#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 /*<<< orphan*/ printf(char *, ...);
scalar_t__ str_a_entero(char *);
scalar_t__ validarCadena(char *);
int main(int argc, char **argv) {
  if (argc <= 1) {
    printf("Error\n");
    return 2;
  }
  int i = 0;
  int total = 0;
  for (i = 1; i < argc; i++) {
    if (validarCadena(argv[i])) {
      total += str_a_entero(argv[i]);
    }
  }
  printf("%d\n", total);
  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)
cmpl   $0x1,-0x8(%rbp)
jg     116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    11ef <main+0xbf>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d7 <main+0xa7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <validarCadena@plt>
cmp    $0x0,%rax
je     11c4 <main+0x94>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <str_a_entero@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
jmp    11c9 <main+0x99>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x4f>
mov    -0x18(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    115f <main+0x1f>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebx
jmp    11a8 <main+0x68>
mov    %rsi,%rbx
mov    %edi,%r14d
xor    %r15d,%r15d
mov    $0x1,%ebp
jmp    1179 <main+0x39>
nop
add    $0x1,%rbp
cmp    %rbp,%r14
je     1195 <main+0x55>
mov    (%rbx,%rbp,8),%rdi
call   1050 <validarCadena@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    (%rbx,%rbp,8),%rdi
call   1060 <str_a_entero@plt>
add    %eax,%r15d
jmp    1170 <main+0x30>
lea    0xe64(%rip),%rdi
xor    %ebx,%ebx
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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