#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 */
typedef int uint64_t;

/* Variables and functions */
scalar_t__ is_prime(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  uint64_t sum = 0, number = 0;
  do {
    number++;
    if (is_prime(number)) {
      sum += number;
    }
  } while (number != 2000000);
  printf("%llu\n", sum);
  return (0);
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1168 <main+0x48>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    116d <main+0x4d>
cmpl   $0x1e8480,-0x18(%rbp)
jne    1144 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    $0x1,%ebp
jmp    113d <main+0x1d>
nopl   0x0(%rax)
add    %ecx,%ebx
add    $0x1,%ebp
cmp    $0x1e8481,%ebp
je     1152 <main+0x32>
mov    %ebp,%edi
call   1040 <is_prime@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     1130 <main+0x10>
mov    %ebp,%ecx
jmp    1130 <main+0x10>
lea    0xea7(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %19, %2
%9 = load i32, i32* %7
%10 = add nsw i32 %9, 1
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = call i64 @is_prime(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = add nsw i32 %16, %15
store i32 %17, i32* %6
br label %18
18: ; preds = %14, %8
br label %19
19: ; preds = %18
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 2000000
br i1 %21, label %8, label %22
22: ; preds = %19
%23 = load i32, i32* %6
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%llu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ %10, %3 ]
%5 = phi i32 [ 0, %2 ], [ %6, %3 ]
%6 = add nuw nsw i32 %5, 1
%7 = tail call i64 @is_prime(i32 %6)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32 0, i32 %6
%10 = add nuw nsw i32 %9, %4
%11 = icmp eq i32 %6, 2000000
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}