#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*/ printf(char *, int);
int sqrt(float);
int main(void) {
  int sum = 2;
  char isPrime;
  for (int i = 3; i < 100; i++) {
    isPrime = 1;
    for (int j = 2; j <= sqrt((float)i); j++) {
      if (i % j == 0) {
        isPrime = 0;
        break;
      }
    }
    if (isPrime) {
      sum += i;
    }
  }
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x3,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jge    11c1 <main+0xa1>
movb   $0x1,-0x9(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     119b <main+0x7b>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    1188 <main+0x68>
movb   $0x0,-0x9(%rbp)
jmp    119b <main+0x7b>
jmp    118d <main+0x6d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <main+0x32>
cmpb   $0x0,-0x9(%rbp)
je     11ae <main+0x8e>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11b3 <main+0x93>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <main+0x1d>
mov    -0x8(%rbp),%esi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x2,%r14d
mov    $0x3,%ebp
jmp    114b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
nop
add    %ecx,%r14d
add    $0x1,%ebp
cmp    $0x64,%ebp
je     1192 <main+0x72>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <sqrt@plt>
mov    %ebp,%ecx
cmp    $0x2,%eax
jl     1140 <main+0x20>
mov    $0x1,%ebx
nopl   0x0(%rax)
add    $0x1,%ebx
xor    %ecx,%ecx
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
test   %edx,%edx
je     1140 <main+0x20>
movss  0xc(%rsp),%xmm0
call   1040 <sqrt@plt>
cmp    %eax,%ebx
jl     1170 <main+0x50>
mov    %ebp,%ecx
jmp    1140 <main+0x20>
lea    0xe67(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 3, i32* %4
br label %6
6: ; preds = %34, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %37
9: ; preds = %6
store i8 1, i8* %3
store i32 2, i32* %5
br label %10
10: ; preds = %23, %9
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = sitofp i32 %12 to float
%14 = call i32 @sqrt(float %13)
%15 = icmp sle i32 %11, %14
br i1 %15, label %16, label %26
16: ; preds = %10
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i8 0, i8* %3
br label %26
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %10
26: ; preds = %21, %10
%27 = load i8, i8* %3
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %4
%31 = load i32, i32* %2
%32 = add nsw i32 %31, %30
store i32 %32, i32* %2
br label %33
33: ; preds = %29, %26
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %6
37: ; preds = %6
%38 = load i32, i32* %2
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %17
%2 = phi i32 [ 3, %0 ], [ %20, %17 ]
%3 = phi i32 [ 2, %0 ], [ %19, %17 ]
%4 = sitofp i32 %2 to float
%5 = tail call i32 @sqrt(float %4)
%6 = icmp slt i32 %5, 2
br i1 %6, label %17, label %13
7: ; preds = %17
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
9: ; preds = %13
%10 = add nuw nsw i32 %14, 1
%11 = tail call i32 @sqrt(float %4)
%12 = icmp slt i32 %14, %11
br i1 %12, label %13, label %17
13: ; preds = %1, %9
%14 = phi i32 [ %10, %9 ], [ 2, %1 ]
%15 = urem i32 %2, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %9, %13, %1
%18 = phi i32 [ %2, %1 ], [ 0, %13 ], [ %2, %9 ]
%19 = add nuw nsw i32 %18, %3
%20 = add nuw nsw i32 %2, 1
%21 = icmp eq i32 %20, 100
br i1 %21, label %7, label %1
}