#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*/ putchar(char);
void printknu(unsigned n, int b) {
  char prbuf[24];
  register char *cp;
  cp = prbuf;
  do {
    *cp++ = "0123456789ABCDEF"[(int)(n % b)];
  } while ((n = n / b & 0x0FFFFFFF) != 0);
  do {
    putchar(*--cp);
  } while (cp > prbuf);
}


x86 assembly (clang, -O0):
<printknu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
movslq %edx,%rcx
lea    0xec8(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
and    $0xfffffff,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jne    1126 <printknu+0x16>
jmp    116a <printknu+0x5a>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x28(%rbp)
movsbl -0x1(%rax),%edi
call   1030 <putchar@plt>
mov    -0x28(%rbp),%rax
lea    -0x20(%rbp),%rcx
cmp    %rcx,%rax
ja     116a <printknu+0x5a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printknu>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%eax
mov    %rsp,%rbx
lea    0xedd(%rip),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edx,%edx
div    %esi
movslq %edx,%rdx
movzbl (%rdx,%rcx,1),%edx
mov    %dl,(%rbx)
add    $0x1,%rbx
and    $0xfffffff,%eax
jne    1130 <printknu+0x20>
mov    %rsp,%r14
nopl   0x0(%rax,%rax,1)
movsbl -0x1(%rbx),%edi
add    $0xffffffffffffffff,%rbx
call   1030 <putchar@plt>
cmp    %r14,%rbx
ja     1150 <printknu+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"0123456789ABCDEF\00"
define void @printknu(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [24 x i8]
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
store i8* %7, i8** %6
br label %8
8: ; preds = %17, %2
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = urem i32 %9, %10
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %6
store i8 %14, i8* %15
br label %17
17: ; preds = %8
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = udiv i32 %18, %19
%21 = and i32 %20, 268435455
store i32 %21, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %8, label %23
23: ; preds = %17
br label %24
24: ; preds = %29, %23
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i32 -1
store i8* %26, i8** %6
%27 = load i8, i8* %26
%28 = call i32 @putchar(i8 signext %27)
br label %29
29: ; preds = %24
%30 = load i8*, i8** %6
%31 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
%32 = icmp ugt i8* %30, %31
br i1 %32, label %24, label %33
33: ; preds = %29
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789ABCDEF\00"
define void @printknu(i32 %0, i32 %1) {
%3 = alloca [24 x i8]
%4 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %5, %2
%6 = phi i32 [ %0, %2 ], [ %14, %5 ]
%7 = phi i8* [ %4, %2 ], [ %12, %5 ]
%8 = urem i32 %6, %1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [17 x i8], [17 x i8]* @.str, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %11, i8* %7
%13 = udiv i32 %6, %1
%14 = and i32 %13, 268435455
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %5, %16
%17 = phi i8* [ %18, %16 ], [ %12, %5 ]
%18 = getelementptr inbounds i8, i8* %17, i64 -1
%19 = load i8, i8* %18
%20 = call i32 @putchar(i8 signext %19)
%21 = icmp ugt i8* %18, %4
br i1 %21, label %16, label %22
22: ; preds = %16
ret void
}