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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jg     118e <main+0x7e>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1161 <main+0x51>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113e <main+0x2e>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
mov    $0x2,%r15d
xor    %r12d,%r12d
lea    0xed3(%rip),%r14
nopl   (%rax)
mov    %r12,%rcx
shr    %rcx
add    %ebx,%ecx
lea    -0x1(%rbx),%esi
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
add    $0x1,%ebx
add    %r15,%r12
add    $0x2,%r15
cmp    $0x65,%ebx
jne    1130 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"0+...+%d+%d=%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i33 [ 0, %0 ], [ %12, %1 ]
%3 = phi i33 [ 2, %0 ], [ %11, %1 ]
%4 = phi i32 [ 1, %0 ], [ %10, %1 ]
%5 = lshr exact i33 %2, 1
%6 = trunc i33 %5 to i32
%7 = add i32 %4, %6
%8 = add nsw i32 %4, -1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %4, i32 %7)
%10 = add nuw nsw i32 %4, 1
%11 = add nuw nsw i33 %3, 2
%12 = add i33 %2, %3
%13 = icmp eq i32 %10, 101
br i1 %13, label %14, label %1
14: ; preds = %1
ret i32 0
}