#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__ checkIfPrime(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long, unsigned long);
unsigned long int sumOfPrimes(unsigned long int low, unsigned long int high) {
  unsigned long int sum = 0;
  for (unsigned long int i = low; i < high; i++) {
    if (checkIfPrime(i)) {
      sum += i;
      printf("count: %lu\trunning sum: %lu\n", i, sum);
    }
  }
  return sum;
}


x86 assembly (clang, -O0):
<sumOfPrimes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1197 <sumOfPrimes+0x77>
mov    -0x20(%rbp),%rdi
call   1030 <checkIfPrime@plt>
cmp    $0x0,%rax
je     1181 <sumOfPrimes+0x61>
mov    -0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
jmp    1186 <sumOfPrimes+0x66>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1140 <sumOfPrimes+0x20>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumOfPrimes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    %rsi,%rdi
jae    1169 <sumOfPrimes+0x49>
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r15d,%r15d
lea    0xec3(%rip),%r12
jmp    1149 <sumOfPrimes+0x29>
nop
add    $0x1,%rbx
cmp    %rbx,%r14
je     116c <sumOfPrimes+0x4c>
mov    %rbx,%rdi
call   1030 <checkIfPrime@plt>
test   %rax,%rax
je     1140 <sumOfPrimes+0x20>
add    %rbx,%r15
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
jmp    1140 <sumOfPrimes+0x20>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"count: %lu\09running sum: %lu\0A\00"
define i64 @sumOfPrimes(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
store i64 0, i64* %5
%7 = load i64, i64* %3
store i64 %7, i64* %6
br label %8
8: ; preds = %24, %2
%9 = load i64, i64* %6
%10 = load i64, i64* %4
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i64, i64* %6
%14 = call i64 @checkIfPrime(i64 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i64, i64* %6
%18 = load i64, i64* %5
%19 = add i64 %18, %17
store i64 %19, i64* %5
%20 = load i64, i64* %6
%21 = load i64, i64* %5
%22 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %20, i64 %21)
br label %23
23: ; preds = %16, %12
br label %24
24: ; preds = %23
%25 = load i64, i64* %6
%26 = add i64 %25, 1
store i64 %26, i64* %6
br label %8
27: ; preds = %8
%28 = load i64, i64* %5
ret i64 %28
}

LLVM IR (-O2):
@.str = [29 x i8] c"count: %lu\09running sum: %lu\0A\00"
define i64 @sumOfPrimes(i64 %0, i64 %1) {
%3 = icmp ult i64 %0, %1
br i1 %3, label %6, label %4
4: ; preds = %14, %2
%5 = phi i64 [ 0, %2 ], [ %15, %14 ]
ret i64 %5
6: ; preds = %2, %14
%7 = phi i64 [ %16, %14 ], [ %0, %2 ]
%8 = phi i64 [ %15, %14 ], [ 0, %2 ]
%9 = tail call i64 @checkIfPrime(i64 %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = add i64 %7, %8
%13 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %7, i64 %12)
br label %14
14: ; preds = %6, %11
%15 = phi i64 [ %12, %11 ], [ %8, %6 ]
%16 = add i64 %7, 1
%17 = icmp eq i64 %16, %1
br i1 %17, label %4, label %6
}