#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*/ FILE;

/* Variables and functions */
void *dsa_load_keys(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char **);
void *crypto_load_key_pair(FILE *pub_key, FILE *priv_key, int algo,
                           char **err) {
  if ((algo != 2) && (algo != 3)) {
    *err = "Unknown key algo";
    return NULL;
  }
  if (algo == 2)
    return dsa_load_keys(pub_key, priv_key, err);
  else {
    *err = "RSA key supported not implemented";
    return NULL;
  }
}


x86 assembly (clang, -O0):
<crypto_load_key_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpl   $0x2,-0x1c(%rbp)
je     1156 <crypto_load_key_pair+0x46>
cmpl   $0x3,-0x1c(%rbp)
je     1156 <crypto_load_key_pair+0x46>
mov    -0x28(%rbp),%rax
lea    0xeba(%rip),%rcx
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1190 <crypto_load_key_pair+0x80>
cmpl   $0x2,-0x1c(%rbp)
jne    117a <crypto_load_key_pair+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <dsa_load_keys@plt>
mov    %rax,-0x8(%rbp)
jmp    1190 <crypto_load_key_pair+0x80>
mov    -0x28(%rbp),%rax
lea    0xe8c(%rip),%rcx
mov    %rcx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypto_load_key_pair>:
mov    %edx,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    1127 <crypto_load_key_pair+0x17>
cmp    $0x2,%edx
jne    1130 <crypto_load_key_pair+0x20>
mov    %rcx,%rdx
jmp    1030 <dsa_load_keys@plt>
lea    0xed2(%rip),%rax
jmp    1137 <crypto_load_key_pair+0x27>
lea    0xeda(%rip),%rax
mov    %rax,(%rcx)
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Unknown key algo\00"
@.str.1 = [34 x i8] c"RSA key supported not implemented\00"
define i8* @crypto_load_key_pair(i32* %0, i32* %1, i32 %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8**
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
%10 = load i32, i32* %8
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i8**, i8*** %9
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %16
store i8* null, i8** %5
br label %27
17: ; preds = %12, %4
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32*, i32** %6
%22 = load i32*, i32** %7
%23 = load i8**, i8*** %9
%24 = call i8* @dsa_load_keys(i32* %21, i32* %22, i8** %23)
store i8* %24, i8** %5
br label %27
25: ; preds = %17
%26 = load i8**, i8*** %9
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8** %26
store i8* null, i8** %5
br label %27
27: ; preds = %25, %20, %15
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
@.str = [17 x i8] c"Unknown key algo\00"
@.str.1 = [34 x i8] c"RSA key supported not implemented\00"
define i8* @crypto_load_key_pair(i32* %0, i32* %1, i32 %2, i8** %3) {
%5 = and i32 %2, -2
%6 = icmp eq i32 %5, 2
br i1 %6, label %8, label %7
7: ; preds = %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %3
br label %13
8: ; preds = %4
%9 = icmp eq i32 %2, 2
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i8* @dsa_load_keys(i32* %0, i32* %1, i8** %3)
br label %13
12: ; preds = %8
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %13
13: ; preds = %12, %10, %7
%14 = phi i8* [ null, %7 ], [ %11, %10 ], [ null, %12 ]
ret i8* %14
}