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

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


x86 assembly (clang, -O0):
<test_gea3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1050 <osmo_gea3@plt>
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%edx
call   1040 <print_check@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_gea3>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,-0x30(%rbp)
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%r13d
lea    0xeac(%rip),%rdi
mov    %ecx,%esi
mov    %r12d,%ecx
call   1030 <printf@plt>
mov    %ebx,%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
call   1050 <osmo_gea3@plt>
mov    -0x30(%rbp),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <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_gea3(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%13 = load i32, i32* %9
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14, i32 %15)
%17 = load i32, i32* %9
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %11
%20 = alloca i32, i64 %18
store i64 %18, i64* %12
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @osmo_gea3(i32* %20, i32 %21, i32 %22, i32 %23, i32 %24)
%26 = load i8*, i8** %10
%27 = load i32, i32* %9
%28 = call i32 @print_check(i8* %26, i32* %20, i32 %27)
%29 = load i8*, i8** %11
ret void
}

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