#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ isprime(int);
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char *argv[]) {
  int n, pc, foundone;
  printf("Starting. Numbers to be scanned= %d\n", 2500000);
  pc = 4;
  for (n = 11; n <= 2500000; n = n + 2) {
    if (isprime(n)) {
      pc++;
      foundone = n;
    }
    if ((n - 1) % 100000 == 0)
      printf("Numbers scanned= %d   Primes found= %d\n", n - 1, pc);
  }
  printf("Done. Largest prime is %d Total primes %d\n", foundone, pc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x2625a0,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x4,-0x18(%rbp)
movl   $0xb,-0x14(%rbp)
cmpl   $0x2625a0,-0x14(%rbp)
jg     11c6 <main+0xa6>
mov    -0x14(%rbp),%edi
call   1040 <isprime@plt>
cmp    $0x0,%rax
je     1185 <main+0x65>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    $0x186a0,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b3 <main+0x93>
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x18(%rbp),%edx
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b8 <main+0x98>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <main+0x37>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
mov    $0x2625a0,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4,%ebp
mov    $0x9,%ebx
mov    $0xa,%r13d
jmp    1160 <main+0x40>
add    $0x2,%r13d
mov    %r12d,%ebx
cmp    $0x26259f,%r12d
jae    11c0 <main+0xa0>
mov    %ebp,%r14d
lea    0x2(%rbx),%r12d
mov    %r13d,%eax
shr    $0x5,%eax
imul   $0xa7c5ac5,%rax,%rax
shr    $0x27,%rax
imul   $0x186a0,%eax,%r15d
mov    %r12d,%edi
call   1040 <isprime@plt>
xor    %ebp,%ebp
test   %rax,%rax
mov    0x4(%rsp),%eax
cmovne %r12d,%eax
mov    %eax,0x4(%rsp)
setne  %bpl
add    %r14d,%ebp
mov    %ebx,%eax
sub    %r15d,%eax
cmp    $0xffffffff,%eax
jne    1150 <main+0x30>
add    $0x1,%ebx
lea    0xe72(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1150 <main+0x30>
lea    0xe86(%rip),%rdi
mov    0x4(%rsp),%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Starting. Numbers to be scanned= %d\0A\00"
@.str.1 = [40 x i8] c"Numbers scanned= %d Primes found= %d\0A\00"
@.str.2 = [43 x i8] c"Done. Largest prime is %d Total primes %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 2500000)
store i32 4, i32* %7
store i32 11, i32* %6
br label %10
10: ; preds = %32, %2
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 2500000
br i1 %12, label %13, label %35
13: ; preds = %10
%14 = load i32, i32* %6
%15 = call i64 @isprime(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
%20 = load i32, i32* %6
store i32 %20, i32* %8
br label %21
21: ; preds = %17, %13
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 1
%24 = srem i32 %23, 100000
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = load i32, i32* %6
%28 = sub nsw i32 %27, 1
%29 = load i32, i32* %7
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29)
br label %31
31: ; preds = %26, %21
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 2
store i32 %34, i32* %6
br label %10
35: ; preds = %10
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %37)
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [37 x i8] c"Starting. Numbers to be scanned= %d\0A\00"
@.str.1 = [40 x i8] c"Numbers scanned= %d Primes found= %d\0A\00"
@.str.2 = [43 x i8] c"Done. Largest prime is %d Total primes %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 2500000)
br label %4
4: ; preds = %2, %19
%5 = phi i32 [ undef, %2 ], [ %13, %19 ]
%6 = phi i32 [ 4, %2 ], [ %12, %19 ]
%7 = phi i32 [ 11, %2 ], [ %20, %19 ]
%8 = tail call i64 @isprime(i32 %7)
%9 = icmp eq i64 %8, 0
%10 = xor i1 %9, true
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %6, %11
%13 = select i1 %9, i32 %5, i32 %7
%14 = add nsw i32 %7, -1
%15 = urem i32 %14, 100000
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %12)
br label %19
19: ; preds = %4, %17
%20 = add nuw nsw i32 %7, 2
%21 = icmp ult i32 %7, 2499999
br i1 %21, label %4, label %22
22: ; preds = %19
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %12)
ret i32 0
}