#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*/ bintodec();
int /*<<< orphan*/ dectobin();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int choice;
  printf("\n1) To convert a binary number to decimal");
  printf("\n2) To convert a decimal number to binary");
  printf("\nEnter 1 or 2: ");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    bintodec();
    break;
  case 2:
    dectobin();
    break;
  default:
    printf("\nInvalid Choice");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     11a8 <main+0x68>
jmp    1197 <main+0x57>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     11b4 <main+0x74>
jmp    11c0 <main+0x80>
mov    $0x0,%al
call   1040 <bintodec@plt>
jmp    11cc <main+0x8c>
mov    $0x0,%al
call   1050 <dectobin@plt>
jmp    11cc <main+0x8c>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     118d <main+0x4d>
cmp    $0x1,%eax
jne    1196 <main+0x56>
xor    %eax,%eax
call   1040 <bintodec@plt>
jmp    11a2 <main+0x62>
xor    %eax,%eax
call   1050 <dectobin@plt>
jmp    11a2 <main+0x62>
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"\0A1) To convert a binary number to decimal\00"
@.str.1 = [42 x i8] c"\0A2) To convert a decimal number to binary\00"
@.str.2 = [16 x i8] c"\0AEnter 1 or 2: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [16 x i8] c"\0AInvalid Choice\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
switch i32 %7, label %12 [
i32 1, label %8
i32 2, label %10
]
8: ; preds = %0
%9 = call i32 (...) @bintodec()
br label %14
10: ; preds = %0
%11 = call i32 (...) @dectobin()
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %10, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"\0A1) To convert a binary number to decimal\00"
@.str.1 = [42 x i8] c"\0A2) To convert a decimal number to binary\00"
@.str.2 = [16 x i8] c"\0AEnter 1 or 2: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [16 x i8] c"\0AInvalid Choice\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
switch i32 %7, label %12 [
i32 1, label %8
i32 2, label %10
]
8: ; preds = %0
%9 = call i32 (...) @bintodec()
br label %14
10: ; preds = %0
%11 = call i32 (...) @dectobin()
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %10, %8
ret i32 0
}