int sieveBuildBig(unsigned char *array, unsigned size, struct BigNum const *bn,
                  struct BigNum const *step, unsigned dbl) {
  unsigned i, j;
  unsigned p;
  unsigned s;
  unsigned t;
  unsigned char small[(65536 / 16)];
  assert(array);
  if (bnLSWord(step) & 1) {
    s = bnLSWord(bn) & 1;
    memset(array, 0xAA >> s, size);
  } else {
    memset(array, 255, size);
    assert(bnLSWord(bn) & 1);
  }
  sieveSmall(small, (65536 / 16));
  i = (small[0] & 1) ? 0 : sieveSearch(small, (65536 / 16), 0);
  do {
    p = 2 * i + 1;
    t = bnModQ(step, p);
    if (!t) {
      assert(bnModQ(bn, p) != 0);
      continue;
    }
    t = sieveModInvert(bnModQ(step, p), p);
    assert(t);
    t = p - t;
    s = bnModQ(bn, p);
    s = (unsigned)(((unsigned long)s * t) % p);
    sieveSingle(array, size, s, p);
    for (j = 0; j < dbl; j++) {
      t = (t & 1) ? p / 2 + t / 2 + 1 : t / 2;
      s += t;
      if (s >= p || s < t)
        s -= p;
      sieveSingle(array, size, s, p);
    }
  } while ((i = sieveSearch(small, (65536 / 16), i)) != 0);
  return 0;
}


x86 assembly (clang, -O0):
<sieveBuildBig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1070 <assert@plt>
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <bnLSWord@plt>
and    $0x1,%eax
cmp    $0x0,%eax
je     11f1 <sieveBuildBig+0x71>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <bnLSWord@plt>
and    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%ecx
mov    $0xaa,%eax
sar    %cl,%eax
mov    -0xc(%rbp),%ecx
mov    %ecx,%edx
movzbl %al,%esi
call   1060 <memset@plt>
jmp    121b <sieveBuildBig+0x9b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
mov    %eax,%edx
mov    $0xff,%esi
call   1060 <memset@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <bnLSWord@plt>
mov    %eax,%edi
and    $0x1,%edi
mov    $0x0,%al
call   1070 <assert@plt>
lea    -0x1040(%rbp),%rdi
mov    $0x1000,%esi
mov    $0x0,%al
call   10a0 <sieveSmall@plt>
movzbl -0x1040(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     124e <sieveBuildBig+0xce>
xor    %eax,%eax
mov    %eax,-0x1044(%rbp)
jmp    1269 <sieveBuildBig+0xe9>
lea    -0x1040(%rbp),%rdi
mov    $0x1000,%esi
xor    %edx,%edx
mov    $0x0,%al
call   1050 <sieveSearch@plt>
mov    %eax,-0x1044(%rbp)
mov    -0x1044(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    $0x0,%al
call   1080 <bnModQ@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    12be <sieveBuildBig+0x13e>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    $0x0,%al
call   1080 <bnModQ@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1070 <assert@plt>
jmp    13d0 <sieveBuildBig+0x250>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    $0x0,%al
call   1080 <bnModQ@plt>
mov    %eax,%edi
mov    -0x30(%rbp),%esi
mov    $0x0,%al
call   1040 <sieveModInvert@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    $0x0,%al
call   1070 <assert@plt>
mov    -0x30(%rbp),%eax
sub    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    $0x0,%al
call   1080 <bnModQ@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x38(%rbp),%ecx
imul   %rcx,%rax
mov    -0x30(%rbp),%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    $0x0,%al
call   1090 <sieveSingle@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    13cb <sieveBuildBig+0x24b>
mov    -0x38(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1368 <sieveBuildBig+0x1e8>
mov    -0x30(%rbp),%eax
shr    $0x1,%eax
mov    -0x38(%rbp),%ecx
shr    $0x1,%ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x1048(%rbp)
jmp    1374 <sieveBuildBig+0x1f4>
mov    -0x38(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x1048(%rbp)
mov    -0x1048(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jae    139e <sieveBuildBig+0x21e>
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jae    13a9 <sieveBuildBig+0x229>
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    $0x0,%al
call   1090 <sieveSingle@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1331 <sieveBuildBig+0x1b1>
jmp    13d0 <sieveBuildBig+0x250>
lea    -0x1040(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    $0x1000,%esi
mov    $0x0,%al
call   1050 <sieveSearch@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jne    1272 <sieveBuildBig+0xf2>
xor    %eax,%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sieveBuildBig>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1038,%rsp
mov    %r8d,0x4(%rsp)
mov    %rcx,%rbp
mov    %rdx,%r15
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <assert@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <bnLSWord@plt>
test   $0x1,%al
mov    %rbx,0x8(%rsp)
jne    11e4 <sieveBuildBig+0x64>
mov    %r14d,%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1060 <memset@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <bnLSWord@plt>
and    $0x1,%eax
mov    %eax,%edi
xor    %eax,%eax
call   1070 <assert@plt>
jmp    1204 <sieveBuildBig+0x84>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <bnLSWord@plt>
and    $0x1,%al
mov    $0xaa,%esi
mov    %eax,%ecx
shr    %cl,%esi
mov    %r14d,%edx
mov    %rbx,%rdi
call   1060 <memset@plt>
mov    %r14d,0x14(%rsp)
lea    0x30(%rsp),%rdi
mov    $0x1000,%esi
xor    %eax,%eax
call   10a0 <sieveSmall@plt>
testb  $0x1,0x30(%rsp)
mov    $0x0,%ebx
jne    123b <sieveBuildBig+0xbb>
lea    0x30(%rsp),%rdi
mov    $0x1000,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <sieveSearch@plt>
mov    %eax,%ebx
mov    %rbp,0x28(%rsp)
mov    %r15,0x20(%rsp)
jmp    1296 <sieveBuildBig+0x116>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1080 <bnModQ@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
xor    %eax,%eax
call   1070 <assert@plt>
lea    0x30(%rsp),%rdi
mov    $0x1000,%esi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1050 <sieveSearch@plt>
mov    %eax,%ebx
test   %eax,%eax
mov    0x28(%rsp),%rbp
mov    0x20(%rsp),%r15
je     1395 <sieveBuildBig+0x215>
lea    (%rbx,%rbx,1),%r14d
add    $0x1,%r14d
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1080 <bnModQ@plt>
test   %eax,%eax
mov    %rbx,0x18(%rsp)
je     1250 <sieveBuildBig+0xd0>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1080 <bnModQ@plt>
mov    %eax,%edi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <sieveModInvert@plt>
mov    %eax,%ebp
mov    %eax,%edi
xor    %eax,%eax
call   1070 <assert@plt>
mov    %r14d,%r13d
sub    %ebp,%r13d
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1080 <bnModQ@plt>
mov    %eax,%ecx
mov    %r13,%rax
imul   %rcx,%rax
mov    %r14d,%ecx
mov    %rax,%rdx
shr    $0x20,%rdx
je     1310 <sieveBuildBig+0x190>
xor    %edx,%edx
div    %rcx
mov    %rdx,%r15
jmp    1317 <sieveBuildBig+0x197>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %ecx
mov    %edx,%r15d
mov    0x8(%rsp),%rdi
mov    0x14(%rsp),%ebx
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1090 <sieveSingle@plt>
cmpl   $0x0,0x4(%rsp)
je     126c <sieveBuildBig+0xec>
mov    0x18(%rsp),%rax
mov    %eax,%ebp
and    $0x7fffffff,%ebp
add    $0x1,%ebp
mov    0x4(%rsp),%r12d
nop
mov    %r13d,%eax
and    $0x1,%eax
neg    %eax
and    %ebp,%eax
shr    %r13d
add    %eax,%r13d
add    %r13d,%r15d
mov    $0x0,%eax
cmovb  %r14d,%eax
cmp    %r14d,%r15d
cmovae %r14d,%eax
sub    %eax,%r15d
mov    0x8(%rsp),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1090 <sieveSingle@plt>
add    $0xffffffff,%r12d
jne    1350 <sieveBuildBig+0x1d0>
jmp    126c <sieveBuildBig+0xec>
xor    %eax,%eax
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.BigNum = type opaque
define i32 @sieveBuildBig(i8* %0, i32 %1, %struct.BigNum* %2, %struct.BigNum* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.BigNum*
%9 = alloca %struct.BigNum*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [4096 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store %struct.BigNum* %2, %struct.BigNum** %8
store %struct.BigNum* %3, %struct.BigNum** %9
store i32 %4, i32* %10
%17 = load i8*, i8** %6
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %17)
%19 = load %struct.BigNum*, %struct.BigNum** %9
%20 = call i32 (%struct.BigNum*, ...) bitcast (i32 (...)* @bnLSWord to i32 (%struct.BigNum*, ...)*)(%struct.BigNum* %19)
%21 = and i32 %20, 1
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %5
%24 = load %struct.BigNum*, %struct.BigNum** %8
%25 = call i32 (%struct.BigNum*, ...) bitcast (i32 (...)* @bnLSWord to i32 (%struct.BigNum*, ...)*)(%struct.BigNum* %24)
%26 = and i32 %25, 1
store i32 %26, i32* %14
%27 = load i8*, i8** %6
%28 = load i32, i32* %14
%29 = ashr i32 170, %28
%30 = trunc i32 %29 to i8
%31 = load i32, i32* %7
%32 = zext i32 %31 to i64
br label %41
33: ; preds = %5
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = zext i32 %35 to i64
%37 = load %struct.BigNum*, %struct.BigNum** %8
%38 = call i32 (%struct.BigNum*, ...) bitcast (i32 (...)* @bnLSWord to i32 (%struct.BigNum*, ...)*)(%struct.BigNum* %37)
%39 = and i32 %38, 1
%40 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %39)
br label %41
41: ; preds = %33, %23
%42 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%43 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @sieveSmall to i32 (i8*, i32, ...)*)(i8* %42, i32 4096)
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = and i32 %46, 1
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %41
br label %53
50: ; preds = %41
%51 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%52 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @sieveSearch to i32 (i8*, i32, i32, ...)*)(i8* %51, i32 4096, i32 0)
br label %53
53: ; preds = %50, %49
%54 = phi i32 [ 0, %49 ], [ %52, %50 ]
store i32 %54, i32* %11
br label %55
55: ; preds = %143, %53
%56 = load i32, i32* %11
%57 = mul i32 2, %56
%58 = add i32 %57, 1
store i32 %58, i32* %13
%59 = load %struct.BigNum*, %struct.BigNum** %9
%60 = load i32, i32* %13
%61 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %59, i32 %60)
store i32 %61, i32* %15
%62 = load i32, i32* %15
%63 = icmp ne i32 %62, 0
br i1 %63, label %71, label %64
64: ; preds = %55
%65 = load %struct.BigNum*, %struct.BigNum** %8
%66 = load i32, i32* %13
%67 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %65, i32 %66)
%68 = icmp ne i32 %67, 0
%69 = zext i1 %68 to i32
%70 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %69)
br label %143
71: ; preds = %55
%72 = load %struct.BigNum*, %struct.BigNum** %9
%73 = load i32, i32* %13
%74 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %72, i32 %73)
%75 = load i32, i32* %13
%76 = call i32 (i32, i32, ...) bitcast (i32 (...)* @sieveModInvert to i32 (i32, i32, ...)*)(i32 %74, i32 %75)
store i32 %76, i32* %15
%77 = load i32, i32* %15
%78 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %77)
%79 = load i32, i32* %13
%80 = load i32, i32* %15
%81 = sub i32 %79, %80
store i32 %81, i32* %15
%82 = load %struct.BigNum*, %struct.BigNum** %8
%83 = load i32, i32* %13
%84 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %82, i32 %83)
store i32 %84, i32* %14
%85 = load i32, i32* %14
%86 = zext i32 %85 to i64
%87 = load i32, i32* %15
%88 = zext i32 %87 to i64
%89 = mul i64 %86, %88
%90 = load i32, i32* %13
%91 = zext i32 %90 to i64
%92 = urem i64 %89, %91
%93 = trunc i64 %92 to i32
store i32 %93, i32* %14
%94 = load i8*, i8** %6
%95 = load i32, i32* %7
%96 = load i32, i32* %14
%97 = load i32, i32* %13
%98 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @sieveSingle to i32 (i8*, i32, i32, i32, ...)*)(i8* %94, i32 %95, i32 %96, i32 %97)
store i32 0, i32* %12
br label %99
99: ; preds = %139, %71
%100 = load i32, i32* %12
%101 = load i32, i32* %10
%102 = icmp ult i32 %100, %101
br i1 %102, label %103, label %142
103: ; preds = %99
%104 = load i32, i32* %15
%105 = and i32 %104, 1
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %114
107: ; preds = %103
%108 = load i32, i32* %13
%109 = udiv i32 %108, 2
%110 = load i32, i32* %15
%111 = udiv i32 %110, 2
%112 = add i32 %109, %111
%113 = add i32 %112, 1
br label %117
114: ; preds = %103
%115 = load i32, i32* %15
%116 = udiv i32 %115, 2
br label %117
117: ; preds = %114, %107
%118 = phi i32 [ %113, %107 ], [ %116, %114 ]
store i32 %118, i32* %15
%119 = load i32, i32* %15
%120 = load i32, i32* %14
%121 = add i32 %120, %119
store i32 %121, i32* %14
%122 = load i32, i32* %14
%123 = load i32, i32* %13
%124 = icmp uge i32 %122, %123
br i1 %124, label %129, label %125
125: ; preds = %117
%126 = load i32, i32* %14
%127 = load i32, i32* %15
%128 = icmp ult i32 %126, %127
br i1 %128, label %129, label %133
129: ; preds = %125, %117
%130 = load i32, i32* %13
%131 = load i32, i32* %14
%132 = sub i32 %131, %130
store i32 %132, i32* %14
br label %133
133: ; preds = %129, %125
%134 = load i8*, i8** %6
%135 = load i32, i32* %7
%136 = load i32, i32* %14
%137 = load i32, i32* %13
%138 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @sieveSingle to i32 (i8*, i32, i32, i32, ...)*)(i8* %134, i32 %135, i32 %136, i32 %137)
br label %139
139: ; preds = %133
%140 = load i32, i32* %12
%141 = add i32 %140, 1
store i32 %141, i32* %12
br label %99
142: ; preds = %99
br label %143
143: ; preds = %142, %64
%144 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%145 = load i32, i32* %11
%146 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @sieveSearch to i32 (i8*, i32, i32, ...)*)(i8* %144, i32 4096, i32 %145)
store i32 %146, i32* %11
%147 = icmp ne i32 %146, 0
br i1 %147, label %55, label %148
148: ; preds = %143
ret i32 0
}

LLVM IR (-O2):
%struct.BigNum = type opaque
define i32 @sieveBuildBig(i8* %0, i32 %1, %struct.BigNum* %2, %struct.BigNum* %3, i32 %4) {
%6 = alloca [4096 x i8]
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @assert to i32 (i8*, ...)*)(i8* %0)
%9 = tail call i32 (%struct.BigNum*, ...) bitcast (i32 (...)* @bnLSWord to i32 (%struct.BigNum*, ...)*)(%struct.BigNum* %3)
%10 = and i32 %9, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %5
%13 = tail call i32 (%struct.BigNum*, ...) bitcast (i32 (...)* @bnLSWord to i32 (%struct.BigNum*, ...)*)(%struct.BigNum* %2)
%14 = and i32 %13, 1
%15 = lshr i32 170, %14
%16 = trunc i32 %15 to i8
%17 = zext i32 %1 to i64
tail call void @llvm.memset.p0i8.i64(i8* align 1 %0, i8 %16, i64 %17, i1 false)
br label %23
18: ; preds = %5
%19 = zext i32 %1 to i64
tail call void @llvm.memset.p0i8.i64(i8* align 1 %0, i8 -1, i64 %19, i1 false)
%20 = tail call i32 (%struct.BigNum*, ...) bitcast (i32 (...)* @bnLSWord to i32 (%struct.BigNum*, ...)*)(%struct.BigNum* %2)
%21 = and i32 %20, 1
%22 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %21)
br label %23
23: ; preds = %18, %12
%24 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @sieveSmall to i32 (i8*, i32, ...)*)(i8* %7, i32 4096)
%25 = load i8, i8* %7
%26 = and i8 %25, 1
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @sieveSearch to i32 (i8*, i32, i32, ...)*)(i8* %7, i32 4096, i32 0)
br label %30
30: ; preds = %23, %28
%31 = phi i32 [ %29, %28 ], [ 0, %23 ]
%32 = icmp eq i32 %4, 0
br label %33
33: ; preds = %78, %30
%34 = phi i32 [ %31, %30 ], [ %79, %78 ]
%35 = shl i32 %34, 1
%36 = or i32 %35, 1
%37 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %3, i32 %36)
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %33
%40 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %2, i32 %36)
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i32
%43 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %42)
br label %78
44: ; preds = %33
%45 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %3, i32 %36)
%46 = call i32 (i32, i32, ...) bitcast (i32 (...)* @sieveModInvert to i32 (i32, i32, ...)*)(i32 %45, i32 %36)
%47 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %46)
%48 = sub i32 %36, %46
%49 = call i32 (%struct.BigNum*, i32, ...) bitcast (i32 (...)* @bnModQ to i32 (%struct.BigNum*, i32, ...)*)(%struct.BigNum* %2, i32 %36)
%50 = zext i32 %49 to i64
%51 = zext i32 %48 to i64
%52 = mul nuw i64 %50, %51
%53 = zext i32 %36 to i64
%54 = urem i64 %52, %53
%55 = trunc i64 %54 to i32
%56 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @sieveSingle to i32 (i8*, i32, i32, i32, ...)*)(i8* %0, i32 %1, i32 %55, i32 %36)
br i1 %32, label %78, label %57
57: ; preds = %44
%58 = and i32 %34, 2147483647
%59 = add nuw i32 %58, 1
br label %60
60: ; preds = %57, %60
%61 = phi i32 [ %48, %57 ], [ %68, %60 ]
%62 = phi i32 [ %55, %57 ], [ %74, %60 ]
%63 = phi i32 [ 0, %57 ], [ %76, %60 ]
%64 = and i32 %61, 1
%65 = icmp eq i32 %64, 0
%66 = lshr i32 %61, 1
%67 = select i1 %65, i32 0, i32 %59
%68 = add i32 %66, %67
%69 = add i32 %68, %62
%70 = icmp uge i32 %69, %36
%71 = icmp ult i32 %69, %68
%72 = or i1 %70, %71
%73 = select i1 %72, i32 %36, i32 0
%74 = sub i32 %69, %73
%75 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @sieveSingle to i32 (i8*, i32, i32, i32, ...)*)(i8* %0, i32 %1, i32 %74, i32 %36)
%76 = add nuw i32 %63, 1
%77 = icmp eq i32 %76, %4
br i1 %77, label %78, label %60
78: ; preds = %60, %44, %39
%79 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @sieveSearch to i32 (i8*, i32, i32, ...)*)(i8* %7, i32 4096, i32 %34)
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %33
81: ; preds = %78
ret i32 0
}