1 ; RUN: llvm-upgrade < %s | llvm-as | opt -std-compile-opts | llvm-dis | \
2 ; RUN: %prcontext strstr 2 | grep -v declare | grep bb36.outer:
5 @str = internal constant [68 x i8] c"Dot. date. datum. 123. Some more doubtful demonstration dummy data.\00" ; <[68 x i8]*> [#uses=1]
6 @str1 = internal constant [5 x i8] c"ummy\00" ; <[5 x i8]*> [#uses=1]
7 @str2 = internal constant [6 x i8] c" data\00" ; <[6 x i8]*> [#uses=1]
8 @str3 = internal constant [3 x i8] c"by\00" ; <[3 x i8]*> [#uses=1]
10 i32 @stringSearch_Clib(i32 %count) {
12 %count_addr = alloca i32 ; <i32*> [#uses=2]
13 %retval = alloca i32, align 4 ; <i32*> [#uses=2]
14 %tmp = alloca i32, align 4 ; <i32*> [#uses=2]
15 %i = alloca i32, align 4 ; <i32*> [#uses=5]
16 %c = alloca i32, align 4 ; <i32*> [#uses=9]
17 %j = alloca i32, align 4 ; <i32*> [#uses=4]
18 %p = alloca i8*, align 4 ; <i8**> [#uses=6]
19 %b = alloca [68 x i8], align 16 ; <[68 x i8]*> [#uses=6]
20 "alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
21 store i32 %count, i32* %count_addr
23 %b1 = bitcast [68 x i8]* %b to i8* ; <i8*> [#uses=1]
24 %tmp2 = getelementptr [68 x i8]* @str, i32 0, i32 0 ; <i8*> [#uses=1]
25 call void @llvm.memcpy.i32( i8* %b1, i8* %tmp2, i32 68, i32 1 )
31 %tmp3 = load i32* %i ; <i32> [#uses=1]
32 store i32 %tmp3, i32* %c
36 %b5 = bitcast [68 x i8]* %b to i8* ; <i8*> [#uses=1]
37 %tmp6 = getelementptr [5 x i8]* @str1, i32 0, i32 0 ; <i8*> [#uses=1]
38 %tmp7 = call i8* @strstr( i8* %b5, i8* %tmp6 ) ; <i8*> [#uses=1]
39 store i8* %tmp7, i8** %p
40 %tmp8 = load i8** %p ; <i8*> [#uses=1]
41 %ttmp8 = icmp ne i8* %tmp8, null ; <i1>:0 [#uses=1]
42 %ttmp10 = zext i1 %ttmp8 to i8 ; <i8>:1 [#uses=1]
43 %ttmp7 = icmp ne i8 %ttmp10, 0 ; <i1>:2 [#uses=1]
44 br i1 %ttmp7, label %cond_true, label %cond_next
46 cond_true: ; preds = %bb4
47 %tmp9 = load i8** %p ; <i8*> [#uses=1]
48 %tmp910 = ptrtoint i8* %tmp9 to i32 ; <i32> [#uses=1]
49 %b11 = bitcast [68 x i8]* %b to i8* ; <i8*> [#uses=1]
50 %b1112 = ptrtoint i8* %b11 to i32 ; <i32> [#uses=1]
51 %tmp13 = sub i32 %tmp910, %b1112 ; <i32> [#uses=1]
52 %tmp14 = load i32* %c ; <i32> [#uses=1]
53 %tmp15 = add i32 %tmp13, %tmp14 ; <i32> [#uses=1]
54 store i32 %tmp15, i32* %c
57 cond_next: ; preds = %cond_true, %bb4
58 %b16 = bitcast [68 x i8]* %b to i8* ; <i8*> [#uses=1]
59 %tmp17 = getelementptr [6 x i8]* @str2, i32 0, i32 0 ; <i8*> [#uses=1]
60 %tmp18 = call i8* @strstr( i8* %b16, i8* %tmp17 ) ; <i8*> [#uses=1]
61 store i8* %tmp18, i8** %p
62 %tmp19 = load i8** %p ; <i8*> [#uses=1]
63 %ttmp6 = icmp ne i8* %tmp19, null ; <i1>:3 [#uses=1]
64 %ttmp9 = zext i1 %ttmp6 to i8 ; <i8>:4 [#uses=1]
65 %ttmp4 = icmp ne i8 %ttmp9, 0 ; <i1>:5 [#uses=1]
66 br i1 %ttmp4, label %cond_true20, label %cond_next28
68 cond_true20: ; preds = %cond_next
69 %tmp21 = load i8** %p ; <i8*> [#uses=1]
70 %tmp2122 = ptrtoint i8* %tmp21 to i32 ; <i32> [#uses=1]
71 %b23 = bitcast [68 x i8]* %b to i8* ; <i8*> [#uses=1]
72 %b2324 = ptrtoint i8* %b23 to i32 ; <i32> [#uses=1]
73 %tmp25 = sub i32 %tmp2122, %b2324 ; <i32> [#uses=1]
74 %tmp26 = load i32* %c ; <i32> [#uses=1]
75 %tmp27 = add i32 %tmp25, %tmp26 ; <i32> [#uses=1]
76 store i32 %tmp27, i32* %c
79 cond_next28: ; preds = %cond_true20, %cond_next
80 %b29 = bitcast [68 x i8]* %b to i8* ; <i8*> [#uses=1]
81 %tmp30 = getelementptr [3 x i8]* @str3, i32 0, i32 0 ; <i8*> [#uses=1]
82 %tmp31 = call i32 @strcspn( i8* %b29, i8* %tmp30 ) ; <i32> [#uses=1]
83 %tmp32 = load i32* %c ; <i32> [#uses=1]
84 %tmp33 = add i32 %tmp31, %tmp32 ; <i32> [#uses=1]
85 store i32 %tmp33, i32* %c
86 %tmp34 = load i32* %i ; <i32> [#uses=1]
87 %tmp35 = add i32 %tmp34, 1 ; <i32> [#uses=1]
88 store i32 %tmp35, i32* %i
91 bb36: ; preds = %cond_next28, %bb
92 %tmp37 = load i32* %i ; <i32> [#uses=1]
93 %ttmp3= icmp sle i32 %tmp37, 249 ; <i1>:6 [#uses=1]
94 %ttmp12 = zext i1 %ttmp3 to i8 ; <i8>:7 [#uses=1]
95 %ttmp1 = icmp ne i8 %ttmp12, 0 ; <i1>:8 [#uses=1]
96 br i1 %ttmp1, label %bb4, label %bb38
99 %tmp39 = load i32* %j ; <i32> [#uses=1]
100 %tmp40 = add i32 %tmp39, 1 ; <i32> [#uses=1]
101 store i32 %tmp40, i32* %j
104 bb41: ; preds = %bb38, %entry
105 %tmp42 = load i32* %j ; <i32> [#uses=1]
106 %tmp43 = load i32* %count_addr ; <i32> [#uses=1]
107 %ttmp2 = icmp slt i32 %tmp42, %tmp43 ; <i1>:9 [#uses=1]
108 %ttmp11 = zext i1 %ttmp2 to i8 ; <i8>:10 [#uses=1]
109 %ttmp5 = icmp ne i8 %ttmp11, 0 ; <i1>:11 [#uses=1]
110 br i1 %ttmp5, label %bb, label %bb44
112 bb44: ; preds = %bb41
113 %tmp45 = load i32* %c ; <i32> [#uses=1]
114 store i32 %tmp45, i32* %tmp
115 %tmp46 = load i32* %tmp ; <i32> [#uses=1]
116 store i32 %tmp46, i32* %retval
119 return: ; preds = %bb44
120 %retval47 = load i32* %retval ; <i32> [#uses=1]
124 declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
126 declare i8* @strstr(i8*, i8*)
128 declare i32 @strcspn(i8*, i8*)