#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_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ atoi(char *);
scalar_t__ checkarg(char *);
int filekey(int /*<<< orphan*/, char *);
int /*<<< orphan*/ makekey(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int ret = EXIT_SUCCESS;
  if (argc != 2 && argc != 3) {
    printf("Uso: %s numero_de_bytes\n", argv[0]);
  } else {
    if ((strcmp(argv[1], "--help")) == 0) {
      printf("RandomKey %s\n", "0.3");
      printf("Uso: %s numero_de_bytes\n", argv[0]);
      printf("Uso: %s numero_de_bytes archivo.txt\n", argv[0]);
      printf("Contacto: dalmemail@amaya.tk\n");
    } else {
      if (checkarg(argv[1]) < 0) {
        printf("%s error: %s no es valido\n", argv[0], argv[1]);
        ret = EXIT_FAILURE;
      } else {
        if (argv[2]) {
          ret = filekey(atoi(argv[1]), argv[2]);
        } else {
          makekey(atoi(argv[1]));
        }
      }
    }
  }
  return ret;
}


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    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b0 <main+0x50>
cmpl   $0x3,-0x8(%rbp)
je     11b0 <main+0x50>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bb <main+0x15b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1220 <main+0xc0>
lea    0xe4b(%rip),%rdi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b6 <main+0x156>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <checkarg@plt>
cmp    $0x0,%rax
jge    1265 <main+0x105>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    12b1 <main+0x151>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1298 <main+0x138>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1080 <filekey@plt>
mov    %eax,-0x14(%rbp)
jmp    12ac <main+0x14c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1040 <makekey@plt>
jmp    12b1 <main+0x151>
jmp    12b6 <main+0x156>
jmp    12bb <main+0x15b>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2e5b(%rip),%rax
mov    (%rax),%ebp
and    $0xfffffffe,%edi
cmp    $0x2,%edi
jne    11d0 <main+0x60>
mov    0x8(%rbx),%rdi
lea    0xe87(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11e3 <main+0x73>
mov    0x8(%rbx),%rdi
call   1060 <checkarg@plt>
test   %rax,%rax
js     1228 <main+0xb8>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rbx
call   1080 <atoi@plt>
mov    %eax,%edi
test   %rbx,%rbx
je     1248 <main+0xd8>
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <filekey@plt>
mov    (%rbx),%rsi
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    124d <main+0xdd>
lea    0xe36(%rip),%rdi
lea    0xe3d(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
lea    0xdfe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
jmp    124d <main+0xdd>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%ebp
jmp    124d <main+0xdd>
call   1050 <makekey@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@.str = [25 x i8] c"Uso: %s numero_de_bytes\0A\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [14 x i8] c"RandomKey %s\0A\00"
@.str.3 = [4 x i8] c"0.3\00"
@.str.4 = [37 x i8] c"Uso: %s numero_de_bytes archivo.txt\0A\00"
@.str.5 = [30 x i8] c"Contacto: dalmemail@amaya.tk\0A\00"
@.str.6 = [27 x i8] c"%s error: %s no es valido\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @EXIT_SUCCESS
store i32 %7, i32* %6
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %73
18: ; preds = %10, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %35
24: ; preds = %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %72
35: ; preds = %18
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i64 @checkarg(i8* %38)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %50
41: ; preds = %35
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %44, i8* %47)
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %6
br label %71
50: ; preds = %35
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %64
55: ; preds = %50
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 @atoi(i8* %58)
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = call i32 @filekey(i32 %59, i8* %62)
store i32 %63, i32* %6
br label %70
64: ; preds = %50
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i32 @atoi(i8* %67)
%69 = call i32 @makekey(i32 %68)
br label %70
70: ; preds = %64, %55
br label %71
71: ; preds = %70, %41
br label %72
72: ; preds = %71, %24
br label %73
73: ; preds = %72, %13
%74 = load i32, i32* %6
ret i32 %74
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@.str = [25 x i8] c"Uso: %s numero_de_bytes\0A\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [14 x i8] c"RandomKey %s\0A\00"
@.str.3 = [4 x i8] c"0.3\00"
@.str.4 = [37 x i8] c"Uso: %s numero_de_bytes archivo.txt\0A\00"
@.str.6 = [27 x i8] c"%s error: %s no es valido\0A\00"
@EXIT_FAILURE = global i32 0
@str = [29 x i8] c"Contacto: dalmemail@amaya.tk\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @EXIT_SUCCESS
%4 = and i32 %0, -2
%5 = icmp eq i32 %4, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %40
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%16 = load i8*, i8** %1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %1
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %40
21: ; preds = %9
%22 = load i8*, i8** %10
%23 = tail call i64 @checkarg(i8* %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %1
%27 = load i8*, i8** %10
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %26, i8* %27)
%29 = load i32, i32* @EXIT_FAILURE
br label %40
30: ; preds = %21
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = icmp eq i8* %32, null
%34 = load i8*, i8** %10
%35 = tail call i32 @atoi(i8* %34)
br i1 %33, label %38, label %36
36: ; preds = %30
%37 = tail call i32 @filekey(i32 %35, i8* %32)
br label %40
38: ; preds = %30
%39 = tail call i32 @makekey(i32 %35)
br label %40
40: ; preds = %14, %36, %38, %25, %6
%41 = phi i32 [ %3, %6 ], [ %3, %14 ], [ %29, %25 ], [ %37, %36 ], [ %3, %38 ]
ret i32 %41
}