#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, properResult, testResult = 0, i;
  printf("Please only input non-negative integers: ");
  scanf(" %d", &n);
  for (i = 1; i <= n; i++) {
    testResult = testResult + i;
    printf("%d: %d. ", i, testResult);
  }
  printf("\ntestResult: %d\n", testResult);
  properResult = (n * (n + 1)) / 2;
  printf("properResult: %d\n", properResult);
  printf("testResult and properResult equal: %s\n",
         testResult == properResult ? "Yis" : "Nop");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1192 <main+0x72>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x3b>
mov    -0x10(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%edx
lea    0xead(%rip),%rsi
lea    0xea2(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1180 <main+0x60>
lea    0xed7(%rip),%r14
xor    %eax,%eax
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
add    $0x1,%ebp
add    %eax,%ebx
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
cmp    0xc(%rsp),%ebp
jl     1160 <main+0x40>
lea    0xeb0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
lea    0x1(%rax),%ecx
imul   %eax,%ecx
mov    %ecx,%ebp
shr    $0x1f,%ebp
add    %ecx,%ebp
sar    %ebp
lea    0xe9e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebp,%ebx
lea    0xec5(%rip),%rax
lea    0xec2(%rip),%rsi
cmove  %rax,%rsi
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Please only input non-negative integers: \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [9 x i8] c"%d: %d. \00"
@.str.3 = [17 x i8] c"\0AtestResult: %d\0A\00"
@.str.4 = [18 x i8] c"properResult: %d\0A\00"
@.str.5 = [39 x i8] c"testResult and properResult equal: %s\0A\00"
@.str.6 = [4 x i8] c"Yis\00"
@.str.7 = [4 x i8] c"Nop\00"
@EXIT_SUCCESS = global i32 0
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 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %5
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = add nsw i32 %13, %14
store i32 %15, i32* %4
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %12
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %8
22: ; preds = %8
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %2
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
%28 = mul nsw i32 %25, %27
%29 = sdiv i32 %28, 2
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %4
%33 = load i32, i32* %3
%34 = icmp eq i32 %32, %33
%35 = zext i1 %34 to i64
%36 = select i1 %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}

LLVM IR (-O2):
@.str = [42 x i8] c"Please only input non-negative integers: \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [9 x i8] c"%d: %d. \00"
@.str.3 = [17 x i8] c"\0AtestResult: %d\0A\00"
@.str.4 = [18 x i8] c"properResult: %d\0A\00"
@.str.5 = [39 x i8] c"testResult and properResult equal: %s\0A\00"
@.str.6 = [4 x i8] c"Yis\00"
@.str.7 = [4 x i8] c"Nop\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 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 %15, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %12, %7 ], [ 1, %0 ]
%9 = phi i32 [ %10, %7 ], [ 0, %0 ]
%10 = add nuw nsw i32 %8, %9
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %10)
%12 = add nuw nsw i32 %8, 1
%13 = load i32, i32* %1
%14 = icmp slt i32 %8, %13
br i1 %14, label %7, label %15
15: ; preds = %7, %0
%16 = phi i32 [ 0, %0 ], [ %10, %7 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
%20 = mul nsw i32 %19, %18
%21 = sdiv i32 %20, 2
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = icmp eq i32 %16, %21
%24 = select i1 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}