#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_10_to_2(char *, char *);
int /*<<< orphan*/ convert_2_to_10(char *, char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int main(void) {
  char str_buffer[64];
  puts(convert_2_to_10("1000.10011", str_buffer));
  puts(convert_2_to_10("-100001.0011101", str_buffer));
  puts(convert_10_to_2("111.111", str_buffer));
  puts(convert_10_to_2("-101.101", str_buffer));
  puts(convert_2_to_10("111", str_buffer));
  puts(convert_2_to_10("10.111", str_buffer));
  char input_buffer[64];
  printf("Enter number to convert from base 2 to 10: ");
  gets(input_buffer);
  puts(convert_2_to_10(input_buffer, str_buffer));
  printf("\nEnter number to convert from base 10 to 2: ");
  gets(input_buffer);
  puts(convert_10_to_2(input_buffer, str_buffer));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1070 <convert_10_to_2@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1070 <convert_10_to_2@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rsi
lea    0xe4c(%rip),%rdi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <convert_10_to_2@plt>
mov    %eax,%edi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xe9f(%rip),%rdi
lea    0x40(%rsp),%r14
mov    %r14,%rsi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
mov    %r14,%rsi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe89(%rip),%rdi
mov    %r14,%rsi
call   1070 <convert_10_to_2@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
mov    %r14,%rsi
call   1070 <convert_10_to_2@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe71(%rip),%rdi
mov    %r14,%rsi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe58(%rip),%rdi
mov    %r14,%rsi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <convert_2_to_10@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <convert_10_to_2@plt>
mov    %eax,%edi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1000.10011\00"
@.str.1 = [16 x i8] c"-100001.0011101\00"
@.str.2 = [8 x i8] c"111.111\00"
@.str.3 = [9 x i8] c"-101.101\00"
@.str.4 = [4 x i8] c"111\00"
@.str.5 = [7 x i8] c"10.111\00"
@.str.6 = [44 x i8] c"Enter number to convert from base 2 to 10: \00"
@.str.7 = [45 x i8] c"\0AEnter number to convert from base 10 to 2: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @puts(i32 %5)
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%8 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @puts(i32 %8)
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%11 = call i32 @convert_10_to_2(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i32 @puts(i32 %11)
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%14 = call i32 @convert_10_to_2(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = call i32 @puts(i32 %14)
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%17 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%18 = call i32 @puts(i32 %17)
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%20 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = call i32 @puts(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%24 = call i32 @gets(i8* %23)
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%27 = call i32 @convert_2_to_10(i8* %25, i8* %26)
%28 = call i32 @puts(i32 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%31 = call i32 @gets(i8* %30)
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%34 = call i32 @convert_10_to_2(i8* %32, i8* %33)
%35 = call i32 @puts(i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"1000.10011\00"
@.str.1 = [16 x i8] c"-100001.0011101\00"
@.str.2 = [8 x i8] c"111.111\00"
@.str.3 = [9 x i8] c"-101.101\00"
@.str.4 = [4 x i8] c"111\00"
@.str.5 = [7 x i8] c"10.111\00"
@.str.6 = [44 x i8] c"Enter number to convert from base 2 to 10: \00"
@.str.7 = [45 x i8] c"\0AEnter number to convert from base 10 to 2: \00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @puts(i32 %4)
%6 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @puts(i32 %6)
%8 = call i32 @convert_10_to_2(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%9 = call i32 @puts(i32 %8)
%10 = call i32 @convert_10_to_2(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%11 = call i32 @puts(i32 %10)
%12 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%13 = call i32 @puts(i32 %12)
%14 = call i32 @convert_2_to_10(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%15 = call i32 @puts(i32 %14)
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @gets(i8* %16)
%19 = call i32 @convert_2_to_10(i8* %16, i8* %3)
%20 = call i32 @puts(i32 %19)
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @gets(i8* %16)
%23 = call i32 @convert_10_to_2(i8* %16, i8* %3)
%24 = call i32 @puts(i32 %23)
ret i32 0
}