#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*/ xputc(char const);
void dabt_put_hex(unsigned int data, int nbls) {
  unsigned int data_t;
  const char _hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
                         '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
  while (nbls) {
    data_t = (data >> ((nbls - 1) * 4)) & 0xF;
    xputc(_hex[data_t]);
    nbls--;
  }
}


x86 assembly (clang, -O0):
<dabt_put_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     116d <dabt_put_hex+0x5d>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x2,%ecx
shr    %cl,%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%edi
call   1030 <xputc@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1134 <dabt_put_hex+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dabt_put_hex>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     114c <dabt_put_hex+0x3c>
mov    %esi,%ebx
mov    %edi,%r14d
lea    -0x4(,%rbx,4),%ebp
lea    0xed2(%rip),%r15
xchg   %ax,%ax
mov    %r14d,%eax
mov    %ebp,%ecx
shr    %cl,%eax
and    $0xf,%eax
movsbl (%rax,%r15,1),%edi
call   1030 <xputc@plt>
add    $0xfffffffc,%ebp
add    $0xffffffff,%ebx
jne    1130 <dabt_put_hex+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.dabt_put_hex._hex = [16 x i8] c"0123456789abcdef"
define void @dabt_put_hex(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = bitcast [16 x i8]* %6 to i8*
br label %8
8: ; preds = %11, %2
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = mul nsw i32 %14, 4
%16 = lshr i32 %12, %15
%17 = and i32 %16, 15
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @xputc(i8 signext %21)
%23 = load i32, i32* %4
%24 = add nsw i32 %23, -1
store i32 %24, i32* %4
br label %8
25: ; preds = %8
ret void
}

LLVM IR (-O2):
@__const.dabt_put_hex._hex = [16 x i8] c"0123456789abcdef"
define void @dabt_put_hex(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %14, %4 ], [ %1, %2 ]
%6 = shl i32 %5, 2
%7 = add i32 %6, -4
%8 = lshr i32 %0, %7
%9 = and i32 %8, 15
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.dabt_put_hex._hex, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @xputc(i8 signext %12)
%14 = add nsw i32 %5, -1
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %4
16: ; preds = %4, %2
ret void
}