#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 atoi(char *);
int /*<<< orphan*/ getlinee(char *, int);
int /*<<< orphan*/ itob(int, char *, int);
int /*<<< orphan*/ printf(char *);
void prog() {
  int n;
  int b;
  char n_str[100];
  char b_str[100];
  char str[100];
  printf("Enter the number n\n");
  getlinee(n_str, 100);
  n = atoi(n_str);
  printf("Enter the base b\n");
  getlinee(b_str, 100);
  b = atoi(b_str);
  switch (b) {
  case 2:
    itob(n, str, 2);
    break;
  case 8:
    itob(n, str, 8);
    break;
  case 10:
    itob(n, str, 10);
    break;
  case 16:
    itob(n, str, 16);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<prog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
lea    0xeea(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    %rdi,-0x170(%rbp)
mov    $0x64,%esi
mov    %esi,-0x164(%rbp)
call   1060 <getlinee@plt>
mov    -0x170(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x164(%rbp),%esi
lea    -0xe0(%rbp),%rdi
mov    %rdi,-0x160(%rbp)
call   1060 <getlinee@plt>
mov    -0x160(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x158(%rbp)
sub    $0xe,%eax
ja     1248 <prog+0x108>
mov    -0x158(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0x2,%edx
call   1040 <itob@plt>
jmp    124d <prog+0x10d>
mov    -0x4(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0x8,%edx
call   1040 <itob@plt>
jmp    124d <prog+0x10d>
mov    -0x4(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0xa,%edx
call   1040 <itob@plt>
jmp    124d <prog+0x10d>
mov    -0x4(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0x10,%edx
call   1040 <itob@plt>
jmp    124d <prog+0x10d>
jmp    124d <prog+0x10d>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prog>:
push   %rbp
push   %rbx
sub    $0x148,%rsp
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <getlinee@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <getlinee@plt>
mov    %rbx,%rdi
call   1050 <atoi@plt>
add    $0xfffffffe,%eax
ror    %eax
cmp    $0x7,%eax
ja     11c4 <prog+0x84>
mov    $0x99,%ecx
bt     %eax,%ecx
jae    11c4 <prog+0x84>
cltq
lea    0xe6d(%rip),%rcx
mov    (%rcx,%rax,4),%edx
mov    %rsp,%rsi
mov    %ebp,%edi
call   1040 <itob@plt>
add    $0x148,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter the number n\0A\00"
@.str.1 = [18 x i8] c"Enter the base b\0A\00"
define void @prog() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 @getlinee(i8* %7, i32 100)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = call i32 @atoi(i8* %9)
store i32 %10, i32* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = call i32 @getlinee(i8* %12, i32 100)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
switch i32 %16, label %33 [
i32 2, label %17
i32 8, label %21
i32 10, label %25
i32 16, label %29
]
17: ; preds = %0
%18 = load i32, i32* %1
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%20 = call i32 @itob(i32 %18, i8* %19, i32 2)
br label %34
21: ; preds = %0
%22 = load i32, i32* %1
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%24 = call i32 @itob(i32 %22, i8* %23, i32 8)
br label %34
25: ; preds = %0
%26 = load i32, i32* %1
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%28 = call i32 @itob(i32 %26, i8* %27, i32 10)
br label %34
29: ; preds = %0
%30 = load i32, i32* %1
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%32 = call i32 @itob(i32 %30, i8* %31, i32 16)
br label %34
33: ; preds = %0
br label %34
34: ; preds = %33, %29, %25, %21, %17
ret void
}

LLVM IR (-O2):
@str = [19 x i8] c"Enter the number n\00"
@str.2 = [17 x i8] c"Enter the base b\00"
@switch.table.prog = [8 x i32] [i32 2, i32 2, i32 2, i32 8, i32 10, i32 2, i32 2, i32 16]
define void @prog() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = call i32 @getlinee(i8* %4, i32 100)
%9 = call i32 @atoi(i8* %4)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.2, i64 0, i64 0))
%11 = call i32 @getlinee(i8* %5, i32 100)
%12 = call i32 @atoi(i8* %5)
%13 = add i32 %12, -2
%14 = call i32 @llvm.fshl.i32(i32 %13, i32 %13, i32 31)
%15 = icmp ult i32 %14, 8
br i1 %15, label %16, label %26
16: ; preds = %0
%17 = trunc i32 %14 to i8
%18 = lshr i8 -103, %17
%19 = and i8 %18, 1
%20 = icmp eq i8 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = sext i32 %14 to i64
%23 = getelementptr inbounds [8 x i32], [8 x i32]* @switch.table.prog, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = call i32 @itob(i32 %9, i8* %6, i32 %24)
br label %26
26: ; preds = %16, %0, %21
ret void
}