1 ; RUN: llc -mcpu=cortex-a8 < %s
2 ; rdar://problem/10137436: sqlite3 miscompile
8 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32"
9 target triple = "thumbv7-apple-ios4.0.0"
11 declare ptr @__memset_chk(ptr, i32, i32, i32) nounwind
13 define hidden fastcc i32 @sqlite3VdbeExec(ptr %p) nounwind {
15 br label %sqlite3VarintLen.exit7424
17 sqlite3VarintLen.exit7424: ; preds = %do.body.i7423
20 do.body.i: ; preds = %do.body.i, %sqlite3VarintLen.exit7424
21 br i1 undef, label %do.body.i, label %sqlite3VarintLen.exit
23 sqlite3VarintLen.exit: ; preds = %do.body.i
24 %sub2322 = add i64 undef, undef
25 br i1 undef, label %too_big, label %if.end2327
27 if.end2327: ; preds = %sqlite3VarintLen.exit
28 br i1 undef, label %if.end2341, label %no_mem
30 if.end2341: ; preds = %if.end2327
31 br label %for.body2355
33 for.body2355: ; preds = %for.body2355, %if.end2341
34 %add2366 = add nsw i32 undef, undef
35 br i1 undef, label %for.body2377, label %for.body2355
37 for.body2377: ; preds = %for.body2355
38 %conv23836154 = zext i32 %add2366 to i64
39 %sub2384 = sub i64 %sub2322, %conv23836154
40 %conv2385 = trunc i64 %sub2384 to i32
41 %len.0.i = select i1 undef, i32 %conv2385, i32 undef
42 %sub.i7384 = sub nsw i32 %len.0.i, 0
43 %call.i.i7385 = call ptr @__memset_chk(ptr undef, i32 0, i32 %sub.i7384, i32 undef) nounwind
46 too_big: ; preds = %sqlite3VarintLen.exit
49 no_mem: ; preds = %if.end2327, %for.body, %entry.no_mem_crit_edge
52 sqlite3ErrStr.exit: ; preds = %if.then82