#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *lee_certificado_alloc(char *, unsigned char **, int);
int /*<<< orphan*/ printf(char *, unsigned char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  unsigned char *cert = NULL;
  unsigned char *serial = NULL;
  if (argc < 2) {
    fprintf(stderr, "Error. Sintax:\n\t%s CERTIFICADO-DE-LLAVE-PUBLICA\n",
            argv[0]);
    return 1;
  }
  cert = lee_certificado_alloc(argv[1], &serial, 1);
  if (cert != NULL) {
    printf("Certificado de llave publica:\n%s\n", cert);
    free(cert);
  } else {
    fprintf(stderr, "No fue posible leer el certificado de llave publica.\n");
  }
  if (serial != NULL) {
    printf("Numero de serie del certificado de llave publica: %s.\n", serial);
    free(serial);
  } else {
    fprintf(stderr, "No fue posible leer el numero de serie del certificado de "
                    "llave publica.\n");
  }
  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)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119a <main+0x5a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123b <main+0xfb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1060 <lee_certificado_alloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11dd <main+0x9d>
mov    -0x18(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    11f4 <main+0xb4>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     121d <main+0xdd>
mov    -0x20(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    1234 <main+0xf4>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
cmp    $0x1,%edi
jg     1177 <main+0x37>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%ebx
jmp    11ff <main+0xbf>
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
mov    $0x1,%edx
call   1060 <lee_certificado_alloc@plt>
test   %rax,%rax
je     11ab <main+0x6b>
mov    %rax,%rbx
lea    0xe98(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11c2 <main+0x82>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     11e6 <main+0xa6>
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
jmp    11ff <main+0xbf>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    0xeca(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"Error. Sintax:\0A\09%s CERTIFICADO-DE-LLAVE-PUBLICA\0A\00"
@.str.1 = [34 x i8] c"Certificado de llave publica:\0A%s\0A\00"
@.str.2 = [54 x i8] c"No fue posible leer el certificado de llave publica.\0A\00"
@.str.3 = [55 x i8] c"Numero de serie del certificado de llave publica: %s.\0A\00"
@.str.4 = [74 x i8] c"No fue posible leer el numero de serie del certificado de llave publica.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %43
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i8* @lee_certificado_alloc(i8* %19, i8** %7, i32 1)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load i8*, i8** %6
%25 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %6
%27 = call i32 @free(i8* %26)
br label %31
28: ; preds = %16
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %28, %23
%32 = load i8*, i8** %7
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i8*, i8** %7
%36 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%37 = load i8*, i8** %7
%38 = call i32 @free(i8* %37)
br label %42
39: ; preds = %31
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %39, %34
store i32 0, i32* %3
br label %43
43: ; preds = %42, %10
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"Error. Sintax:\0A\09%s CERTIFICADO-DE-LLAVE-PUBLICA\0A\00"
@.str.1 = [34 x i8] c"Certificado de llave publica:\0A%s\0A\00"
@.str.2 = [54 x i8] c"No fue posible leer el certificado de llave publica.\0A\00"
@.str.3 = [55 x i8] c"Numero de serie del certificado de llave publica: %s.\0A\00"
@.str.4 = [74 x i8] c"No fue posible leer el numero de serie del certificado de llave publica.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %31
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i8* @lee_certificado_alloc(i8* %12, i8** %3, i32 1)
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%17 = call i32 @free(i8* %13)
br label %21
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %18, %15
%22 = load i8*, i8** %3
%23 = icmp eq i8* %22, null
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%26 = load i8*, i8** %3
%27 = call i32 @free(i8* %26)
br label %31
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %24, %28, %6
%32 = phi i32 [ 1, %6 ], [ 0, %28 ], [ 0, %24 ]
ret i32 %32
}