#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*/ convert(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, base;
  printf("Enter number to be converted: ");
  scanf("%d", &num);
  printf("Enter base: ");
  scanf("%d", &base);
  if (num < 0 || base < 0 || base > 16) {
    printf("Error\n");
    return -1;
  }
  convert(num, base);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1195 <main+0x65>
cmpl   $0x0,-0xc(%rbp)
jl     1195 <main+0x65>
cmpl   $0x10,-0xc(%rbp)
jle    11ad <main+0x7d>
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <main+0x94>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <convert@plt>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
call   1060 <printf@plt>
lea    0xeb7(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xea6(%rip),%rdi
call   1060 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
js     11b6 <main+0x66>
mov    0x8(%rsp),%esi
test   %esi,%esi
js     11b6 <main+0x66>
cmp    $0x11,%esi
jge    11b6 <main+0x66>
call   1040 <convert@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
jmp    11c7 <main+0x77>
lea    0xe72(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter number to be converted: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Enter base: \00"
@.str.3 = [7 x i8] c"Error\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 16
br i1 %15, label %16, label %18
16: ; preds = %13, %10, %0
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %23
18: ; preds = %13
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 @convert(i32 %19, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %18, %16
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [31 x i8] c"Enter number to be converted: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"Enter base: \00"
@str = [6 x i8] c"Error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
%13 = select i1 %10, i1 true, i1 %12
%14 = icmp sgt i32 %11, 16
%15 = select i1 %13, i1 true, i1 %14
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %21
18: ; preds = %0
%19 = call i32 @convert(i32 %9, i32 %11)
%20 = call i32 @putchar(i32 10)
br label %21
21: ; preds = %18, %16
%22 = phi i32 [ -1, %16 ], [ 0, %18 ]
ret i32 %22
}