#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void supcon_putp(unsigned int num, char offset) {
  char buffer[128];
  int position = 126;
  unsigned int temp = num;
  int value;
  if (num == 0) {
    fputs("0", stdout);
    return;
  }
  buffer[127] = 0;
  while (temp > 0) {
    value = temp % 16;
    if (value < 10)
      buffer[position--] = '0' + value;
    else
      buffer[position--] = offset - 10 + value;
    temp = temp / 16;
  }
  fputs(buffer + position + 1, stdout);
}


x86 assembly (clang, -O0):
<supcon_putp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x7e,-0x94(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x98(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    115b <supcon_putp+0x4b>
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1030 <fputs@plt>
jmp    1212 <supcon_putp+0x102>
movb   $0x0,-0x11(%rbp)
cmpl   $0x0,-0x98(%rbp)
jbe    11ef <supcon_putp+0xdf>
mov    -0x98(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x9c(%rbp)
cmpl   $0xa,-0x9c(%rbp)
jge    11b2 <supcon_putp+0xa2>
mov    -0x9c(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x94(%rbp),%eax
mov    %eax,%edx
add    $0xffffffff,%edx
mov    %edx,-0x94(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
jmp    11db <supcon_putp+0xcb>
movsbl -0x5(%rbp),%eax
sub    $0xa,%eax
add    -0x9c(%rbp),%eax
mov    %al,%cl
mov    -0x94(%rbp),%eax
mov    %eax,%edx
add    $0xffffffff,%edx
mov    %edx,-0x94(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0x98(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x98(%rbp)
jmp    115f <supcon_putp+0x4f>
lea    -0x90(%rbp),%rdi
movslq -0x94(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<supcon_putp>:
sub    $0x88,%rsp
test   %edi,%edi
je     117f <supcon_putp+0x6f>
mov    %edi,%eax
lea    0x7f(%rsp),%rdi
movb   $0x0,0x7f(%rsp)
movzbl %sil,%r8d
add    $0xf6,%r8d
mov    %eax,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%esi
and    $0xf,%esi
lea    0x30(%rsi),%r9d
lea    (%r8,%rsi,1),%ecx
cmp    $0xa,%esi
movzbl %r9b,%esi
cmovae %ecx,%esi
mov    %sil,-0x1(%rdi)
add    $0xffffffffffffffff,%rdi
shr    $0x4,%edx
cmp    $0xf,%eax
mov    %edx,%eax
ja     1140 <supcon_putp+0x30>
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
add    $0x88,%rsp
ret
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
lea    0xe71(%rip),%rdi
add    $0x88,%rsp
jmp    1030 <fputs@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@stdout = global i32 0
define void @supcon_putp(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca [128 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
store i32 126, i32* %6
%9 = load i32, i32* %3
store i32 %9, i32* %7
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stdout
%14 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %55
15: ; preds = %2
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 127
store i8 0, i8* %16
br label %17
17: ; preds = %44, %15
%18 = load i32, i32* %7
%19 = icmp ugt i32 %18, 0
br i1 %19, label %20, label %47
20: ; preds = %17
%21 = load i32, i32* %7
%22 = urem i32 %21, 16
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = load i32, i32* %8
%27 = add nsw i32 48, %26
%28 = trunc i32 %27 to i8
%29 = load i32, i32* %6
%30 = add nsw i32 %29, -1
store i32 %30, i32* %6
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %31
store i8 %28, i8* %32
br label %44
33: ; preds = %20
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = sub nsw i32 %35, 10
%37 = load i32, i32* %8
%38 = add nsw i32 %36, %37
%39 = trunc i32 %38 to i8
%40 = load i32, i32* %6
%41 = add nsw i32 %40, -1
store i32 %41, i32* %6
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %42
store i8 %39, i8* %43
br label %44
44: ; preds = %33, %25
%45 = load i32, i32* %7
%46 = udiv i32 %45, 16
store i32 %46, i32* %7
br label %17
47: ; preds = %17
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = load i32, i32* @stdout
%54 = call i32 @fputs(i8* %52, i32 %53)
br label %55
55: ; preds = %47, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
@stdout = global i32 0
define void @supcon_putp(i32 %0, i8 signext %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stdout
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %34
9: ; preds = %2
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 127
store i8 0, i8* %10
%11 = zext i8 %1 to i32
%12 = add nuw nsw i32 %11, 246
br label %13
13: ; preds = %9, %13
%14 = phi i64 [ 126, %9 ], [ %24, %13 ]
%15 = phi i32 [ %0, %9 ], [ %25, %13 ]
%16 = and i32 %15, 15
%17 = icmp ult i32 %16, 10
%18 = trunc i32 %16 to i8
%19 = or i8 %18, 48
%20 = add nuw nsw i32 %12, %16
%21 = trunc i32 %20 to i8
%22 = select i1 %17, i8 %19, i8 %21
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %14
store i8 %22, i8* %23
%24 = add nsw i64 %14, -1
%25 = lshr i32 %15, 4
%26 = icmp ult i32 %15, 16
br i1 %26, label %27, label %13
27: ; preds = %13
%28 = shl i64 %24, 32
%29 = ashr exact i64 %28, 32
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* %31, i32 %32)
br label %34
34: ; preds = %27, %6
ret void
}