#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*/ printf(char *, unsigned int);
void outnum(int num, int radix) {
  unsigned val;
  val = (unsigned)num;
  if (radix == 8)
    printf("%06o", val);
  else if (radix == 10)
    printf("%05u", val);
  else if (radix == 16)
    printf("%04x", val);
  else if (radix == 7) {
    printf("%03o", val);
  }
}


x86 assembly (clang, -O0):
<outnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x8,-0x8(%rbp)
jne    1142 <outnum+0x32>
mov    -0xc(%rbp),%esi
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
jmp    11a6 <outnum+0x96>
cmpl   $0xa,-0x8(%rbp)
jne    1160 <outnum+0x50>
mov    -0xc(%rbp),%esi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <outnum+0x91>
cmpl   $0x10,-0x8(%rbp)
jne    117e <outnum+0x6e>
mov    -0xc(%rbp),%esi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <outnum+0x8c>
cmpl   $0x7,-0x8(%rbp)
jne    1197 <outnum+0x87>
mov    -0xc(%rbp),%esi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <outnum+0x8c>
jmp    11a1 <outnum+0x91>
jmp    11a6 <outnum+0x96>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outnum>:
add    $0xfffffff9,%esi
cmp    $0x9,%esi
ja     1122 <outnum+0x12>
mov    $0x20b,%ecx
bt     %esi,%ecx
jb     1123 <outnum+0x13>
ret
mov    %edi,%eax
movslq %esi,%rcx
lea    0xee5(%rip),%rdx
movslq (%rdx,%rcx,4),%rdi
add    %rdx,%rdi
mov    %eax,%esi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%06o\00"
@.str.1 = [5 x i8] c"%05u\00"
@.str.2 = [5 x i8] c"%04x\00"
@.str.3 = [5 x i8] c"%03o\00"
define void @outnum(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
store i32 %6, i32* %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 8
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %5
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %33
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 10
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %32
18: ; preds = %12
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 16
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %31
24: ; preds = %18
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 7
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %5
%29 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %30, %21
br label %32
32: ; preds = %31, %15
br label %33
33: ; preds = %32, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%06o\00"
@.str.1 = [5 x i8] c"%05u\00"
@.str.2 = [5 x i8] c"%04x\00"
@.str.3 = [5 x i8] c"%03o\00"
@reltable.outnum = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.outnum to i64)) to i32)]
define void @outnum(i32 %0, i32 %1) {
%3 = add i32 %1, -7
%4 = icmp ult i32 %3, 10
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = trunc i32 %3 to i16
%7 = lshr i16 523, %6
%8 = and i16 %7, 1
%9 = icmp eq i16 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = sext i32 %3 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.outnum to i8*), i64 %12)
%14 = tail call i32 @printf(i8* %13, i32 %0)
br label %15
15: ; preds = %5, %2, %10
ret void
}