#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 main() {
  int i, j, k;
  int sum = 1;
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 10000; j++) {
      for (k = 0; k < 10000; k++) {
        sum = -sum;
      }
    }
  }
  printf("Sum is %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jge    119e <main+0x8e>
movl   $0x0,-0xc(%rbp)
cmpl   $0x2710,-0xc(%rbp)
jge    118b <main+0x7b>
movl   $0x0,-0x10(%rbp)
cmpl   $0x2710,-0x10(%rbp)
jge    1178 <main+0x68>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1155 <main+0x45>
jmp    117d <main+0x6d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1141 <main+0x31>
jmp    1190 <main+0x80>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112d <main+0x1d>
mov    -0x14(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %r8d,%r8d
mov    $0x1,%esi
mov    $0xffffffff,%eax
nopl   (%rax)
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2710,%edi
mov    %eax,%ecx
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
mov    %ecx,%esi
mov    %eax,%ecx
add    $0xffffffe7,%edi
jne    1140 <main+0x30>
add    $0x1,%edx
cmp    $0x2710,%edx
jne    1130 <main+0x20>
add    $0x1,%r8d
cmp    $0x2710,%r8d
jne    1120 <main+0x10>
push   %rax
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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