#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 triangluar number do you want? ");
    scanf("%i", &number);
    triangularNumber = 0;
    n = 1;
    while (n <= number) {
      triangularNumber += n;
      n++;
    }
    printf("Triangular number %i is %i\n", number, triangularNumber);
    counter++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jg     11b1 <main+0x91>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%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     118f <main+0x6f>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x4c>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
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 triangluar number do you want? \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [28 x i8] c"Triangular number %i is %i\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 = icmp sle i32 %7, 5
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%11 = 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 %12
12: ; preds = %16, %9
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = add nsw i32 %18, %17
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %12
22: ; preds = %12
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24)
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %6
28: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"What triangluar number do you want? \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [28 x i8] c"Triangular number %i is %i\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 ([28 x i8], [28 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 ([28 x i8], [28 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 ([28 x i8], [28 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 ([28 x i8], [28 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 ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %77, i32 %91)
ret i32 0
}