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

/* Variables and functions */
int EXIT_FAILURE;
scalar_t__ EXIT_SUCCESS;
scalar_t__ bytes_from_base16hex(int /*<<< orphan*/ *, size_t, char const *,
                                size_t);
scalar_t__ bytes_from_base32hex(int /*<<< orphan*/ *, size_t, char const *,
                                size_t);
size_t strlen(char const *);
int hex_get_id(uint8_t id[], size_t idsize, const char query[]) {
  size_t querysize;
  querysize = strlen(query);
  if (EXIT_SUCCESS == bytes_from_base32hex(id, idsize, query, querysize)) {
    return EXIT_SUCCESS;
  }
  if (EXIT_SUCCESS == bytes_from_base16hex(id, idsize, query, querysize)) {
    return EXIT_SUCCESS;
  }
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<hex_get_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e80(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <bytes_from_base32hex@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jne    1196 <hex_get_id+0x66>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    11e7 <hex_get_id+0xb7>
mov    0x2e3b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <bytes_from_base16hex@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jne    11db <hex_get_id+0xab>
mov    0x2e08(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    11e7 <hex_get_id+0xb7>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_get_id>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
mov    0x2e82(%rip),%r15
mov    (%r15),%rbp
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1030 <bytes_from_base32hex@plt>
mov    (%r15),%r15
cmp    %rax,%rbp
je     119b <hex_get_id+0x6b>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
call   1050 <bytes_from_base16hex@plt>
cmp    %rax,%r15
jne    1191 <hex_get_id+0x61>
mov    0x2e49(%rip),%rax
jmp    1198 <hex_get_id+0x68>
mov    0x2e48(%rip),%rax
mov    (%rax),%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i64 0
@EXIT_FAILURE = global i32 0
define i32 @hex_get_id(i32* %0, i64 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%9 = load i8*, i8** %7
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %8
%11 = load i64, i64* @EXIT_SUCCESS
%12 = load i32*, i32** %5
%13 = load i64, i64* %6
%14 = load i8*, i8** %7
%15 = load i64, i64* %8
%16 = call i64 @bytes_from_base32hex(i32* %12, i64 %13, i8* %14, i64 %15)
%17 = icmp eq i64 %11, %16
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i64, i64* @EXIT_SUCCESS
%20 = trunc i64 %19 to i32
store i32 %20, i32* %4
br label %34
21: ; preds = %3
%22 = load i64, i64* @EXIT_SUCCESS
%23 = load i32*, i32** %5
%24 = load i64, i64* %6
%25 = load i8*, i8** %7
%26 = load i64, i64* %8
%27 = call i64 @bytes_from_base16hex(i32* %23, i64 %24, i8* %25, i64 %26)
%28 = icmp eq i64 %22, %27
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i64, i64* @EXIT_SUCCESS
%31 = trunc i64 %30 to i32
store i32 %31, i32* %4
br label %34
32: ; preds = %21
%33 = load i32, i32* @EXIT_FAILURE
store i32 %33, i32* %4
br label %34
34: ; preds = %32, %29, %18
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i64 0
@EXIT_FAILURE = global i32 0
define i32 @hex_get_id(i32* %0, i64 %1, i8* %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%5 = load i64, i64* @EXIT_SUCCESS
%6 = tail call i64 @bytes_from_base32hex(i32* %0, i64 %1, i8* %2, i64 %4)
%7 = icmp eq i64 %5, %6
%8 = load i64, i64* @EXIT_SUCCESS
br i1 %7, label %9, label %11
9: ; preds = %3
%10 = trunc i64 %8 to i32
br label %19
11: ; preds = %3
%12 = tail call i64 @bytes_from_base16hex(i32* %0, i64 %1, i8* %2, i64 %4)
%13 = icmp eq i64 %8, %12
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i64, i64* @EXIT_SUCCESS
%16 = trunc i64 %15 to i32
br label %19
17: ; preds = %11
%18 = load i32, i32* @EXIT_FAILURE
br label %19
19: ; preds = %17, %14, %9
%20 = phi i32 [ %10, %9 ], [ %16, %14 ], [ %18, %17 ]
ret i32 %20
}