#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 */
int /*<<< orphan*/ getchar();
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, unsigned long long);
int main(void) {
  unsigned long long soma = 0;
  int num;
  for (num = 3; num <= 2000000; num += 2) {
    if (isPrime(num))
      soma += num;
  }
  soma += 2;
  printf("soma = %lld\n", soma);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
cmpl   $0x1e8480,-0x14(%rbp)
jg     118c <main+0x5c>
mov    -0x14(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1179 <main+0x49>
movslq -0x14(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    117e <main+0x4e>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <main+0x1e>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x3,%ebx
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %ebx,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
cmovne %rbx,%rax
add    %rax,%r14
lea    0x2(%rbx),%rax
cmp    $0x1e847f,%rbx
mov    %rax,%rbx
jb     1140 <main+0x10>
add    $0x2,%r14
lea    0xe94(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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