#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 RSA2048_load(int, char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *);
int RSA2048_load_signature(int fd, unsigned char *text) {
  int ret;
  ret = RSA2048_load(fd, "BF50010080", text, 128);
  if (ret != 0) {
    printf("ERR:RSA2048_load_text_128 failed!\n");
    return 1;
  }
  ret = RSA2048_load(fd, "BF50018080", text + 128, 128);
  if (ret != 0) {
    printf("ERR:RSA2048_load_text_256 failed!\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<RSA2048_load_signature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rdx
lea    0xec3(%rip),%rsi
mov    $0x80,%ecx
call   1040 <RSA2048_load@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116c <RSA2048_load_signature+0x4c>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b7 <RSA2048_load_signature+0x97>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rdx
add    $0x80,%rdx
lea    0xead(%rip),%rsi
mov    $0x80,%ecx
call   1040 <RSA2048_load@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11b0 <RSA2048_load_signature+0x90>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b7 <RSA2048_load_signature+0x97>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RSA2048_load_signature>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed1(%rip),%rsi
mov    %rbx,%rdx
mov    $0x80,%ecx
call   1040 <RSA2048_load@plt>
test   %eax,%eax
je     1149 <RSA2048_load_signature+0x29>
lea    0xef1(%rip),%rdi
jmp    116e <RSA2048_load_signature+0x4e>
sub    $0xffffffffffffff80,%rbx
lea    0xeb7(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    $0x80,%ecx
call   1040 <RSA2048_load@plt>
test   %eax,%eax
je     117f <RSA2048_load_signature+0x5f>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
jmp    1178 <RSA2048_load_signature+0x58>

LLVM IR (-O0):
@.str = [11 x i8] c"BF50010080\00"
@.str.1 = [35 x i8] c"ERR:RSA2048_load_text_128 failed!\0A\00"
@.str.2 = [11 x i8] c"BF50018080\00"
@.str.3 = [35 x i8] c"ERR:RSA2048_load_text_256 failed!\0A\00"
define i32 @RSA2048_load_signature(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i32, i32* %4
%8 = load i8*, i8** %5
%9 = call i32 @RSA2048_load(i32 %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8, i32 128)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %24
14: ; preds = %2
%15 = load i32, i32* %4
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 128
%18 = call i32 @RSA2048_load(i32 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %17, i32 128)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %24
23: ; preds = %14
store i32 0, i32* %3
br label %24
24: ; preds = %23, %21, %12
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [11 x i8] c"BF50010080\00"
@.str.2 = [11 x i8] c"BF50018080\00"
@str = [34 x i8] c"ERR:RSA2048_load_text_256 failed!\00"
@str.4 = [34 x i8] c"ERR:RSA2048_load_text_128 failed!\00"
define i32 @RSA2048_load_signature(i32 %0, i8* %1) {
%3 = tail call i32 @RSA2048_load(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1, i32 128)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 128
%7 = tail call i32 @RSA2048_load(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %6, i32 128)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5, %2
%10 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @str.4, i64 0, i64 0), %2 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0), %5 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %9, %5
%13 = phi i32 [ 0, %5 ], [ 1, %9 ]
ret i32 %13
}