#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*/ bintooct();
char getch();
int /*<<< orphan*/ octtobin();
int /*<<< orphan*/ printf(char *);
int main(void) {
  printf("1 - Bin to Oct\n");
  printf("2 - Oct to Bin\n");
  printf("Enter your choice: \n> ");
  char ch = getch();
  switch (ch) {
  case '1':
    bintooct();
    break;
  case '2':
    octtobin();
    break;
  default:
    printf("Please enter appropriate 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    0xeae(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x31,%eax
je     11a3 <main+0x63>
jmp    1192 <main+0x52>
mov    -0xc(%rbp),%eax
sub    $0x32,%eax
je     11af <main+0x6f>
jmp    11bb <main+0x7b>
mov    $0x0,%al
call   1050 <bintooct@plt>
jmp    11c7 <main+0x87>
mov    $0x0,%al
call   1040 <octtobin@plt>
jmp    11c7 <main+0x87>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <getch@plt>
movsbl %al,%eax
cmp    $0x32,%eax
je     1192 <main+0x42>
cmp    $0x31,%eax
jne    119b <main+0x4b>
xor    %eax,%eax
call   1060 <bintooct@plt>
jmp    11a7 <main+0x57>
xor    %eax,%eax
call   1050 <octtobin@plt>
jmp    11a7 <main+0x57>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"1 - Bin to Oct\0A\00"
@.str.1 = [16 x i8] c"2 - Oct to Bin\0A\00"
@.str.2 = [23 x i8] c"Enter your choice: \0A> \00"
@.str.3 = [32 x i8] c"Please enter appropriate choice\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%6 = call signext i8 (...) @getch()
store i8 %6, i8* %2
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
switch i32 %8, label %13 [
i32 49, label %9
i32 50, label %11
]
9: ; preds = %0
%10 = call i32 (...) @bintooct()
br label %15
11: ; preds = %0
%12 = call i32 (...) @octtobin()
br label %15
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %13, %11, %9
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [23 x i8] c"Enter your choice: \0A> \00"
@.str.3 = [32 x i8] c"Please enter appropriate choice\00"
@str = [15 x i8] c"1 - Bin to Oct\00"
@str.4 = [15 x i8] c"2 - Oct to Bin\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call signext i8 (...) @getch()
%5 = sext i8 %4 to i32
switch i32 %5, label %10 [
i32 49, label %6
i32 50, label %8
]
6: ; preds = %0
%7 = tail call i32 (...) @bintooct()
br label %12
8: ; preds = %0
%9 = tail call i32 (...) @octtobin()
br label %12
10: ; preds = %0
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %8, %6
ret i32 0
}