#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*/ printf(char *, char, ...);
int strtol(char *, char **, int);
int main() {
  char *binstr = "0x4B";
  char *endptr;
  int integer = strtol(binstr, &endptr, 16);
  int j = strtol("0x5c", &endptr, 16);
  printf("hex: 0x%02X, dec: %d \n", integer, integer);
  printf("hex: 0x%02X, dec: %d \n", j, j);
  printf("%d\n", '\0');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,-0x1c(%rbp)
lea    0xeaf(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x1c(%rbp),%edx
lea    0xe96(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
mov    -0x20(%rbp),%edx
lea    0xe7f(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%ebp
lea    0xebb(%rip),%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1040 <strtol@plt>
mov    %eax,%ebx
movsbl %bpl,%esi
lea    0xea6(%rip),%r14
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movsbl %bl,%esi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0x4B\00"
@.str.1 = [5 x i8] c"0x5c\00"
@.str.2 = [23 x i8] c"hex: 0x%02X, dec: %d \0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strtol(i8* %6, i8** %3, i32 16)
store i32 %7, i32* %4
%8 = call i32 @strtol(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %3, i32 16)
store i32 %8, i32* %5
%9 = load i32, i32* %4
%10 = trunc i32 %9 to i8
%11 = load i32, i32* %4
%12 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %10, i32 %11)
%13 = load i32, i32* %5
%14 = trunc i32 %13 to i8
%15 = load i32, i32* %5
%16 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %14, i32 %15)
%17 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8 signext 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"0x4B\00"
@.str.1 = [5 x i8] c"0x5c\00"
@.str.2 = [23 x i8] c"hex: 0x%02X, dec: %d \0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call i32 @strtol(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %1, i32 16)
%4 = call i32 @strtol(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %1, i32 16)
%5 = trunc i32 %3 to i8
%6 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %5, i32 %3)
%7 = trunc i32 %4 to i8
%8 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8 signext %7, i32 %4)
%9 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8 signext 0)
ret i32 0
}