#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*/ uint8_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ osmo_gea4(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *,
                             int, int);
int /*<<< orphan*/ osmo_hexparse(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ print_check(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *, int, int, int);
void test_gea4(char *kc, uint32_t iv, int dir, uint16_t len, char *res) {
  printf("%d: %d -> 0x%X ", len, dir, iv);
  uint8_t out[len], ck[256];
  osmo_hexparse(kc, ck, len);
  osmo_gea4(out, len, ck, iv, dir);
  print_check(res, out, len);
}


x86 assembly (clang, -O0):
<test_gea4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x438(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <osmo_hexparse@plt>
mov    -0x438(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x430(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
call   1060 <osmo_gea4@plt>
mov    -0x438(%rbp),%rsi
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
call   1050 <print_check@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_gea4>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r8,-0x38(%rbp)
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,-0x30(%rbp)
lea    0xe95(%rip),%rdi
mov    %ecx,%esi
mov    %r12d,%ecx
call   1040 <printf@plt>
mov    %ebx,%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    -0x440(%rbp),%r13
mov    -0x30(%rbp),%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <osmo_hexparse@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %r12d,%ecx
mov    %r15d,%r8d
call   1060 <osmo_gea4@plt>
mov    -0x38(%rbp),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <print_check@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%d: %d -> 0x%X \00"
define void @test_gea4(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca [256 x i32]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%14 = load i32, i32* %9
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* %9
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %11
%21 = alloca i32, i64 %19
store i64 %19, i64* %12
%22 = load i8*, i8** %6
%23 = getelementptr inbounds [256 x i32], [256 x i32]* %13, i64 0, i64 0
%24 = load i32, i32* %9
%25 = call i32 @osmo_hexparse(i8* %22, i32* %23, i32 %24)
%26 = load i32, i32* %9
%27 = getelementptr inbounds [256 x i32], [256 x i32]* %13, i64 0, i64 0
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = call i32 @osmo_gea4(i32* %21, i32 %26, i32* %27, i32 %28, i32 %29)
%31 = load i8*, i8** %10
%32 = load i32, i32* %9
%33 = call i32 @print_check(i8* %31, i32* %21, i32 %32)
%34 = load i8*, i8** %11
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"%d: %d -> 0x%X \00"
define void @test_gea4(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca [256 x i32]
%7 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %2, i32 %1)
%8 = zext i32 %3 to i64
%9 = alloca i32, i64 %8
%10 = bitcast [256 x i32]* %6 to i8*
%11 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 0
%12 = call i32 @osmo_hexparse(i8* %0, i32* %11, i32 %3)
%13 = call i32 @osmo_gea4(i32* %9, i32 %3, i32* %11, i32 %1, i32 %2)
%14 = call i32 @print_check(i8* %4, i32* %9, i32 %3)
ret void
}