#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*/ uart_putc(char);
void uart_put_uint(unsigned int value) {
  int i;
  unsigned char c;
  uart_putc('0');
  uart_putc('x');
  for (i = 0; i < 8; i++) {
    c = (value & 0xf0000000) >> 28;
    uart_putc((c < 10 ? '0' : 'A' - 10) + c);
    value = (value & 0x0fffffff) << 4;
  }
  uart_putc('\n');
}


x86 assembly (clang, -O0):
<uart_put_uint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x30,%edi
call   1030 <uart_putc@plt>
mov    $0x78,%edi
call   1030 <uart_putc@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    118c <uart_put_uint+0x7c>
mov    -0x4(%rbp),%eax
and    $0xf0000000,%eax
shr    $0x1c,%eax
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%edx
mov    $0x37,%eax
mov    $0x30,%ecx
cmp    $0xa,%edx
cmovl  %ecx,%eax
movzbl -0x9(%rbp),%ecx
add    %ecx,%eax
movsbl %al,%edi
call   1030 <uart_putc@plt>
mov    -0x4(%rbp),%eax
and    $0xfffffff,%eax
shl    $0x4,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <uart_put_uint+0x26>
mov    $0xa,%edi
call   1030 <uart_putc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_put_uint>:
push   %rbx
mov    %edi,%ebx
mov    $0x30,%edi
call   1030 <uart_putc@plt>
mov    $0x78,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%edi
shr    $0x1c,%edi
lea    0x37(%rdi),%eax
or     $0x30,%edi
cmp    $0xa0000000,%ebx
cmovae %eax,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%eax
shl    $0x4,%eax
mov    %eax,%edi
shr    $0x1c,%edi
lea    0x37(%rdi),%ecx
or     $0x30,%edi
cmp    $0xa0000000,%eax
cmovae %ecx,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%eax
shl    $0x8,%eax
mov    %eax,%edi
shr    $0x1c,%edi
lea    0x37(%rdi),%ecx
or     $0x30,%edi
cmp    $0xa0000000,%eax
cmovae %ecx,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%eax
shl    $0xc,%eax
mov    %eax,%edi
shr    $0x1c,%edi
lea    0x37(%rdi),%ecx
or     $0x30,%edi
cmp    $0xa0000000,%eax
cmovae %ecx,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%eax
shl    $0x10,%eax
mov    %eax,%edi
shr    $0x1c,%edi
lea    0x37(%rdi),%ecx
or     $0x30,%edi
cmp    $0xa0000000,%eax
cmovae %ecx,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%eax
shl    $0x14,%eax
mov    %eax,%edi
shr    $0x1c,%edi
lea    0x37(%rdi),%ecx
or     $0x30,%edi
cmp    $0xa0000000,%eax
cmovae %ecx,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%eax
shl    $0x18,%eax
mov    %eax,%edi
shr    $0x1c,%edi
lea    0x37(%rdi),%ecx
or     $0x30,%edi
cmp    $0xa0000000,%eax
cmovae %ecx,%edi
call   1030 <uart_putc@plt>
mov    %ebx,%eax
shl    $0x1c,%eax
and    $0xf,%ebx
lea    0x37(%rbx),%ecx
or     $0x30,%ebx
cmp    $0xa0000000,%eax
cmovae %ecx,%ebx
mov    %ebx,%edi
call   1030 <uart_putc@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <uart_putc@plt>

LLVM IR (-O0):
define void @uart_put_uint(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %2
%5 = call i32 @uart_putc(i8 signext 48)
%6 = call i32 @uart_putc(i8 signext 120)
store i32 0, i32* %3
br label %7
7: ; preds = %28, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i32, i32* %2
%12 = and i32 %11, -268435456
%13 = lshr i32 %12, 28
%14 = trunc i32 %13 to i8
store i8 %14, i8* %4
%15 = load i8, i8* %4
%16 = zext i8 %15 to i32
%17 = icmp slt i32 %16, 10
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 48, i32 55
%20 = load i8, i8* %4
%21 = zext i8 %20 to i32
%22 = add nsw i32 %19, %21
%23 = trunc i32 %22 to i8
%24 = call i32 @uart_putc(i8 signext %23)
%25 = load i32, i32* %2
%26 = and i32 %25, 268435455
%27 = shl i32 %26, 4
store i32 %27, i32* %2
br label %28
28: ; preds = %10
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %7
31: ; preds = %7
%32 = call i32 @uart_putc(i8 signext 10)
ret void
}

LLVM IR (-O2):
define void @uart_put_uint(i32 %0) {
%2 = tail call i32 @uart_putc(i8 signext 48)
%3 = tail call i32 @uart_putc(i8 signext 120)
%4 = lshr i32 %0, 28
%5 = icmp ult i32 %0, -1610612736
%6 = select i1 %5, i32 48, i32 55
%7 = add nuw nsw i32 %6, %4
%8 = trunc i32 %7 to i8
%9 = tail call i32 @uart_putc(i8 signext %8)
%10 = shl i32 %0, 4
%11 = lshr i32 %10, 28
%12 = icmp ult i32 %10, -1610612736
%13 = select i1 %12, i32 48, i32 55
%14 = add nuw nsw i32 %13, %11
%15 = trunc i32 %14 to i8
%16 = tail call i32 @uart_putc(i8 signext %15)
%17 = shl i32 %0, 8
%18 = lshr i32 %17, 28
%19 = icmp ult i32 %17, -1610612736
%20 = select i1 %19, i32 48, i32 55
%21 = add nuw nsw i32 %20, %18
%22 = trunc i32 %21 to i8
%23 = tail call i32 @uart_putc(i8 signext %22)
%24 = shl i32 %0, 12
%25 = lshr i32 %24, 28
%26 = icmp ult i32 %24, -1610612736
%27 = select i1 %26, i32 48, i32 55
%28 = add nuw nsw i32 %27, %25
%29 = trunc i32 %28 to i8
%30 = tail call i32 @uart_putc(i8 signext %29)
%31 = shl i32 %0, 16
%32 = lshr i32 %31, 28
%33 = icmp ult i32 %31, -1610612736
%34 = select i1 %33, i32 48, i32 55
%35 = add nuw nsw i32 %34, %32
%36 = trunc i32 %35 to i8
%37 = tail call i32 @uart_putc(i8 signext %36)
%38 = shl i32 %0, 20
%39 = lshr i32 %38, 28
%40 = icmp ult i32 %38, -1610612736
%41 = select i1 %40, i32 48, i32 55
%42 = add nuw nsw i32 %41, %39
%43 = trunc i32 %42 to i8
%44 = tail call i32 @uart_putc(i8 signext %43)
%45 = shl i32 %0, 24
%46 = lshr i32 %45, 28
%47 = icmp ult i32 %45, -1610612736
%48 = select i1 %47, i32 48, i32 55
%49 = add nuw nsw i32 %48, %46
%50 = trunc i32 %49 to i8
%51 = tail call i32 @uart_putc(i8 signext %50)
%52 = shl i32 %0, 28
%53 = and i32 %0, 15
%54 = icmp ult i32 %52, -1610612736
%55 = select i1 %54, i32 48, i32 55
%56 = add nuw nsw i32 %55, %53
%57 = trunc i32 %56 to i8
%58 = tail call i32 @uart_putc(i8 signext %57)
%59 = tail call i32 @uart_putc(i8 signext 10)
ret void
}