#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, number, triangularNumber, counter;
  counter = 1;
  while (counter++ <= 5) {
    printf("What triangular number do you want? ");
    scanf("%i", &number);
    triangularNumber = 0;
    n = 1;
    while (n <= number)
      triangularNumber += n++;
    printf("Triangular number %i is %i\n\n", number, triangularNumber);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x5,%eax
jg     11b1 <main+0x91>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1198 <main+0x78>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1176 <main+0x56>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x0,%edx
test   %esi,%esi
jle    1164 <main+0x44>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
shr    %rcx
lea    (%rcx,%rsi,2),%edx
add    $0xffffffff,%edx
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11ac <main+0x8c>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
shr    %rcx
lea    (%rcx,%rsi,2),%ebp
add    $0xffffffff,%ebp
lea    0xe75(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe52(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x0,%edx
test   %esi,%esi
jle    11fd <main+0xdd>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
shr    %rcx
lea    (%rcx,%rsi,2),%edx
add    $0xffffffff,%edx
lea    0xe24(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdee(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe05(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1245 <main+0x125>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
shr    %rcx
lea    (%rcx,%rsi,2),%ebx
add    $0xffffffff,%ebx
lea    0xddc(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xda2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdb9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1291 <main+0x171>
lea    -0x1(%rsi),%eax
lea    -0x2(%rsi),%ecx
imul   %rax,%rcx
shr    %rcx
lea    (%rcx,%rsi,2),%ebp
add    $0xffffffff,%ebp
lea    0xd90(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"What triangular number do you want? \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [29 x i8] c"Triangular number %i is %i\0A\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
br label %6
6: ; preds = %22, %0
%7 = load i32, i32* %5
%8 = add nsw i32 %7, 1
store i32 %8, i32* %5
%9 = icmp sle i32 %7, 5
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
store i32 1, i32* %2
br label %13
13: ; preds = %17, %10
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %18
store i32 %21, i32* %4
br label %13
22: ; preds = %13
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24)
br label %6
26: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"What triangular number do you want? \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [29 x i8] c"Triangular number %i is %i\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %18, label %7
7: ; preds = %0
%8 = shl nuw i32 %5, 1
%9 = add nsw i32 %5, -1
%10 = zext i32 %9 to i33
%11 = add nsw i32 %5, -2
%12 = zext i32 %11 to i33
%13 = mul i33 %10, %12
%14 = lshr i33 %13, 1
%15 = trunc i33 %14 to i32
%16 = add i32 %8, -1
%17 = add i32 %16, %15
br label %18
18: ; preds = %7, %0
%19 = phi i32 [ 0, %0 ], [ %17, %7 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%23 = load i32, i32* %1
%24 = icmp slt i32 %23, 1
br i1 %24, label %36, label %25
25: ; preds = %18
%26 = shl nuw i32 %23, 1
%27 = add nsw i32 %23, -1
%28 = zext i32 %27 to i33
%29 = add nsw i32 %23, -2
%30 = zext i32 %29 to i33
%31 = mul i33 %28, %30
%32 = lshr i33 %31, 1
%33 = trunc i33 %32 to i32
%34 = add i32 %26, -1
%35 = add i32 %34, %33
br label %36
36: ; preds = %25, %18
%37 = phi i32 [ 0, %18 ], [ %35, %25 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%41 = load i32, i32* %1
%42 = icmp slt i32 %41, 1
br i1 %42, label %54, label %43
43: ; preds = %36
%44 = shl nuw i32 %41, 1
%45 = add nsw i32 %41, -1
%46 = zext i32 %45 to i33
%47 = add nsw i32 %41, -2
%48 = zext i32 %47 to i33
%49 = mul i33 %46, %48
%50 = lshr i33 %49, 1
%51 = trunc i33 %50 to i32
%52 = add i32 %44, -1
%53 = add i32 %52, %51
br label %54
54: ; preds = %43, %36
%55 = phi i32 [ 0, %36 ], [ %53, %43 ]
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%58 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%59 = load i32, i32* %1
%60 = icmp slt i32 %59, 1
br i1 %60, label %72, label %61
61: ; preds = %54
%62 = shl nuw i32 %59, 1
%63 = add nsw i32 %59, -1
%64 = zext i32 %63 to i33
%65 = add nsw i32 %59, -2
%66 = zext i32 %65 to i33
%67 = mul i33 %64, %66
%68 = lshr i33 %67, 1
%69 = trunc i33 %68 to i32
%70 = add i32 %62, -1
%71 = add i32 %70, %69
br label %72
72: ; preds = %61, %54
%73 = phi i32 [ 0, %54 ], [ %71, %61 ]
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %59, i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%77 = load i32, i32* %1
%78 = icmp slt i32 %77, 1
br i1 %78, label %90, label %79
79: ; preds = %72
%80 = shl nuw i32 %77, 1
%81 = add nsw i32 %77, -1
%82 = zext i32 %81 to i33
%83 = add nsw i32 %77, -2
%84 = zext i32 %83 to i33
%85 = mul i33 %82, %84
%86 = lshr i33 %85, 1
%87 = trunc i33 %86 to i32
%88 = add i32 %80, -1
%89 = add i32 %88, %87
br label %90
90: ; preds = %79, %72
%91 = phi i32 [ 0, %72 ], [ %89, %79 ]
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %77, i32 %91)
ret i32 0
}