#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 is_curious(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(int argc, char *argv[]) {
  unsigned sum = 0;
  for (unsigned i = 3; i <= 9999999; i++) {
    if (is_curious(i) == true)
      sum += i;
  }
  printf("Sum: %u\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   $0x3,-0x18(%rbp)
cmpl   $0x98967f,-0x18(%rbp)
ja     117e <main+0x5e>
mov    -0x18(%rbp),%edi
call   1040 <is_curious@plt>
cmp    $0x1,%eax
jne    116b <main+0x4b>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <main+0x50>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xe78(%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    $0x3,%ebp
jmp    113d <main+0x1d>
nopl   0x0(%rax)
add    %ecx,%ebx
add    $0x1,%ebp
cmp    $0x989680,%ebp
je     114f <main+0x2f>
mov    %ebp,%edi
call   1040 <is_curious@plt>
mov    %ebp,%ecx
cmp    $0x1,%eax
je     1130 <main+0x10>
xor    %ecx,%ecx
jmp    1130 <main+0x10>
lea    0xeaa(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Sum: %u\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 3, i32* %7
br label %8
8: ; preds = %20, %2
%9 = load i32, i32* %7
%10 = icmp ule i32 %9, 9999999
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %7
%13 = call i32 @is_curious(i32 %12)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = add i32 %17, %16
store i32 %18, i32* %6
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %7
%22 = add i32 %21, 1
store i32 %22, i32* %7
br label %8
23: ; preds = %8
%24 = load i32, i32* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %24)
ret i32 0
}

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