#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__ is_prime(int);
int /*<<< orphan*/ printf(char *, int, int const, int const);
int main() {
  const int start = 1;
  const int stop = 1000;
  int sum = 0;
  int count = 0;
  int sc = 0;
  int p;
  for (p = start; p < stop; p++) {
    if (is_prime(p)) {
      count++;
      sum += p;
      if (is_prime(sum)) {
        printf("The sum of %3d primes in [2, %3d] is %5d which is also prime\n",
               count, p, sum);
        sc++;
      }
    }
  }
  printf("There are %d summerized primes in [%d, %d)\n", sc, start, stop);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x3e8,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    11d2 <main+0xb2>
mov    -0x1c(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     11bf <main+0x9f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     11ba <main+0x9a>
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bf <main+0x9f>
jmp    11c4 <main+0xa4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <main+0x39>
mov    -0x18(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x1,%edx
mov    $0x3e8,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r15d,%r15d
mov    $0x1,%ebp
lea    0xec9(%rip),%r14
xor    %r12d,%r12d
xor    %ebx,%ebx
jmp    114b <main+0x2b>
xchg   %ax,%ax
add    $0x1,%ebp
cmp    $0x3e8,%ebp
je     117e <main+0x5e>
mov    %ebp,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1140 <main+0x20>
add    $0x1,%r12d
add    %ebp,%ebx
mov    %ebx,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1140 <main+0x20>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
add    $0x1,%r15d
jmp    1140 <main+0x20>
lea    0xeb9(%rip),%rdi
mov    %r15d,%esi
mov    $0x1,%edx
mov    $0x3e8,%ecx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [62 x i8] c"The sum of %3d primes in [2, %3d] is %5d which is also prime\0A\00"
@.str.1 = [44 x i8] c"There are %d summerized primes in [%d, %d)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 1000, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %8
8: ; preds = %33, %0
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 1000
br i1 %10, label %11, label %36
11: ; preds = %8
%12 = load i32, i32* %7
%13 = call i64 @is_prime(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %32
15: ; preds = %11
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
%18 = load i32, i32* %7
%19 = load i32, i32* %4
%20 = add nsw i32 %19, %18
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i64 @is_prime(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %15
%25 = load i32, i32* %5
%26 = load i32, i32* %7
%27 = load i32, i32* %4
%28 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26, i32 %27)
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %31
31: ; preds = %24, %15
br label %32
32: ; preds = %31, %11
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %8
36: ; preds = %8
%37 = load i32, i32* %6
%38 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 1, i32 1000)
ret i32 0
}

LLVM IR (-O2):
@.str = [62 x i8] c"The sum of %3d primes in [2, %3d] is %5d which is also prime\0A\00"
@.str.1 = [44 x i8] c"There are %d summerized primes in [%d, %d)\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %16
%2 = phi i32 [ 1, %0 ], [ %20, %16 ]
%3 = phi i32 [ 0, %0 ], [ %19, %16 ]
%4 = phi i32 [ 0, %0 ], [ %18, %16 ]
%5 = phi i32 [ 0, %0 ], [ %17, %16 ]
%6 = tail call i64 @is_prime(i32 %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %1
%9 = add nsw i32 %4, 1
%10 = add nsw i32 %2, %5
%11 = tail call i64 @is_prime(i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %2, i32 %10)
%15 = add nsw i32 %3, 1
br label %16
16: ; preds = %1, %13, %8
%17 = phi i32 [ %10, %13 ], [ %10, %8 ], [ %5, %1 ]
%18 = phi i32 [ %9, %13 ], [ %9, %8 ], [ %4, %1 ]
%19 = phi i32 [ %15, %13 ], [ %3, %8 ], [ %3, %1 ]
%20 = add nuw nsw i32 %2, 1
%21 = icmp eq i32 %20, 1000
br i1 %21, label %22, label %1
22: ; preds = %16
%23 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 1, i32 1000)
ret i32 0
}