#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 */
int /*<<< orphan*/ hex_decode(char *, char *, int);
int /*<<< orphan*/ hex_encode(char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
unsigned int hex_roundtrip_test() {
  char symbol[] = "deadbeef", output[9] = {0};
  char intarr[4] = {0};
  hex_decode(intarr, symbol, 2 * 4);
  hex_encode(output, intarr, 2 * 4);
  return !strcmp((char *)symbol, (char *)intarr);
}


x86 assembly (clang, -O0):
<hex_roundtrip_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x9(%rbp)
mov    0xeaf(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0x12(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1030 <memset@plt>
lea    -0x16(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    -0x16(%rbp),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x8,%edx
call   1040 <hex_decode@plt>
lea    -0x12(%rbp),%rdi
lea    -0x16(%rbp),%rsi
mov    $0x8,%edx
call   1060 <hex_encode@plt>
lea    -0x9(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_roundtrip_test>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movabs $0x6665656264616564,%rax
65 65 66
mov    %rax,0x18(%rsp)
movb   $0x0,0x20(%rsp)
movb   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rbx
lea    0x18(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <hex_decode@plt>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1050 <hex_encode@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.hex_roundtrip_test.symbol = [9 x i8] c"deadbeef\00"
define i32 @hex_roundtrip_test() {
%1 = alloca [9 x i8]
%2 = alloca [9 x i8]
%3 = alloca [4 x i8]
%4 = bitcast [9 x i8]* %1 to i8*
%5 = bitcast [9 x i8]* %2 to i8*
%6 = bitcast [4 x i8]* %3 to i8*
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%9 = call i32 @hex_decode(i8* %7, i8* %8, i32 8)
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%12 = call i32 @hex_encode(i8* %10, i8* %11, i32 8)
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%15 = call i32 @strcmp(i8* %13, i8* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
ret i32 %18
}

LLVM IR (-O2):
@__const.hex_roundtrip_test.symbol = [9 x i8] c"deadbeef\00"
define i32 @hex_roundtrip_test() {
%1 = alloca [9 x i8]
%2 = alloca [9 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = call i32 @hex_decode(i8* %6, i8* %4, i32 8)
%8 = call i32 @hex_encode(i8* %5, i8* %6, i32 8)
%9 = call i32 @strcmp(i8* %4, i8* %6)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
ret i32 %11
}