#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 */
typedef int /*<<< orphan*/ RSA;

/* Variables and functions */
int /*<<< orphan*/ RSA_NO_PADDING;
int /*<<< orphan*/ RSA_PKCS1_PADDING;
int RSA_private_decrypt(int, unsigned char *, unsigned char *,
                        int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *createRSAWithFilename(unsigned char *, int /*<<< orphan*/);
int private_decrypt(unsigned char *enc_data, int data_len,
                    unsigned char *filename, unsigned char *decrypted,
                    int pad) {
  RSA *rsa = createRSAWithFilename(filename, 0);
  int result;
  if (pad)
    result = RSA_private_decrypt(data_len, enc_data, decrypted, rsa,
                                 RSA_PKCS1_PADDING);
  else
    result =
        RSA_private_decrypt(data_len, enc_data, decrypted, rsa, RSA_NO_PADDING);
  return result;
}


x86 assembly (clang, -O0):
<private_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <createRSAWithFilename@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     117a <private_decrypt+0x5a>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x2e66(%rip),%rax
mov    (%rax),%r8d
call   1040 <RSA_private_decrypt@plt>
mov    %eax,-0x34(%rbp)
jmp    119b <private_decrypt+0x7b>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x2e58(%rip),%rax
mov    (%rax),%r8d
call   1040 <RSA_private_decrypt@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<private_decrypt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %rcx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
mov    %rdx,%rdi
xor    %esi,%esi
call   1030 <createRSAWithFilename@plt>
test   %ebx,%ebx
jne    1149 <private_decrypt+0x29>
mov    0x2ea1(%rip),%rcx
jmp    1150 <private_decrypt+0x30>
mov    0x2e80(%rip),%rcx
mov    (%rcx),%r8d
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <RSA_private_decrypt@plt>

LLVM IR (-O0):
@RSA_PKCS1_PADDING = global i32 0
@RSA_NO_PADDING = global i32 0
define i32 @private_decrypt(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = load i8*, i8** %8
%14 = call i32* @createRSAWithFilename(i8* %13, i32 0)
store i32* %14, i32** %11
%15 = load i32, i32* %10
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %5
%18 = load i32, i32* %7
%19 = load i8*, i8** %6
%20 = load i8*, i8** %9
%21 = load i32*, i32** %11
%22 = load i32, i32* @RSA_PKCS1_PADDING
%23 = call i32 @RSA_private_decrypt(i32 %18, i8* %19, i8* %20, i32* %21, i32 %22)
store i32 %23, i32* %12
br label %31
24: ; preds = %5
%25 = load i32, i32* %7
%26 = load i8*, i8** %6
%27 = load i8*, i8** %9
%28 = load i32*, i32** %11
%29 = load i32, i32* @RSA_NO_PADDING
%30 = call i32 @RSA_private_decrypt(i32 %25, i8* %26, i8* %27, i32* %28, i32 %29)
store i32 %30, i32* %12
br label %31
31: ; preds = %24, %17
%32 = load i32, i32* %12
ret i32 %32
}

LLVM IR (-O2):
@RSA_PKCS1_PADDING = global i32 0
@RSA_NO_PADDING = global i32 0
define i32 @private_decrypt(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = tail call i32* @createRSAWithFilename(i8* %2, i32 0)
%7 = icmp eq i32 %4, 0
%8 = load i32, i32* @RSA_NO_PADDING
%9 = load i32, i32* @RSA_PKCS1_PADDING
%10 = select i1 %7, i32 %8, i32 %9
%11 = tail call i32 @RSA_private_decrypt(i32 %1, i8* %0, i8* %3, i32* %6, i32 %10)
ret i32 %11
}