#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*/ print_int(int);
int /*<<< orphan*/ print_string(char *);
void main(void) {
  int i, res;
  i = 0;
  res = 0;
  for (; i < 10; i = i + 1)
    res = res + i;
  for (i = 0; i < 10;) {
    res = res + i;
    i = i + 1;
  }
  for (i = 0;; i = i + 1) {
    res = res + i;
    if (i > 10) {
      print_int(res);
      print_string("\n");
      return;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    1157 <main+0x37>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1136 <main+0x16>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    117f <main+0x5f>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115e <main+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xa,-0x4(%rbp)
jle    11b3 <main+0x93>
mov    -0x8(%rbp),%edi
call   1040 <print_int@plt>
lea    0xe58(%rip),%rdi
call   1030 <print_string@plt>
add    $0x10,%rsp
pop    %rbp
ret
jmp    11b8 <main+0x98>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <main+0x66>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x9c,%edi
call   1040 <print_int@plt>
lea    0xece(%rip),%rdi
pop    %rax
jmp    1030 <print_string@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define void @main() {
%1 = tail call i32 @print_int(i32 156)
%2 = tail call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}