#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 hex_to_byte(char);
int /*<<< orphan*/ log_msg(int /*<<< orphan*/, char *, int, char *, char, char,
                           int);
int hex_to_char(char *p) {
  int ret = (hex_to_byte(*p) << 4) + hex_to_byte(*(p + 1));
  log_msg(0,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/w1ndy/simple-http-server/refs/heads/"
          "master/http.c",
          286, "hex_to_char: %c%c to %d", *p, *(p + 1), ret);
  return ret;
}


x86 assembly (clang, -O0):
<hex_to_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <hex_to_byte@plt>
shl    $0x4,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1040 <hex_to_byte@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%r8b
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%r9b
mov    -0xc(%rbp),%eax
xor    %edi,%edi
lea    0xe90(%rip),%rsi
mov    $0x11e,%edx
lea    0xf10(%rip),%rcx
movsbl %r8b,%r8d
movsbl %r9b,%r9d
mov    %eax,(%rsp)
call   1030 <log_msg@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_to_char>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <hex_to_byte@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0x1(%rbx),%edi
call   1040 <hex_to_byte@plt>
mov    %eax,%r14d
add    %ebp,%r14d
movsbl (%rbx),%r8d
movsbl 0x1(%rbx),%r9d
mov    %r14d,(%rsp)
lea    0xea5(%rip),%rsi
lea    0xf2a(%rip),%rcx
xor    %edi,%edi
mov    $0x11e,%edx
call   1030 <log_msg@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/w1ndy/simple-http-server/refs/heads/master/http.c\00"
@.str.1 = [24 x i8] c"hex_to_char: %c%c to %d\00"
define i32 @hex_to_char(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = call i32 @hex_to_byte(i8 signext %5)
%7 = shl i32 %6, 4
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = call i32 @hex_to_byte(i8 signext %10)
%12 = add nsw i32 %7, %11
store i32 %12, i32* %3
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = load i32, i32* %3
%19 = call i32 @log_msg(i32 0, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 286, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8 signext %14, i8 signext %17, i32 %18)
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/w1ndy/simple-http-server/refs/heads/master/http.c\00"
@.str.1 = [24 x i8] c"hex_to_char: %c%c to %d\00"
define i32 @hex_to_char(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @hex_to_byte(i8 signext %2)
%4 = shl i32 %3, 4
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = tail call i32 @hex_to_byte(i8 signext %6)
%8 = add nsw i32 %7, %4
%9 = load i8, i8* %0
%10 = load i8, i8* %5
%11 = tail call i32 @log_msg(i32 0, i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 286, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8 signext %9, i8 signext %10, i32 %8)
ret i32 %8
}