#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*/ exit(int);
int hexa_str_to_byte_array(char const *, unsigned char *);
int /*<<< orphan*/ logmsg(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ print_byte_array(unsigned char *, size_t);
size_t strlen(char const *);
int /*<<< orphan*/ validate_arguments(int, char **);
int main(int argc, char *argv[]) {
  validate_arguments(argc, argv);
  const char *input = argv[1];
  size_t inputLen = strlen(input);
  size_t outputLen = inputLen / 2;
  int result;
  unsigned char output[outputLen];
  if ((result = hexa_str_to_byte_array(input, output)) != 0) {
    logmsg(0, "Something happens during conversion: %d", result);
    exit(result);
  }
  print_byte_array(output, outputLen);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <validate_arguments@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shr    %rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x48(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <hexa_str_to_byte_array@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     11fb <main+0x9b>
mov    -0x2c(%rbp),%edx
xor    %edi,%edi
lea    0xe12(%rip),%rsi
call   1060 <logmsg@plt>
mov    -0x2c(%rbp),%edi
call   1080 <exit@plt>
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <print_byte_array@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1040 <validate_arguments@plt>
mov    0x8(%rbx),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%r14
shr    %r14
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <hexa_str_to_byte_array@plt>
test   %eax,%eax
jne    11bc <main+0x5c>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <print_byte_array@plt>
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r15d
lea    0xe3a(%rip),%rsi
xor    %edi,%edi
mov    %eax,%edx
call   1060 <logmsg@plt>
mov    %r15d,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Something happens during conversion: %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @validate_arguments(i32 %12, i8** %13)
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i64 @strlen(i8* %18)
store i64 %19, i64* %7
%20 = load i64, i64* %7
%21 = udiv i64 %20, 2
store i64 %21, i64* %8
%22 = load i64, i64* %8
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %10
%24 = alloca i8, i64 %22
store i64 %22, i64* %11
%25 = load i8*, i8** %6
%26 = call i32 @hexa_str_to_byte_array(i8* %25, i8* %24)
store i32 %26, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %2
%29 = load i32, i32* %9
%30 = call i32 @logmsg(i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %9
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %2
%34 = load i64, i64* %8
%35 = call i32 @print_byte_array(i8* %24, i64 %34)
store i32 0, i32* %3
%36 = load i8*, i8** %10
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [40 x i8] c"Something happens during conversion: %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @validate_arguments(i32 %0, i8** %1)
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%7 = lshr i64 %6, 1
%8 = alloca i8, i64 %7
%9 = call i32 @hexa_str_to_byte_array(i8* %5, i8* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = call i32 @logmsg(i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %9)
%13 = call i32 @exit(i32 %9)
unreachable
14: ; preds = %2
%15 = call i32 @print_byte_array(i8* %8, i64 %7)
ret i32 0
}