#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*/ myputc(char);
void myputuint(unsigned int num, unsigned char base) {
  if (num >= base)
    myputuint(num / base, base);
  char dig = num % base;
  dig = dig + (dig < 10 ? '0' : 'A' - 10);
  myputc(dig);
}


x86 assembly (clang, -O0):
<myputuint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
movzbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jb     1156 <myputuint+0x36>
mov    -0x4(%rbp),%eax
movzbl -0x5(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
movzbl -0x5(%rbp),%esi
call   1040 <myputuint@plt>
mov    -0x4(%rbp),%eax
movzbl -0x5(%rbp),%ecx
xor    %edx,%edx
div    %ecx
mov    %dl,%al
mov    %al,-0x6(%rbp)
movsbl -0x6(%rbp),%eax
movsbl -0x6(%rbp),%esi
mov    $0x37,%ecx
mov    $0x30,%edx
cmp    $0xa,%esi
cmovl  %edx,%ecx
add    %ecx,%eax
mov    %al,-0x6(%rbp)
movsbl -0x6(%rbp),%edi
call   1030 <myputc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myputuint>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
cmp    %edi,%esi
ja     113b <myputuint+0x1b>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
movzbl %bl,%esi
mov    %eax,%edi
call   1040 <myputuint@plt>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
lea    0x37(%rdx),%eax
mov    %edx,%ecx
add    $0x30,%ecx
cmp    $0xa,%dl
cmovge %eax,%ecx
movsbl %cl,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <myputc@plt>

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

LLVM IR (-O2):
define void @myputuint(i32 %0, i8 zeroext %1) {
%3 = zext i8 %1 to i32
%4 = icmp ugt i32 %3, %0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = udiv i32 %0, %3
tail call void @myputuint(i32 %6, i8 zeroext %1)
br label %7
7: ; preds = %5, %2
%8 = urem i32 %0, %3
%9 = trunc i32 %8 to i8
%10 = icmp slt i8 %9, 10
%11 = select i1 %10, i32 48, i32 55
%12 = add nuw nsw i32 %11, %8
%13 = trunc i32 %12 to i8
%14 = tail call i32 @myputc(i8 signext %13)
ret void
}