#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 *, char *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ printf(char *, char *, unsigned char *);
unsigned char *sello_alloc(char *, char *, unsigned char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  unsigned char *seal = NULL;
  if (argc < 3) {
    fprintf(stderr, "Error. Sintax\n\t%s KEYCERT CADENA\n", argv[0]);
    return 1;
  }
  seal = sello_alloc(argv[1], "sha1", (unsigned char *)argv[2], 1);
  if (seal == NULL) {
    fprintf(stderr, "No fue posible crear el sello digital de la cadena %s.\n",
            argv[2]);
  } else {
    printf("Sello digital de %s:\n\n%s\n", argv[2], seal);
    free(seal);
  }
  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)
cmpl   $0x3,-0x8(%rbp)
jge    1190 <main+0x50>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120a <main+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe7b(%rip),%rsi
mov    $0x1,%ecx
call   1060 <sello_alloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e2 <main+0xa2>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe4f(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1203 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     116b <main+0x2b>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xea1(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11c4 <main+0x84>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rdx
lea    0xea8(%rip),%rsi
mov    $0x1,%ecx
call   1060 <sello_alloc@plt>
test   %rax,%rax
je     11a9 <main+0x69>
mov    %rax,%r14
mov    0x10(%rbx),%rsi
lea    0xec8(%rip),%rdi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    11c2 <main+0x82>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe6a(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Error. Sintax\0A\09%s KEYCERT CADENA\0A\00"
@.str.1 = [5 x i8] c"sha1\00"
@.str.2 = [56 x i8] c"No fue posible crear el sello digital de la cadena %s.\0A\00"
@.str.3 = [26 x i8] c"Sello digital de %s:\0A\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %40
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i8* @sello_alloc(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 1)
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %31
25: ; preds = %15
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %39
31: ; preds = %15
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = load i8*, i8** %6
%36 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %34, i8* %35)
%37 = load i8*, i8** %6
%38 = call i32 @free(i8* %37)
br label %39
39: ; preds = %31, %25
store i32 0, i32* %3
br label %40
40: ; preds = %39, %9
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Error. Sintax\0A\09%s KEYCERT CADENA\0A\00"
@.str.1 = [5 x i8] c"sha1\00"
@.str.2 = [56 x i8] c"No fue posible crear el sello digital de la cadena %s.\0A\00"
@.str.3 = [26 x i8] c"Sello digital de %s:\0A\0A%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %23
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i8* @sello_alloc(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 1)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %11
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %23
19: ; preds = %8
%20 = load i8*, i8** %11
%21 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* %13)
%22 = tail call i32 @free(i8* %13)
br label %23
23: ; preds = %15, %19, %4
%24 = phi i32 [ 1, %4 ], [ 0, %19 ], [ 0, %15 ]
ret i32 %24
}