#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 argc, const char *argv[]) {
  int i = 0;
  int sum = 0;
  while (i <= 100) {
    sum = sum + i;
    i++;
  }
  printf("1+2+3+4+...+100=%d \n", sum);
  int i2 = 0;
  int sum2 = 0;
  do {
    sum2 = sum2 + i2;
    i2++;
  } while (i2 <= 100);
  printf("1+2+3+4+...+100=%d \n", sum2);
  int i3 = 0;
  int sum3 = 0;
  for (i3 = 0; i3 <= 100; i3++) {
    sum3 += i3;
  }
  printf("1+2+3+4+...+100=%d \n", sum3);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x14(%rbp)
jg     1155 <main+0x45>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <main+0x24>
mov    -0x18(%rbp),%esi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jle    1172 <main+0x62>
mov    -0x20(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jg     11d3 <main+0xc3>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b2 <main+0xa2>
mov    -0x28(%rbp),%esi
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x13ba,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x13ba,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x13ba,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"1+2+3+4+...+100=%d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %15, %2
%13 = load i32, i32* %6
%14 = icmp sle i32 %13, 100
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = add nsw i32 %16, %17
store i32 %18, i32* %7
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %12
21: ; preds = %12
%22 = load i32, i32* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %22)
store i32 0, i32* %8
store i32 0, i32* %9
br label %24
24: ; preds = %30, %21
%25 = load i32, i32* %9
%26 = load i32, i32* %8
%27 = add nsw i32 %25, %26
store i32 %27, i32* %9
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %30
30: ; preds = %24
%31 = load i32, i32* %8
%32 = icmp sle i32 %31, 100
br i1 %32, label %24, label %33
33: ; preds = %30
%34 = load i32, i32* %9
%35 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %34)
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %10
br label %36
36: ; preds = %43, %33
%37 = load i32, i32* %10
%38 = icmp sle i32 %37, 100
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32, i32* %10
%41 = load i32, i32* %11
%42 = add nsw i32 %41, %40
store i32 %42, i32* %11
br label %43
43: ; preds = %39
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %36
46: ; preds = %36
%47 = load i32, i32* %11
%48 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [21 x i8] c"1+2+3+4+...+100=%d \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 5050)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 5050)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 5050)
ret i32 0
}