#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*/ panos_uart_char(char);
void panos_uart_int(int num, int base) {
  int sum = num;
  int digit;
  do {
    digit = sum % base;
    if (digit < 0xA) {
      panos_uart_char('0' + digit);
    } else {
      panos_uart_char('A' + digit - 0xA);
    }
    sum /= base;
  } while (sum);
}


x86 assembly (clang, -O0):
<panos_uart_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    114b <panos_uart_int+0x3b>
mov    -0x10(%rbp),%eax
add    $0x30,%eax
movsbl %al,%edi
call   1030 <panos_uart_char@plt>
jmp    115c <panos_uart_int+0x4c>
mov    -0x10(%rbp),%eax
add    $0x41,%eax
sub    $0xa,%eax
movsbl %al,%edi
call   1030 <panos_uart_char@plt>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1124 <panos_uart_int+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<panos_uart_int>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0x30,%r14d
xchg   %ax,%ax
mov    %ebp,%eax
cltd
idiv   %ebx
cmp    $0xa,%edx
mov    $0x37,%ecx
cmovl  %r14d,%ecx
add    %dl,%cl
movsbl %cl,%edi
mov    %eax,%ebp
call   1030 <panos_uart_char@plt>
test   %ebp,%ebp
jne    1120 <panos_uart_int+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @panos_uart_int(i32 %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ %0, %2 ], [ %11, %3 ]
%5 = srem i32 %4, %1
%6 = icmp slt i32 %5, 10
%7 = trunc i32 %5 to i8
%8 = select i1 %6, i8 48, i8 55
%9 = add i8 %8, %7
%10 = tail call i32 @panos_uart_char(i8 signext %9)
%11 = sdiv i32 %4, %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %3
13: ; preds = %3
ret void
}