; ModuleID = 'strtol.bc'
target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-f32:32:32"
target triple = "pic16-"
@ptr = global i8* inttoptr (i64 160 to i8*), align 1		; <i8**> [#uses=1]
@main.auto.str = internal global [3 x i8] zeroinitializer		; <[3 x i8]*> [#uses=1]
@.str = private constant [3 x i8] c"11\00"		; <[3 x i8]*> [#uses=1]
@main.auto.pEnd = internal global i8* null		; <i8**> [#uses=1]
@main.auto.li = internal global i32 0		; <i32*> [#uses=2]
@strtol.auto.a = internal global i32 0		; <i32*> [#uses=4]
@strtol.auto.c = internal global i8 0		; <i8*> [#uses=10]
@strtol.auto.sign = internal global i8 0		; <i8*> [#uses=3]

define i16 @main() nounwind {
entry:
	%retval = alloca i16		; <i16*> [#uses=2]
	store i16 0, i16* %retval
	call void @llvm.memcpy.i16(i8* getelementptr ([3 x i8]* @main.auto.str, i32 0, i32 0), i8* getelementptr ([3 x i8]* @.str, i32 0, i32 0), i16 3, i32 1)
	%call = call i32 @strtol(i8* getelementptr ([3 x i8]* @main.auto.str, i32 0, i32 0), i8** @main.auto.pEnd, i16 10)		; <i32> [#uses=1]
	store i32 %call, i32* @main.auto.li
	%tmp = load i32* @main.auto.li		; <i32> [#uses=1]
	%sub = sub i32 %tmp, 10		; <i32> [#uses=1]
	%conv = trunc i32 %sub to i8		; <i8> [#uses=1]
	%tmp1 = load i8** @ptr		; <i8*> [#uses=1]
	store i8 %conv, i8* %tmp1
	%0 = load i16* %retval		; <i16> [#uses=1]
	ret i16 %0
}

declare void @llvm.memcpy.i16(i8* nocapture, i8* nocapture, i16, i32) nounwind

define i32 @strtol(i8* %s, i8** %endptr, i16 %base) nounwind {
entry:
	br label %do.body

do.body:		; preds = %do.body, %entry
	%indvar11 = phi i16 [ 0, %entry ], [ %tmp, %do.body ]		; <i16> [#uses=4]
	%s.addr.0 = getelementptr i8* %s, i16 %indvar11		; <i8*> [#uses=1]
	%tmp = add i16 %indvar11, 1		; <i16> [#uses=2]
	%ptrincdec = getelementptr i8* %s, i16 %tmp		; <i8*> [#uses=3]
	%tmp1 = load i8* %s.addr.0		; <i8> [#uses=2]
	store i8 %tmp1, i8* @strtol.auto.c
	%call = tail call i8 @isspace(i8 %tmp1) nounwind		; <i8> [#uses=1]
	%tobool = icmp eq i8 %call, 0		; <i1> [#uses=1]
	br i1 %tobool, label %do.end, label %do.body

do.end:		; preds = %do.body
	store i32 0, i32* @strtol.auto.a
	store i8 0, i8* @strtol.auto.sign
	%tmp3 = load i8* @strtol.auto.c		; <i8> [#uses=3]
	switch i8 %tmp3, label %if.end16 [
		i8 45, label %if.then
		i8 43, label %if.then12
	]

if.then:		; preds = %do.end
	store i8 1, i8* @strtol.auto.sign
	%s.addr.0.sum13 = add i16 %indvar11, 2		; <i16> [#uses=1]
	%ptrincdec6 = getelementptr i8* %s, i16 %s.addr.0.sum13		; <i8*> [#uses=1]
	%tmp7 = load i8* %ptrincdec		; <i8> [#uses=3]
	store i8 %tmp7, i8* @strtol.auto.c
	br label %if.end16

if.then12:		; preds = %do.end
	%s.addr.0.sum = add i16 %indvar11, 2		; <i16> [#uses=1]
	%ptrincdec14 = getelementptr i8* %s, i16 %s.addr.0.sum		; <i8*> [#uses=1]
	%tmp15 = load i8* %ptrincdec		; <i8> [#uses=3]
	store i8 %tmp15, i8* @strtol.auto.c
	br label %if.end16

if.end16:		; preds = %if.then12, %if.then, %do.end
	%tmp57.rle16 = phi i8 [ %tmp15, %if.then12 ], [ %tmp7, %if.then ], [ %tmp3, %do.end ]		; <i8> [#uses=1]
	%tmp17 = phi i8 [ %tmp15, %if.then12 ], [ %tmp7, %if.then ], [ %tmp3, %do.end ]		; <i8> [#uses=1]
	%s.addr.1 = phi i8* [ %ptrincdec6, %if.then ], [ %ptrincdec14, %if.then12 ], [ %ptrincdec, %do.end ]		; <i8*> [#uses=4]
	%cmp19 = icmp eq i8 %tmp17, 48		; <i1> [#uses=1]
	br i1 %cmp19, label %if.then21, label %if.end51

if.then21:		; preds = %if.end16
	%ptrincdec23 = getelementptr i8* %s.addr.1, i16 1		; <i8*> [#uses=3]
	%tmp24 = load i8* %s.addr.1		; <i8> [#uses=4]
	store i8 %tmp24, i8* @strtol.auto.c
	switch i16 %base, label %if.end51 [
		i16 0, label %land.lhs.true
		i16 16, label %land.lhs.true
	]

land.lhs.true:		; preds = %if.then21, %if.then21
	switch i8 %tmp24, label %if.else44 [
		i8 120, label %if.end51.thread
		i8 88, label %if.end51.thread
	]

if.end51.thread:		; preds = %land.lhs.true, %land.lhs.true
	%ptrincdec42 = getelementptr i8* %s.addr.1, i16 2		; <i8*> [#uses=1]
	%tmp43 = load i8* %ptrincdec23		; <i8> [#uses=2]
	store i8 %tmp43, i8* @strtol.auto.c
	br label %for.cond.preheader

if.else44:		; preds = %land.lhs.true
	%cmp46 = icmp eq i16 %base, 0		; <i1> [#uses=1]
	%.base = select i1 %cmp46, i16 8, i16 %base		; <i16> [#uses=1]
	br label %for.cond.preheader

if.end51:		; preds = %if.then21, %if.end16
	%tmp57.rle15 = phi i8 [ %tmp57.rle16, %if.end16 ], [ %tmp24, %if.then21 ]		; <i8> [#uses=2]
	%s.addr.2 = phi i8* [ %s.addr.1, %if.end16 ], [ %ptrincdec23, %if.then21 ]		; <i8*> [#uses=2]
	%cmp53 = icmp eq i16 %base, 0		; <i1> [#uses=1]
	br i1 %cmp53, label %if.then55, label %for.cond.preheader

if.then55:		; preds = %if.end51
	br label %for.cond.preheader

for.cond.preheader:		; preds = %if.then55, %if.end51, %if.else44, %if.end51.thread
	%tmp57.rle14 = phi i8 [ %tmp57.rle15, %if.then55 ], [ %tmp43, %if.end51.thread ], [ %tmp24, %if.else44 ], [ %tmp57.rle15, %if.end51 ]		; <i8> [#uses=1]
	%base.addr.1.ph = phi i16 [ %.base, %if.else44 ], [ 16, %if.end51.thread ], [ 10, %if.then55 ], [ %base, %if.end51 ]		; <i16> [#uses=2]
	%s.addr.3.ph = phi i8* [ %ptrincdec23, %if.else44 ], [ %ptrincdec42, %if.end51.thread ], [ %s.addr.2, %if.then55 ], [ %s.addr.2, %if.end51 ]		; <i8*> [#uses=2]
	%conv86 = sext i16 %base.addr.1.ph to i32		; <i32> [#uses=1]
	br label %for.cond

for.cond:		; preds = %if.end83, %for.cond.preheader
	%tmp57 = phi i8 [ %tmp57.rle14, %for.cond.preheader ], [ %tmp92, %if.end83 ]		; <i8> [#uses=1]
	%indvar = phi i16 [ 0, %for.cond.preheader ], [ %indvar.next, %if.end83 ]		; <i16> [#uses=3]
	%s.addr.3 = getelementptr i8* %s.addr.3.ph, i16 %indvar		; <i8*> [#uses=1]
	%call58 = tail call i8 @isalpha(i8 %tmp57) nounwind		; <i8> [#uses=1]
	%tobool59 = icmp eq i8 %call58, 0		; <i1> [#uses=1]
	%tmp61 = load i8* @strtol.auto.c		; <i8> [#uses=2]
	br i1 %tobool59, label %if.else65, label %if.then60

if.then60:		; preds = %for.cond
	%call62 = tail call i8 @toupper(i8 %tmp61) nounwind		; <i8> [#uses=1]
	%add = add i8 %call62, -55		; <i8> [#uses=1]
	br label %if.end76

if.else65:		; preds = %for.cond
	%call67 = tail call i8 @isdigit(i8 %tmp61) nounwind		; <i8> [#uses=1]
	%tobool68 = icmp eq i8 %call67, 0		; <i1> [#uses=1]
	br i1 %tobool68, label %for.end, label %if.then69

if.then69:		; preds = %if.else65
	%tmp70 = load i8* @strtol.auto.c		; <i8> [#uses=1]
	%sub72 = add i8 %tmp70, -48		; <i8> [#uses=1]
	br label %if.end76

if.end76:		; preds = %if.then69, %if.then60
	%tmp87 = phi i8 [ %add, %if.then60 ], [ %sub72, %if.then69 ]		; <i8> [#uses=3]
	store i8 %tmp87, i8* @strtol.auto.c
	%conv78 = sext i8 %tmp87 to i16		; <i16> [#uses=1]
	%cmp80 = icmp slt i16 %conv78, %base.addr.1.ph		; <i1> [#uses=1]
	br i1 %cmp80, label %if.end83, label %for.end

if.end83:		; preds = %if.end76
	%tmp84 = load i32* @strtol.auto.a		; <i32> [#uses=1]
	%mul = mul i32 %tmp84, %conv86		; <i32> [#uses=1]
	%conv88 = sext i8 %tmp87 to i32		; <i32> [#uses=1]
	%add89 = add i32 %conv88, %mul		; <i32> [#uses=1]
	store i32 %add89, i32* @strtol.auto.a
	%tmp92 = load i8* %s.addr.3		; <i8> [#uses=2]
	store i8 %tmp92, i8* @strtol.auto.c
	%indvar.next = add i16 %indvar, 1		; <i16> [#uses=1]
	br label %for.cond

for.end:		; preds = %if.end76, %if.else65
	%tobool94 = icmp eq i8** %endptr, null		; <i1> [#uses=1]
	br i1 %tobool94, label %if.end98, label %if.then95

if.then95:		; preds = %for.end
	%s.addr.3.sum = add i16 %indvar, -1		; <i16> [#uses=1]
	%sub.ptr = getelementptr i8* %s.addr.3.ph, i16 %s.addr.3.sum		; <i8*> [#uses=1]
	store i8* %sub.ptr, i8** %endptr
	br label %if.end98

if.end98:		; preds = %if.then95, %for.end
	%tmp99 = load i8* @strtol.auto.sign		; <i8> [#uses=1]
	%tobool100 = icmp eq i8 %tmp99, 0		; <i1> [#uses=1]
	%tmp102 = load i32* @strtol.auto.a		; <i32> [#uses=2]
	%neg = sub i32 0, %tmp102		; <i32> [#uses=1]
	%retval.0 = select i1 %tobool100, i32 %tmp102, i32 %neg		; <i32> [#uses=1]
	ret i32 %retval.0
}

define i8 @isalpha(i8 %c) nounwind {
entry:
	%c.off = add i8 %c, -97		; <i8> [#uses=1]
	%or.cond = icmp ugt i8 %c.off, 25		; <i1> [#uses=1]
	br i1 %or.cond, label %lor.rhs, label %lor.end

lor.rhs:		; preds = %entry
	%call = tail call i8 @isupper(i8 %c) nounwind		; <i8> [#uses=1]
	%tobool = icmp ne i8 %call, 0		; <i1> [#uses=1]
	%phitmp = zext i1 %tobool to i8		; <i8> [#uses=1]
	ret i8 %phitmp

lor.end:		; preds = %entry
	ret i8 1
}

define i8 @isdigit(i8 %c) nounwind {
entry:
	%cmp = icmp sgt i8 %c, 57		; <i1> [#uses=1]
	br i1 %cmp, label %land.end, label %land.rhs

land.rhs:		; preds = %entry
	%cmp4 = icmp sgt i8 %c, 47		; <i1> [#uses=1]
	%phitmp = zext i1 %cmp4 to i8		; <i8> [#uses=1]
	ret i8 %phitmp

land.end:		; preds = %entry
	ret i8 0
}

define i8 @isspace(i8 %c) nounwind {
entry:
	%cmp = icmp eq i8 %c, 32		; <i1> [#uses=1]
	br i1 %cmp, label %lor.end, label %lor.rhs

lor.rhs:		; preds = %entry
	%cmp4 = icmp sgt i8 %c, 13		; <i1> [#uses=1]
	br i1 %cmp4, label %lor.end, label %land.rhs

land.rhs:		; preds = %lor.rhs
	%cmp8 = icmp sgt i8 %c, 8		; <i1> [#uses=1]
	%phitmp = zext i1 %cmp8 to i8		; <i8> [#uses=1]
	ret i8 %phitmp

lor.end:		; preds = %lor.rhs, %entry
	%0 = phi i8 [ 1, %entry ], [ 0, %lor.rhs ]		; <i8> [#uses=1]
	ret i8 %0
}

define i8 @toupper(i8 %c) nounwind {
entry:
	%and = and i8 %c, -33		; <i8> [#uses=1]
	%c.off = add i8 %c, -97		; <i8> [#uses=1]
	%or.cond = icmp ugt i8 %c.off, 25		; <i1> [#uses=1]
	%c.and = select i1 %or.cond, i8 %c, i8 %and		; <i8> [#uses=1]
	ret i8 %c.and
}

define i8 @isupper(i8 %c) nounwind {
entry:
	%cmp = icmp sgt i8 %c, 90		; <i1> [#uses=1]
	br i1 %cmp, label %land.end, label %land.rhs

land.rhs:		; preds = %entry
	%cmp4 = icmp sgt i8 %c, 64		; <i1> [#uses=1]
	%phitmp = zext i1 %cmp4 to i8		; <i8> [#uses=1]
	ret i8 %phitmp

land.end:		; preds = %entry
	ret i8 0
}
