#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*/ print_digit(char, char, unsigned int);
void print_hex(char x, char y, unsigned num) {
  char i;
  for (i = 12; i >= 0; i -= 4, x += 1)
    print_digit(x, y, (num >> i) & 0x0f);
}


x86 assembly (clang, -O0):
<print_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
mov    %edx,-0x8(%rbp)
movb   $0xc,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
jl     1174 <print_hex+0x64>
mov    -0x1(%rbp),%al
mov    %al,-0xa(%rbp)
mov    -0x2(%rbp),%al
mov    -0x8(%rbp),%edx
movsbl -0x9(%rbp),%ecx
shr    %cl,%edx
mov    -0xa(%rbp),%cl
and    $0xf,%edx
movsbl %cl,%edi
movsbl %al,%esi
call   1030 <print_digit@plt>
movsbl -0x9(%rbp),%eax
sub    $0x4,%eax
mov    %al,-0x9(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x1,%eax
mov    %al,-0x1(%rbp)
jmp    112b <print_hex+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hex>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
shr    $0xc,%edx
and    $0xf,%edx
call   1030 <print_digit@plt>
lea    0x1(%rbp),%eax
mov    %ebx,%edx
shr    $0x8,%edx
and    $0xf,%edx
movsbl %al,%edi
mov    %r14d,%esi
call   1030 <print_digit@plt>
lea    0x2(%rbp),%eax
mov    %ebx,%edx
shr    $0x4,%edx
and    $0xf,%edx
movsbl %al,%edi
mov    %r14d,%esi
call   1030 <print_digit@plt>
lea    0x3(%rbp),%eax
and    $0xf,%ebx
movsbl %al,%edi
mov    %r14d,%esi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <print_digit@plt>

LLVM IR (-O0):
define void @print_hex(i8 signext %0, i8 signext %1, i32 %2) {
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8
store i8 %0, i8* %4
store i8 %1, i8* %5
store i32 %2, i32* %6
store i8 12, i8* %7
br label %8
8: ; preds = %21, %3
%9 = load i8, i8* %7
%10 = sext i8 %9 to i32
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load i8, i8* %4
%14 = load i8, i8* %5
%15 = load i32, i32* %6
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
%18 = lshr i32 %15, %17
%19 = and i32 %18, 15
%20 = call i32 @print_digit(i8 signext %13, i8 signext %14, i32 %19)
br label %21
21: ; preds = %12
%22 = load i8, i8* %7
%23 = sext i8 %22 to i32
%24 = sub nsw i32 %23, 4
%25 = trunc i32 %24 to i8
store i8 %25, i8* %7
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, 1
%29 = trunc i32 %28 to i8
store i8 %29, i8* %4
br label %8
30: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @print_hex(i8 signext %0, i8 signext %1, i32 %2) {
%4 = lshr i32 %2, 12
%5 = and i32 %4, 15
%6 = tail call i32 @print_digit(i8 signext %0, i8 signext %1, i32 %5)
%7 = add i8 %0, 1
%8 = lshr i32 %2, 8
%9 = and i32 %8, 15
%10 = tail call i32 @print_digit(i8 signext %7, i8 signext %1, i32 %9)
%11 = add i8 %0, 2
%12 = lshr i32 %2, 4
%13 = and i32 %12, 15
%14 = tail call i32 @print_digit(i8 signext %11, i8 signext %1, i32 %13)
%15 = add i8 %0, 3
%16 = and i32 %2, 15
%17 = tail call i32 @print_digit(i8 signext %15, i8 signext %1, i32 %16)
ret void
}