#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 */
char digit_to_char(unsigned int, unsigned int);
int /*<<< orphan*/ putchar(char);
int print_unsigned_int(unsigned int i, unsigned int radix,
                       unsigned int use_uppercase) {
  char digit = digit_to_char(i % radix, use_uppercase);
  int remains = (i / radix);
  if (remains > 0) {
    int nprinted = print_unsigned_int(remains, radix, use_uppercase);
    putchar(digit);
    return 1 + nprinted;
  } else {
    putchar(digit);
    return 1;
  }
}


x86 assembly (clang, -O0):
<print_unsigned_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %edx,%edi
mov    -0x10(%rbp),%esi
call   1050 <digit_to_char@plt>
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%eax
xor    %edx,%edx
divl   -0xc(%rbp)
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1193 <print_unsigned_int+0x63>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <print_unsigned_int@plt>
mov    %eax,-0x1c(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a3 <print_unsigned_int+0x73>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_unsigned_int>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%eax
xor    %edx,%edx
div    %esi
mov    %edx,%edi
mov    %eax,%ebx
mov    %r15d,%esi
call   1050 <digit_to_char@plt>
mov    %eax,%r14d
test   %ebx,%ebx
jle    1171 <print_unsigned_int+0x41>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r15d,%edx
call   1040 <print_unsigned_int@plt>
mov    %eax,%ebx
movsbl %r14b,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
jmp    117f <print_unsigned_int+0x4f>
movsbl %r14b,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @print_unsigned_int(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = urem i32 %11, %12
%14 = load i32, i32* %7
%15 = call signext i8 @digit_to_char(i32 %13, i32 %14)
store i8 %15, i8* %8
%16 = load i32, i32* %5
%17 = load i32, i32* %6
%18 = udiv i32 %16, %17
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %3
%22 = load i32, i32* %9
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = call i32 @print_unsigned_int(i32 %22, i32 %23, i32 %24)
store i32 %25, i32* %10
%26 = load i8, i8* %8
%27 = call i32 @putchar(i8 signext %26)
%28 = load i32, i32* %10
%29 = add nsw i32 1, %28
store i32 %29, i32* %4
br label %33
30: ; preds = %3
%31 = load i8, i8* %8
%32 = call i32 @putchar(i8 signext %31)
store i32 1, i32* %4
br label %33
33: ; preds = %30, %21
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @print_unsigned_int(i32 %0, i32 %1, i32 %2) {
%4 = urem i32 %0, %1
%5 = tail call signext i8 @digit_to_char(i32 %4, i32 %2)
%6 = udiv i32 %0, %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %10, label %14
8: ; preds = %14, %10
%9 = phi i32 [ %13, %10 ], [ 1, %14 ]
ret i32 %9
10: ; preds = %3
%11 = tail call i32 @print_unsigned_int(i32 %6, i32 %1, i32 %2)
%12 = tail call i32 @putchar(i8 signext %5)
%13 = add nsw i32 %11, 1
br label %8
14: ; preds = %3
%15 = tail call i32 @putchar(i8 signext %5)
br label %8
}