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

/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ RSA_F4;
int /*<<< orphan*/ *RSA_generate_key(int, int /*<<< orphan*/,
                                     int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ debug(char *, int, int);
int /*<<< orphan*/ plog(int /*<<< orphan*/, char *);
RSA *tmp_rsa_cb(SSL *ssl, int export, int key_len) {
  static RSA *rsa = NULL;
  debug("Generating new RSA key.. (ex=%d, kl=%d)", export, key_len);
  if (export) {
    rsa = RSA_generate_key(key_len, RSA_F4, NULL, NULL);
  } else {
    plog(LOG_ERR, "ERROR tmp_rsa_callback(): Export not set");
  }
  return rsa;
}


x86 assembly (clang, -O0):
<tmp_rsa_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xeb1(%rip),%rdi
call   1040 <debug@plt>
cmpl   $0x0,-0xc(%rbp)
je     1182 <tmp_rsa_cb+0x52>
mov    -0x10(%rbp),%edi
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <RSA_generate_key@plt>
mov    %rax,0x2ec3(%rip)
jmp    1197 <tmp_rsa_cb+0x67>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1030 <plog@plt>
mov    0x2ea2(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tmp_rsa_cb>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
lea    0xec2(%rip),%rdi
call   1040 <debug@plt>
test   %ebp,%ebp
je     1164 <tmp_rsa_cb+0x34>
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <RSA_generate_key@plt>
mov    %rax,0x2ede(%rip)
jmp    1180 <tmp_rsa_cb+0x50>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
call   1030 <plog@plt>
mov    0x2ec0(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@tmp_rsa_cb.rsa = internal global i32* null
@.str = [40 x i8] c"Generating new RSA key.. (ex=%d, kl=%d)\00"
@RSA_F4 = global i32 0
@LOG_ERR = global i32 0
@.str.1 = [41 x i8] c"ERROR tmp_rsa_callback(): Export not set\00"
define i32* @tmp_rsa_cb(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = load i32, i32* %6
%9 = call i32 @debug(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* %6
%14 = load i32, i32* @RSA_F4
%15 = call i32* @RSA_generate_key(i32 %13, i32 %14, i32* null, i32* null)
store i32* %15, i32** @tmp_rsa_cb.rsa
br label %19
16: ; preds = %3
%17 = load i32, i32* @LOG_ERR
%18 = call i32 @plog(i32 %17, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %16, %12
%20 = load i32*, i32** @tmp_rsa_cb.rsa
ret i32* %20
}

LLVM IR (-O2):
@tmp_rsa_cb.rsa = internal unnamed_addr global i32* null
@.str = [40 x i8] c"Generating new RSA key.. (ex=%d, kl=%d)\00"
@RSA_F4 = global i32 0
@LOG_ERR = global i32 0
@.str.1 = [41 x i8] c"ERROR tmp_rsa_callback(): Export not set\00"
define i32* @tmp_rsa_cb(i32* nocapture readnone %0, i32 %1, i32 %2) {
%4 = tail call i32 @debug(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%5 = icmp eq i32 %1, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = load i32, i32* @RSA_F4
%8 = tail call i32* @RSA_generate_key(i32 %2, i32 %7, i32* null, i32* null)
store i32* %8, i32** @tmp_rsa_cb.rsa
br label %13
9: ; preds = %3
%10 = load i32, i32* @LOG_ERR
%11 = tail call i32 @plog(i32 %10, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32*, i32** @tmp_rsa_cb.rsa
br label %13
13: ; preds = %9, %6
%14 = phi i32* [ %12, %9 ], [ %8, %6 ]
ret i32* %14
}