#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*/ exit(int);
int /*<<< orphan*/ getch();
char getchar();
int powerfunc(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int d[20];
  int i, n, f, dec;
  int decimalno = 0;
  int j = 0;
  printf("Enter the number of bit places to be calculated:\n");
  scanf("%d", &n);
  while (getchar() != '\n')
    continue;
  printf("Enter the binary number, one digit at a time\n\twhile pressing "
         "'Enter' after each digit has been entered.\n");
  for (i = 0; i = 0; i--) {
    dec = (d[i] * powerfunc(2, j)) + decimalno;
    j++;
  }
  printf("The number you've just entered, in binary is: %d", decimalno);
  getch();
  exit(2351345);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf34(%rip),%rdi
lea    -0x68(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11b6 <main+0x56>
jmp    119e <main+0x3e>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x64(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    11e1 <main+0x81>
jmp    121e <main+0xbe>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x78(%rbp),%esi
mov    $0x2,%edi
call   1050 <powerfunc@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
imul   %ecx,%eax
add    -0x74(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
jmp    11cb <main+0x6b>
mov    -0x74(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    $0x23e0f1,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1180 <main+0x20>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe62(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <getch@plt>
mov    $0x23e0f1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"Enter the number of bit places to be calculated:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [105 x i8] c"Enter the binary number, one digit at a time\0A\09while pressing 'Enter' after each digit has been entered.\0A\00"
@.str.3 = [49 x i8] c"The number you've just entered, in binary is: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %11
11: ; preds = %15, %0
%12 = call signext i8 (...) @getchar()
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %11
br label %11
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %18
18: ; preds = %31, %16
store i32 0, i32* %3
br i1 false, label %19, label %34
19: ; preds = %18
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = load i32, i32* %8
%25 = call i32 @powerfunc(i32 2, i32 %24)
%26 = mul nsw i32 %23, %25
%27 = load i32, i32* %7
%28 = add nsw i32 %26, %27
store i32 %28, i32* %6
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %31
31: ; preds = %19
%32 = load i32, i32* %3
%33 = add nsw i32 %32, -1
store i32 %33, i32* %3
br label %18
34: ; preds = %18
%35 = load i32, i32* %7
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = call i32 (...) @getch()
%38 = call i32 @exit(i32 2351345)
unreachable
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [49 x i8] c"The number you've just entered, in binary is: %d\00"
@str = [49 x i8] c"Enter the number of bit places to be calculated:\00"
@str.4 = [104 x i8] c"Enter the binary number, one digit at a time\0A\09while pressing 'Enter' after each digit has been entered.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
5: ; preds = %5, %0
%6 = call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %8, label %5
8: ; preds = %5
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([104 x i8], [104 x i8]* @str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 0)
%11 = call i32 (...) @getch()
%12 = call i32 @exit(i32 2351345)
unreachable
}