#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 */
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ rd_key;
};
struct TYPE_5__ {
  TYPE_1__ u;
  int /*<<< orphan*/ grand_rounds;
};
typedef TYPE_2__ CAMELLIA_KEY;

/* Variables and functions */
int /*<<< orphan*/ Camellia_Ekeygen(int const, unsigned char const *,
                                    int /*<<< orphan*/);
int private_Camellia_set_key(const unsigned char *userKey, const int bits,
                             CAMELLIA_KEY *key) {
  if (!userKey || !key)
    return -1;
  if (bits != 128 && bits != 192 && bits != 256)
    return -2;
  key->grand_rounds = Camellia_Ekeygen(bits, userKey, key->u.rd_key);
  return 0;
}


x86 assembly (clang, -O0):
<private_Camellia_set_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1139 <private_Camellia_set_key+0x29>
cmpq   $0x0,-0x20(%rbp)
jne    1145 <private_Camellia_set_key+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <private_Camellia_set_key+0x8a>
cmpl   $0x80,-0x14(%rbp)
je     1178 <private_Camellia_set_key+0x68>
cmpl   $0xc0,-0x14(%rbp)
je     1178 <private_Camellia_set_key+0x68>
cmpl   $0x100,-0x14(%rbp)
je     1178 <private_Camellia_set_key+0x68>
movl   $0xfffffffe,-0x4(%rbp)
jmp    119a <private_Camellia_set_key+0x8a>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   1030 <Camellia_Ekeygen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<private_Camellia_set_key>:
push   %rbx
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1154 <private_Camellia_set_key+0x44>
mov    %rdx,%rbx
test   %rdx,%rdx
je     1154 <private_Camellia_set_key+0x44>
mov    %rdi,%rcx
cmp    $0x80,%esi
je     1143 <private_Camellia_set_key+0x33>
cmp    $0x100,%esi
je     1143 <private_Camellia_set_key+0x33>
mov    $0xfffffffe,%eax
cmp    $0xc0,%esi
jne    1154 <private_Camellia_set_key+0x44>
mov    (%rbx),%edx
mov    %esi,%edi
mov    %rcx,%rsi
call   1030 <Camellia_Ekeygen@plt>
mov    %eax,0x4(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32 }
define i32 @private_Camellia_set_key(i8* %0, i32 %1, %struct.TYPE_5__* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.TYPE_5__*
store i8* %0, i8** %5
store i32 %1, i32* %6
store %struct.TYPE_5__* %2, %struct.TYPE_5__** %7
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%12 = icmp ne %struct.TYPE_5__* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10, %3
store i32 -1, i32* %4
br label %34
14: ; preds = %10
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 128
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 192
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 256
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 -2, i32* %4
br label %34
24: ; preds = %20, %17, %14
%25 = load i32, i32* %6
%26 = load i8*, i8** %5
%27 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %27, i32 0, i32 0
%29 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i32 @Camellia_Ekeygen(i32 %25, i8* %26, i32 %30)
%32 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %32, i32 0, i32 1
store i32 %31, i32* %33
store i32 0, i32* %4
br label %34
34: ; preds = %24, %23, %13
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32 }
define i32 @private_Camellia_set_key(i8* %0, i32 %1, %struct.TYPE_5__* %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne %struct.TYPE_5__* %2, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %13
7: ; preds = %3
switch i32 %1, label %13 [
i32 256, label %8
i32 192, label %8
i32 128, label %8
]
8: ; preds = %7, %7, %7
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i32 @Camellia_Ekeygen(i32 %1, i8* %0, i32 %10)
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %2, i64 0, i32 1
store i32 %11, i32* %12
br label %13
13: ; preds = %7, %3, %8
%14 = phi i32 [ 0, %8 ], [ -1, %3 ], [ -2, %7 ]
ret i32 %14
}