#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 */
void *aes_key_schedule(unsigned char *, int, unsigned char *, int);
void *crypto_setup_cipher_context(int cipher, unsigned char *key,
                                  unsigned char *iv, int mode) {
  switch (cipher) {
  case 10:
    return aes_key_schedule(key, 128, iv, mode);
  case 11:
    return aes_key_schedule(key, 192, iv, mode);
  case 12:
    return aes_key_schedule(key, 256, iv, mode);
  default:
    return NULL;
  }
}


x86 assembly (clang, -O0):
<crypto_setup_cipher_context>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0xa,%eax
je     115c <crypto_setup_cipher_context+0x4c>
jmp    113a <crypto_setup_cipher_context+0x2a>
mov    -0x28(%rbp),%eax
sub    $0xb,%eax
je     117a <crypto_setup_cipher_context+0x6a>
jmp    114b <crypto_setup_cipher_context+0x3b>
mov    -0x28(%rbp),%eax
sub    $0xc,%eax
je     1198 <crypto_setup_cipher_context+0x88>
jmp    11b6 <crypto_setup_cipher_context+0xa6>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x80,%esi
call   1030 <aes_key_schedule@plt>
mov    %rax,-0x8(%rbp)
jmp    11be <crypto_setup_cipher_context+0xae>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0xc0,%esi
call   1030 <aes_key_schedule@plt>
mov    %rax,-0x8(%rbp)
jmp    11be <crypto_setup_cipher_context+0xae>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x100,%esi
call   1030 <aes_key_schedule@plt>
mov    %rax,-0x8(%rbp)
jmp    11be <crypto_setup_cipher_context+0xae>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypto_setup_cipher_context>:
mov    %edi,%eax
add    $0xfffffff6,%eax
cmp    $0x2,%eax
ja     112a <crypto_setup_cipher_context+0x1a>
shl    $0x6,%eax
sub    $0xffffff80,%eax
mov    %rsi,%rdi
mov    %eax,%esi
jmp    1030 <aes_key_schedule@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i8* @crypto_setup_cipher_context(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%10 = load i32, i32* %6
switch i32 %10, label %26 [
i32 10, label %11
i32 11, label %16
i32 12, label %21
]
11: ; preds = %4
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = load i32, i32* %9
%15 = call i8* @aes_key_schedule(i8* %12, i32 128, i8* %13, i32 %14)
store i8* %15, i8** %5
br label %27
16: ; preds = %4
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = load i32, i32* %9
%20 = call i8* @aes_key_schedule(i8* %17, i32 192, i8* %18, i32 %19)
store i8* %20, i8** %5
br label %27
21: ; preds = %4
%22 = load i8*, i8** %7
%23 = load i8*, i8** %8
%24 = load i32, i32* %9
%25 = call i8* @aes_key_schedule(i8* %22, i32 256, i8* %23, i32 %24)
store i8* %25, i8** %5
br label %27
26: ; preds = %4
store i8* null, i8** %5
br label %27
27: ; preds = %26, %21, %16, %11
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
define i8* @crypto_setup_cipher_context(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = add i32 %0, -10
%6 = icmp ult i32 %5, 3
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = shl i32 %5, 6
%9 = add i32 %8, 128
%10 = tail call i8* @aes_key_schedule(i8* %1, i32 %9, i8* %2, i32 %3)
br label %11
11: ; preds = %4, %7
%12 = phi i8* [ null, %4 ], [ %10, %7 ]
ret i8* %12
}