#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*/ os_puts(char *);
void supcon_putp(unsigned int num, char offset) {
  char buffer[128];
  int position = 126;
  unsigned int temp = num;
  int value;
  if (num == 0) {
    os_puts("0");
    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;
  }
  os_puts(buffer + position + 1);
}


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    1152 <supcon_putp+0x42>
lea    0xeb8(%rip),%rdi
call   1030 <os_puts@plt>
jmp    1200 <supcon_putp+0xf0>
movb   $0x0,-0x11(%rbp)
cmpl   $0x0,-0x98(%rbp)
jbe    11e6 <supcon_putp+0xd6>
mov    -0x98(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x9c(%rbp)
cmpl   $0xa,-0x9c(%rbp)
jge    11a9 <supcon_putp+0x99>
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    11d2 <supcon_putp+0xc2>
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    1156 <supcon_putp+0x46>
lea    -0x90(%rbp),%rdi
movslq -0x94(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1030 <os_puts@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<supcon_putp>:
test   %edi,%edi
je     1179 <supcon_putp+0x69>
sub    $0x88,%rsp
lea    0x7f(%rsp),%rax
movb   $0x0,0x7f(%rsp)
movzbl %sil,%r8d
add    $0xf6,%r8d
mov    %edi,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %edi,%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(%rax)
add    $0xffffffffffffffff,%rax
shr    $0x4,%edx
cmp    $0xf,%edi
mov    %edx,%edi
ja     1140 <supcon_putp+0x30>
mov    %rax,%rdi
call   1030 <os_puts@plt>
add    $0x88,%rsp
ret
lea    0xe80(%rip),%rdi
jmp    1030 <os_puts@plt>

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

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