#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*/ isdigit(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  int i, c, sum = 0;
  if (argc == 1) {
    puts("0");
    return (0);
  }
  while (--argc) {
    ++argv;
    for (i = 0; (c = *(*argv + i)); ++i) {
      if (!(isdigit(c))) {
        puts("Error");
        return (1);
      }
    }
    sum += atoi(*argv);
  }
  printf("%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)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    117f <main+0x3f>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1234 <main+0xf4>
jmp    1184 <main+0x44>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     121e <main+0xde>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
je     1200 <main+0xc0>
mov    -0x18(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11ed <main+0xad>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1234 <main+0xf4>
jmp    11f2 <main+0xb2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a9 <main+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <atoi@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    1184 <main+0x44>
mov    -0x1c(%rbp),%esi
lea    0xde0(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jne    1149 <main+0x19>
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    11a9 <main+0x79>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0xffffffff,%ebp
xor    %r14d,%r14d
jmp    1171 <main+0x41>
cs nopw 0x0(%rax,%rax,1)
add    $0x8,%rbx
call   1050 <atoi@plt>
add    %eax,%r14d
add    $0xffffffff,%ebp
je     11ae <main+0x7e>
mov    0x8(%rbx),%rdi
mov    (%rdi),%cl
test   %cl,%cl
je     1160 <main+0x30>
lea    0x1(%rdi),%rax
nop
movsbl %cl,%ecx
add    $0xffffffd0,%ecx
cmp    $0xa,%ecx
jae    1198 <main+0x68>
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1180 <main+0x50>
jmp    1160 <main+0x30>
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe53(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
jmp    1145 <main+0x15>

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [6 x i8] c"Error\00"
@.str.2 = [4 x i8] c"%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
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %51
13: ; preds = %2
br label %14
14: ; preds = %40, %13
%15 = load i32, i32* %4
%16 = add nsw i32 %15, -1
store i32 %16, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %48
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %5
store i32 0, i32* %6
br label %21
21: ; preds = %37, %18
%22 = load i8**, i8*** %5
%23 = load i8*, i8** %22
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
store i32 %28, i32* %7
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %21
%31 = load i32, i32* %7
%32 = call i32 @isdigit(i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %30
%35 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %51
36: ; preds = %30
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %21
40: ; preds = %21
%41 = load i8**, i8*** %5
%42 = load i8*, i8** %41
%43 = call i64 @atoi(i8* %42)
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = add nsw i64 %45, %43
%47 = trunc i64 %46 to i32
store i32 %47, i32* %8
br label %14
48: ; preds = %14
%49 = load i32, i32* %8
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %49)
store i32 0, i32* %3
br label %51
51: ; preds = %48, %34, %11
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
@.str.1 = [6 x i8] c"Error\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = add nsw i32 %0, -1
br label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %37
8: ; preds = %4, %29
%9 = phi i32 [ %33, %29 ], [ %5, %4 ]
%10 = phi i32 [ %32, %29 ], [ 0, %4 ]
%11 = phi i8** [ %12, %29 ], [ %1, %4 ]
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %29, label %20
16: ; preds = %20
%17 = getelementptr inbounds i8, i8* %13, i64 %26
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %8, %16
%21 = phi i64 [ %26, %16 ], [ 0, %8 ]
%22 = phi i8 [ %18, %16 ], [ %14, %8 ]
%23 = sext i8 %22 to i32
%24 = add nsw i32 %23, -48
%25 = icmp ult i32 %24, 10
%26 = add nuw i64 %21, 1
br i1 %25, label %16, label %27
27: ; preds = %20
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %37
29: ; preds = %16, %8
%30 = tail call i64 @atoi(i8* %13)
%31 = trunc i64 %30 to i32
%32 = add i32 %10, %31
%33 = add nsw i32 %9, -1
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %8
35: ; preds = %29
%36 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %37
37: ; preds = %35, %27, %6
%38 = phi i32 [ 0, %6 ], [ 1, %27 ], [ 0, %35 ]
ret i32 %38
}