#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*/ int_to_hex(unsigned int, char *);
int /*<<< orphan*/ uart_putc(char);
void uart_print_hex(unsigned int data) {
  char num[10];
  int_to_hex(data, num);
  for (int i = 7; i >= 0; --i) {
    uart_putc(num[i]);
  }
  return;
}


x86 assembly (clang, -O0):
<uart_print_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xe(%rbp),%rsi
call   1040 <int_to_hex@plt>
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1164 <uart_print_hex+0x44>
movslq -0x14(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%edi
call   1030 <uart_putc@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <uart_print_hex+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_print_hex>:
sub    $0x18,%rsp
lea    0xe(%rsp),%rsi
call   1040 <int_to_hex@plt>
movsbl 0x15(%rsp),%edi
call   1030 <uart_putc@plt>
movsbl 0x14(%rsp),%edi
call   1030 <uart_putc@plt>
movsbl 0x13(%rsp),%edi
call   1030 <uart_putc@plt>
movsbl 0x12(%rsp),%edi
call   1030 <uart_putc@plt>
movsbl 0x11(%rsp),%edi
call   1030 <uart_putc@plt>
movsbl 0x10(%rsp),%edi
call   1030 <uart_putc@plt>
movsbl 0xf(%rsp),%edi
call   1030 <uart_putc@plt>
movsbl 0xe(%rsp),%edi
call   1030 <uart_putc@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @uart_print_hex(i32 %0) {
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = call i32 @int_to_hex(i32 %5, i8* %6)
store i32 7, i32* %4
br label %8
8: ; preds = %17, %1
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call i32 @uart_putc(i8 signext %15)
br label %17
17: ; preds = %11
%18 = load i32, i32* %4
%19 = add nsw i32 %18, -1
store i32 %19, i32* %4
br label %8
20: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @uart_print_hex(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i32 @int_to_hex(i32 %0, i8* %3)
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 7
%6 = load i8, i8* %5
%7 = call i32 @uart_putc(i8 signext %6)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
%9 = load i8, i8* %8
%10 = call i32 @uart_putc(i8 signext %9)
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 5
%12 = load i8, i8* %11
%13 = call i32 @uart_putc(i8 signext %12)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 4
%15 = load i8, i8* %14
%16 = call i32 @uart_putc(i8 signext %15)
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 3
%18 = load i8, i8* %17
%19 = call i32 @uart_putc(i8 signext %18)
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 2
%21 = load i8, i8* %20
%22 = call i32 @uart_putc(i8 signext %21)
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
%24 = load i8, i8* %23
%25 = call i32 @uart_putc(i8 signext %24)
%26 = load i8, i8* %3
%27 = call i32 @uart_putc(i8 signext %26)
ret void
}