#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, long long);
int sscanf(char const *, char *, long long *);
int /*<<< orphan*/ stderr;
int main(const int argc, const char *argv[]) {
  long long int sum = 0;
  long long int num = 0;
  int isValid = 1;
  for (int i = 1; i < argc; ++i) {
    if (sscanf(argv[i], " %lld", &num) != 1) {
      fprintf(stderr, "Input error. One of the arguments "
                      "is not a valid integer.\n");
      isValid = 0;
      break;
    }
    sum += num;
  }
  if (isValid)
    printf("Total: %lld\n", sum);
  getchar();
  return EXIT_SUCCESS;
}


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)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e0 <main+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe6d(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     11c6 <main+0x86>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
jmp    11e0 <main+0xa0>
mov    -0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1174 <main+0x34>
cmpl   $0x0,-0x24(%rbp)
je     11fa <main+0xba>
mov    -0x18(%rbp),%rsi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
cmp    $0x2,%edi
jl     1193 <main+0x53>
mov    %rsi,%r14
mov    %edi,%r13d
mov    $0x1,%ebp
xor    %ebx,%ebx
lea    0xe94(%rip),%r15
mov    %rsp,%r12
nop
mov    (%r14,%rbp,8),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11a6 <main+0x66>
add    (%rsp),%rbx
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1170 <main+0x30>
jmp    1195 <main+0x55>
xor    %ebx,%ebx
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    11bb <main+0x7b>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" %lld\00"
@stderr = global i32 0
@.str.1 = [59 x i8] c"Input error. One of the arguments is not a valid integer.\0A\00"
@.str.2 = [13 x i8] c"Total: %lld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
store i64 0, i64* %7
store i32 1, i32* %8
store i32 1, i32* %9
br label %10
10: ; preds = %29, %2
%11 = load i32, i32* %9
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %7)
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
br label %32
25: ; preds = %14
%26 = load i64, i64* %7
%27 = load i64, i64* %6
%28 = add nsw i64 %27, %26
store i64 %28, i64* %6
br label %29
29: ; preds = %25
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %10
32: ; preds = %22, %10
%33 = load i32, i32* %8
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i64, i64* %6
%37 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %36)
br label %38
38: ; preds = %35, %32
%39 = call i32 (...) @getchar()
%40 = load i32, i32* @EXIT_SUCCESS
ret i32 %40
}

LLVM IR (-O2):
@.str = [6 x i8] c" %lld\00"
@stderr = global i32 0
@.str.1 = [59 x i8] c"Input error. One of the arguments is not a valid integer.\0A\00"
@.str.2 = [13 x i8] c"Total: %lld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %23
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %18
%9 = phi i64 [ 1, %6 ], [ %21, %18 ]
%10 = phi i64 [ 0, %6 ], [ %20, %18 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %9
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %3)
%14 = icmp eq i32 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
br label %26
18: ; preds = %8
%19 = load i64, i64* %3
%20 = add nsw i64 %19, %10
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %23, label %8
23: ; preds = %18, %2
%24 = phi i64 [ 0, %2 ], [ %20, %18 ]
%25 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %15, %23
%27 = call i32 (...) @getchar()
%28 = load i32, i32* @EXIT_SUCCESS
ret i32 %28
}