#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 convert(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char myinput[16];
  char a[4], b[4], c[4], d[3], e[1];
  printf("Please input a binary number:\n");
  scanf("%s", myinput);
  for (int i1 = 0; i1 < 4; i1++) {
    a[i1] = myinput[i1];
    b[i1] = myinput[i1 + 4];
    c[i1] = myinput[i1 + 4 + 4];
  }
  for (int i1 = 0; i1 < 3; i1++)
    d[i1] = myinput[i1 + 4 + 4 + 4];
  e[0] = myinput[4 + 4 + 4 + 3];
  printf("%d\n%d\n%d\n%d\n%d", convert(a, 4), convert(b, 4), convert(c, 4),
         convert(d, 3), convert(e, 1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xec7(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11b7 <main+0x87>
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,1),%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x24(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x4,%eax
cltq
mov    -0x20(%rbp,%rax,1),%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x28(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x4,%eax
add    $0x4,%eax
cltq
mov    -0x20(%rbp,%rax,1),%cl
movslq -0x34(%rbp),%rax
mov    %cl,-0x2c(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1164 <main+0x34>
movl   $0x0,-0x38(%rbp)
cmpl   $0x3,-0x38(%rbp)
jge    11f0 <main+0xc0>
mov    -0x38(%rbp),%eax
add    $0x4,%eax
add    $0x4,%eax
add    $0x4,%eax
cltq
mov    -0x20(%rbp,%rax,1),%cl
movslq -0x38(%rbp),%rax
mov    %cl,-0x2f(%rbp,%rax,1)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11be <main+0x8e>
mov    -0x11(%rbp),%al
mov    %al,-0x30(%rbp)
lea    -0x24(%rbp),%rdi
mov    $0x4,%esi
call   1030 <convert@plt>
mov    %eax,-0x48(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x4,%esi
call   1030 <convert@plt>
mov    %eax,-0x44(%rbp)
lea    -0x2c(%rbp),%rdi
mov    $0x4,%esi
call   1030 <convert@plt>
mov    %eax,-0x40(%rbp)
lea    -0x2f(%rbp),%rdi
mov    $0x3,%esi
call   1030 <convert@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1030 <convert@plt>
mov    -0x48(%rbp),%esi
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
mov    %eax,%r9d
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
lea    0xea3(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x20(%rsp),%eax
mov    0x24(%rsp),%ecx
mov    %eax,0x1c(%rsp)
mov    %ecx,0x18(%rsp)
mov    0x28(%rsp),%eax
mov    %eax,0x14(%rsp)
movzwl 0x2c(%rsp),%eax
mov    %ax,0x10(%rsp)
mov    0x2e(%rsp),%al
mov    %al,0x12(%rsp)
mov    0x2f(%rsp),%al
mov    %al,0xf(%rsp)
lea    0x1c(%rsp),%rdi
mov    $0x4,%esi
call   1030 <convert@plt>
mov    %eax,%r14d
lea    0x18(%rsp),%rdi
mov    $0x4,%esi
call   1030 <convert@plt>
mov    %eax,%r15d
lea    0x14(%rsp),%rdi
mov    $0x4,%esi
call   1030 <convert@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
call   1030 <convert@plt>
mov    %eax,%ebp
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
call   1030 <convert@plt>
lea    0xe0e(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Please input a binary number:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [15 x i8] c"%d\0A%d\0A%d\0A%d\0A%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [4 x i8]
%4 = alloca [4 x i8]
%5 = alloca [4 x i8]
%6 = alloca [3 x i8]
%7 = alloca [1 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 0, i32* %8
br label %13
13: ; preds = %41, %0
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %44
16: ; preds = %13
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 %30
store i8 %28, i8* %31
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 4
%34 = add nsw i32 %33, 4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %39
store i8 %37, i8* %40
br label %41
41: ; preds = %16
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %13
44: ; preds = %13
store i32 0, i32* %9
br label %45
45: ; preds = %59, %44
%46 = load i32, i32* %9
%47 = icmp slt i32 %46, 3
br i1 %47, label %48, label %62
48: ; preds = %45
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 4
%51 = add nsw i32 %50, 4
%52 = add nsw i32 %51, 4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 %57
store i8 %55, i8* %58
br label %59
59: ; preds = %48
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %45
62: ; preds = %45
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 15
%64 = load i8, i8* %63
%65 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
store i8 %64, i8* %65
%66 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%67 = call i32 @convert(i8* %66, i32 4)
%68 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%69 = call i32 @convert(i8* %68, i32 4)
%70 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%71 = call i32 @convert(i8* %70, i32 4)
%72 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%73 = call i32 @convert(i8* %72, i32 3)
%74 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%75 = call i32 @convert(i8* %74, i32 1)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %67, i32 %69, i32 %71, i32 %73, i32 %75)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [15 x i8] c"%d\0A%d\0A%d\0A%d\0A%d\00"
@str = [30 x i8] c"Please input a binary number:\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [3 x i8]
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%7 = alloca [1 x i8]
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%16 = bitcast [16 x i8]* %1 to i32*
%17 = load i32, i32* %16
store i32 %17, i32* %2
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 4
%19 = bitcast i8* %18 to i32*
%20 = load i32, i32* %19
store i32 %20, i32* %3
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 8
%22 = bitcast i8* %21 to i32*
%23 = load i32, i32* %22
store i32 %23, i32* %4
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 12
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 15
%26 = load i8, i8* %25
store i8 %26, i8* %13
%27 = call i32 @convert(i8* %9, i32 4)
%28 = call i32 @convert(i8* %10, i32 4)
%29 = call i32 @convert(i8* %11, i32 4)
%30 = call i32 @convert(i8* %12, i32 3)
%31 = call i32 @convert(i8* %13, i32 1)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28, i32 %29, i32 %30, i32 %31)
ret i32 0
}