#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  printf("I wanna know the argv[ 0 ], it is: %s\n", argv[0]);
  if (argc < 2) {
    printf("No inputs\n");
  } else {
    int sum = 0, i;
    for (i = 1; i <= argc; i++) {
      sum += atoi(argv[i]);
    }
    printf("the sum is: %d\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1168 <main+0x48>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bf <main+0x9f>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ae <main+0x8e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atoi@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1176 <main+0x56>
mov    -0x14(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
mov    (%rsi),%rsi
lea    0xeb9(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r15d
jge    1164 <main+0x34>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
jmp    1194 <main+0x64>
add    $0x1,%r15d
mov    $0x1,%ebx
nopl   (%rax)
mov    (%r14,%rbx,8),%rdi
call   1050 <atoi@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <main+0x40>
lea    0xe9c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"I wanna know the argv[ 0 ], it is: %s\0A\00"
@.str.1 = [11 x i8] c"No inputs\0A\00"
@.str.2 = [16 x i8] c"the sum 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %38
16: ; preds = %2
store i32 0, i32* %6
store i32 1, i32* %7
br label %17
17: ; preds = %32, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %4
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @atoi(i8* %26)
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = add nsw i64 %29, %27
%31 = trunc i64 %30 to i32
store i32 %31, i32* %6
br label %32
32: ; preds = %21
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %17
35: ; preds = %17
%36 = load i32, i32* %6
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"I wanna know the argv[ 0 ], it is: %s\0A\00"
@.str.2 = [16 x i8] c"the sum is: %d\0A\00"
@str = [10 x i8] c"No inputs\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = icmp slt i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = add nuw i32 %0, 1
%8 = zext i32 %7 to i64
br label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %23
11: ; preds = %6, %11
%12 = phi i64 [ 1, %6 ], [ %19, %11 ]
%13 = phi i32 [ 0, %6 ], [ %18, %11 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %12
%15 = load i8*, i8** %14
%16 = tail call i64 @atoi(i8* %15)
%17 = trunc i64 %16 to i32
%18 = add i32 %13, %17
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %21, label %11
21: ; preds = %11
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %23
23: ; preds = %21, %9
ret i32 0
}