#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*/ bin2dec(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char input[100];
  char *i = input;
  printf("Please enter a binary number %c ", 16);
  fgets(i, 100, stdin);
  printf("\n\nThat is in fact ");
  bin2dec(i);
  puts(" in decimal.");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    0xe8f(%rip),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x78(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x78(%rbp),%rdi
call   1040 <bin2dec@plt>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xea4(%rip),%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <bin2dec@plt>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Please enter a binary number %c \00"
@stdin = global i32 0
@.str.1 = [19 x i8] c"\0A\0AThat is in fact \00"
@.str.2 = [13 x i8] c" in decimal.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8* %4, i8** %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 16)
%6 = load i8*, i8** %3
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 100, i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = load i8*, i8** %3
%11 = call i32 @bin2dec(i8* %10)
%12 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Please enter a binary number %c \00"
@stdin = global i32 0
@.str.1 = [19 x i8] c"\0A\0AThat is in fact \00"
@.str.2 = [13 x i8] c" in decimal.\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 16)
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 100, i32 %4)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @bin2dec(i8* %2)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (...) @getchar()
ret i32 0
}