#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int sum1(int, int *);
int sum2(int);
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("<usage> Please input %s number\n", argv[0]);
  }
  int number = atoi(argv[1]);
  int iSum1 = 0;
  int iSum2 = 0;
  printf("The sum1 of 1 to %d is %d \n", number, sum1(number, &iSum1));
  printf("The sum2 of 1 to %d is %d \n", number, sum2(number));
  return 1;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     1175 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1040 <sum1@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <sum2@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
je     115e <main+0x1e>
mov    (%rbx),%rsi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %eax,%edi
call   1040 <sum1@plt>
lea    0xe9c(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
call   1050 <sum2@plt>
lea    0xe9f(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"<usage> Please input %s number\0A\00"
@.str.1 = [28 x i8] c"The sum1 of 1 to %d is %d \0A\00"
@.str.2 = [28 x i8] c"The sum2 of 1 to %d is %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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %11, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%21 = load i32, i32* %6
%22 = load i32, i32* %6
%23 = call i32 @sum1(i32 %22, i32* %7)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %23)
%25 = load i32, i32* %6
%26 = load i32, i32* %6
%27 = call i32 @sum2(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %27)
ret i32 1
}

LLVM IR (-O2):
@.str = [32 x i8] c"<usage> Please input %s number\0A\00"
@.str.1 = [28 x i8] c"The sum1 of 1 to %d is %d \0A\00"
@.str.2 = [28 x i8] c"The sum2 of 1 to %d is %d \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %5, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%13 = call i32 @sum1(i32 %11, i32* %3)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %13)
%15 = call i32 @sum2(i32 %11)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %15)
ret i32 1
}