#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_putui(unsigned int num) {
  char buffer[128];
  int position = 126;
  unsigned int temp = num;
  if (num == 0) {
    os_puts("0");
    return;
  }
  buffer[127] = 0;
  while (temp > 0) {
    buffer[position--] = '0' + (temp % 10);
    temp = temp / 10;
  }
  os_puts(buffer + position + 1);
}


x86 assembly (clang, -O0):
<supcon_putui>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x7e,-0x94(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x98(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    114c <supcon_putui+0x3c>
lea    0xebe(%rip),%rdi
call   1030 <os_puts@plt>
jmp    11bf <supcon_putui+0xaf>
movb   $0x0,-0x11(%rbp)
cmpl   $0x0,-0x98(%rbp)
jbe    11a5 <supcon_putui+0x95>
mov    -0x98(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
add    $0x30,%edx
mov    %dl,%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
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x98(%rbp)
jmp    1150 <supcon_putui+0x40>
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_putui>:
test   %edi,%edi
je     1184 <supcon_putui+0x74>
sub    $0x88,%rsp
movb   $0x0,0x7f(%rsp)
lea    0x7e(%rsp),%rcx
movabs $0x7e00000000,%rax
mov    $0xcccccccd,%r8d
movabs $0xffffffff00000000,%r9
ff ff ff
nop
add    %r9,%rax
mov    %edi,%edx
imul   %r8,%rdx
shr    $0x23,%rdx
lea    (%rdx,%rdx,1),%esi
lea    (%rsi,%rsi,4),%r10d
mov    %edi,%esi
sub    %r10d,%esi
or     $0x30,%sil
mov    %sil,(%rcx)
add    $0xffffffffffffffff,%rcx
cmp    $0x9,%edi
mov    %edx,%edi
ja     1140 <supcon_putui+0x30>
sar    $0x20,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x1,%rdi
call   1030 <os_puts@plt>
add    $0x88,%rsp
ret
lea    0xe75(%rip),%rdi
jmp    1030 <os_puts@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
define void @supcon_putui(i32 %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @os_puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
7: ; preds = %1
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 127
store i8 0, i8* %8
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 126, %7 ], [ %15, %9 ]
%11 = phi i32 [ %0, %7 ], [ %17, %9 ]
%12 = urem i32 %11, 10
%13 = trunc i32 %12 to i8
%14 = or i8 %13, 48
%15 = add i64 %10, -1
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %10
store i8 %14, i8* %16
%17 = udiv i32 %11, 10
%18 = icmp ult i32 %11, 10
br i1 %18, label %19, label %9
19: ; preds = %9
%20 = shl i64 %15, 32
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %21
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = call i32 @os_puts(i8* %23)
br label %25
25: ; preds = %19, %5
ret void
}