#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*/ dbg_write_char(char const);
void dbg_write_hex32(const unsigned long val) {
  static const char hextab[] = {'0', '1', '2', '3', '4', '5', '6', '7',
                                '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
  for (int shift = 28; shift >= 0; shift -= 4)
    dbg_write_char(hextab[(val >> shift) & 0xf]);
}


x86 assembly (clang, -O0):
<dbg_write_hex32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1c,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     115c <dbg_write_hex32+0x4c>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shr    %cl,%rax
mov    %rax,%rcx
and    $0xf,%rcx
lea    0xebb(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <dbg_write_char@plt>
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <dbg_write_hex32+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbg_write_hex32>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %ebx,%eax
shr    $0x1c,%eax
lea    0xedd(%rip),%r14
movsbl (%rax,%r14,1),%edi
call   1030 <dbg_write_char@plt>
mov    %ebx,%eax
shr    $0x18,%eax
and    $0xf,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <dbg_write_char@plt>
mov    %ebx,%eax
shr    $0x14,%eax
and    $0xf,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <dbg_write_char@plt>
mov    %ebx,%eax
shr    $0x10,%eax
and    $0xf,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <dbg_write_char@plt>
mov    %ebx,%eax
shr    $0xc,%eax
and    $0xf,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <dbg_write_char@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0xf,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <dbg_write_char@plt>
mov    %ebx,%eax
shr    $0x4,%eax
and    $0xf,%eax
movsbl (%rax,%r14,1),%edi
call   1030 <dbg_write_char@plt>
and    $0xf,%ebx
movsbl (%rbx,%r14,1),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <dbg_write_char@plt>

LLVM IR (-O0):
@dbg_write_hex32.hextab = internal constant [16 x i8] c"0123456789abcdef"
define void @dbg_write_hex32(i64 %0) {
%2 = alloca i64
%3 = alloca i32
store i64 %0, i64* %2
store i32 28, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i64, i64* %2
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = lshr i64 %8, %10
%12 = and i64 %11, 15
%13 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @dbg_write_char(i8 signext %14)
br label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 4
store i32 %18, i32* %3
br label %4
19: ; preds = %4
ret void
}

LLVM IR (-O2):
@dbg_write_hex32.hextab = internal unnamed_addr constant [16 x i8] c"0123456789abcdef"
define void @dbg_write_hex32(i64 %0) {
%2 = lshr i64 %0, 28
%3 = and i64 %2, 15
%4 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i32 @dbg_write_char(i8 signext %5)
%7 = lshr i64 %0, 24
%8 = and i64 %7, 15
%9 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @dbg_write_char(i8 signext %10)
%12 = lshr i64 %0, 20
%13 = and i64 %12, 15
%14 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = tail call i32 @dbg_write_char(i8 signext %15)
%17 = lshr i64 %0, 16
%18 = and i64 %17, 15
%19 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = tail call i32 @dbg_write_char(i8 signext %20)
%22 = lshr i64 %0, 12
%23 = and i64 %22, 15
%24 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = tail call i32 @dbg_write_char(i8 signext %25)
%27 = lshr i64 %0, 8
%28 = and i64 %27, 15
%29 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = tail call i32 @dbg_write_char(i8 signext %30)
%32 = lshr i64 %0, 4
%33 = and i64 %32, 15
%34 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = tail call i32 @dbg_write_char(i8 signext %35)
%37 = and i64 %0, 15
%38 = getelementptr inbounds [16 x i8], [16 x i8]* @dbg_write_hex32.hextab, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = tail call i32 @dbg_write_char(i8 signext %39)
ret void
}