#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 uint16_t;

/* Variables and functions */
scalar_t__ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
char *osmo_hexdump_nospc(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ osmo_hexparse(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *, ...);
void print_check(char *res, uint8_t *out, uint16_t len) {
  uint8_t buf[len];
  osmo_hexparse(res, buf, len);
  if (0 != memcmp(buf, out, len)) {
    printf("FAIL:\n");
    printf("OUT: %s\n", osmo_hexdump_nospc(out, len));
    printf("EXP: %s\n", osmo_hexdump_nospc(buf, len));
  } else
    printf("OK\n");
}


x86 assembly (clang, -O0):
<print_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x30(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
call   1030 <osmo_hexparse@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11f1 <print_check+0xb1>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <osmo_hexdump_nospc@plt>
mov    %rax,%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <osmo_hexdump_nospc@plt>
mov    %rax,%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <print_check+0xbf>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_check>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edx,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rsi
call   1040 <osmo_hexparse@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1070 <memcmp@plt>
test   %rax,%rax
je     11d8 <print_check+0x88>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1060 <osmo_hexdump_nospc@plt>
lea    0xe50(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <osmo_hexdump_nospc@plt>
lea    0xe3d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e4 <print_check+0x94>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"FAIL:\0A\00"
@.str.1 = [9 x i8] c"OUT: %s\0A\00"
@.str.2 = [9 x i8] c"EXP: %s\0A\00"
@.str.3 = [4 x i8] c"OK\0A\00"
define void @print_check(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %7
%12 = alloca i32, i64 %10
store i64 %10, i64* %8
%13 = load i8*, i8** %4
%14 = load i32, i32* %6
%15 = call i32 @osmo_hexparse(i8* %13, i32* %12, i32 %14)
%16 = load i32*, i32** %5
%17 = load i32, i32* %6
%18 = call i64 @memcmp(i32* %12, i32* %16, i32 %17)
%19 = icmp ne i64 0, %18
br i1 %19, label %20, label %29
20: ; preds = %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = load i32*, i32** %5
%23 = load i32, i32* %6
%24 = call i8* @osmo_hexdump_nospc(i32* %22, i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %6
%27 = call i8* @osmo_hexdump_nospc(i32* %12, i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %31
29: ; preds = %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %29, %20
%32 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"OUT: %s\0A\00"
@.str.2 = [9 x i8] c"EXP: %s\0A\00"
@str = [3 x i8] c"OK\00"
@str.4 = [6 x i8] c"FAIL:\00"
define void @print_check(i8* %0, i32* %1, i32 %2) {
%4 = zext i32 %2 to i64
%5 = alloca i32, i64 %4
%6 = call i32 @osmo_hexparse(i8* %0, i32* %5, i32 %2)
%7 = call i64 @memcmp(i32* %5, i32* %1, i32 %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0))
%11 = call i8* @osmo_hexdump_nospc(i32* %1, i32 %2)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i8* @osmo_hexdump_nospc(i32* %5, i32 %2)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %3
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
ret void
}