#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int input;
  int flag = 0, o1, o2, o3, b1, b2, b3;
  do {
    printf("Enter an octal number (0 - 777): ");
    scanf("%d", &input);
    if (input < 0 || input > 777)
      continue;
    o1 = input / 100;
    o2 = (input % 100) / 10;
    o3 = input % 10;
    if (o1 < 8 && o2 < 8 && o3 < 8)
      flag = 1;
  } while (!flag);
  switch (o1) {
  case (1):
    b1 = 1;
    break;
  case (2):
    b1 = 10;
    break;
  case (3):
    b1 = 11;
    break;
  case (4):
    b1 = 100;
    break;
  case (5):
    b1 = 101;
    break;
  case (6):
    b1 = 110;
    break;
  case (7):
    b1 = 111;
    break;
  }
  switch (o2) {
  case (1):
    b2 = 1;
    break;
  case (2):
    b2 = 10;
    break;
  case (3):
    b2 = 11;
    break;
  case (4):
    b2 = 100;
    break;
  case (5):
    b2 = 101;
    break;
  case (6):
    b2 = 110;
    break;
  case (7):
    b2 = 111;
    break;
  }
  switch (o3) {
  case (1):
    b3 = 1;
    break;
  case (2):
    b3 = 10;
    break;
  case (3):
    b3 = 11;
    break;
  case (4):
    b3 = 100;
    break;
  case (5):
    b3 = 101;
    break;
  case (6):
    b3 = 110;
    break;
  case (7):
    b3 = 111;
    break;
  }
  printf("Octal %d%d%d equals binary %03d%03d%03d", o1, o2, o3, b1, b2, b3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xf17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     116b <main+0x4b>
cmpl   $0x309,-0x8(%rbp)
jle    1170 <main+0x50>
jmp    11ce <main+0xae>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    11c9 <main+0xa9>
cmpl   $0x8,-0x14(%rbp)
jge    11c9 <main+0xa9>
cmpl   $0x8,-0x18(%rbp)
jge    11c9 <main+0xa9>
movl   $0x1,-0xc(%rbp)
jmp    11ce <main+0xae>
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1136 <main+0x16>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x6,%eax
ja     1257 <main+0x137>
mov    -0x30(%rbp),%rax
lea    0xe01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x1c(%rbp)
jmp    1257 <main+0x137>
movl   $0xa,-0x1c(%rbp)
jmp    1257 <main+0x137>
movl   $0xb,-0x1c(%rbp)
jmp    1257 <main+0x137>
movl   $0x64,-0x1c(%rbp)
jmp    1257 <main+0x137>
movl   $0x65,-0x1c(%rbp)
jmp    1257 <main+0x137>
movl   $0x6e,-0x1c(%rbp)
jmp    1257 <main+0x137>
movl   $0x6f,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x6,%eax
ja     12cf <main+0x1af>
mov    -0x38(%rbp),%rax
lea    0xda5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x20(%rbp)
jmp    12cf <main+0x1af>
movl   $0xa,-0x20(%rbp)
jmp    12cf <main+0x1af>
movl   $0xb,-0x20(%rbp)
jmp    12cf <main+0x1af>
movl   $0x64,-0x20(%rbp)
jmp    12cf <main+0x1af>
movl   $0x65,-0x20(%rbp)
jmp    12cf <main+0x1af>
movl   $0x6e,-0x20(%rbp)
jmp    12cf <main+0x1af>
movl   $0x6f,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x6,%eax
ja     1347 <main+0x227>
mov    -0x40(%rbp),%rax
lea    0xd49(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x24(%rbp)
jmp    1347 <main+0x227>
movl   $0xa,-0x24(%rbp)
jmp    1347 <main+0x227>
movl   $0xb,-0x24(%rbp)
jmp    1347 <main+0x227>
movl   $0x64,-0x24(%rbp)
jmp    1347 <main+0x227>
movl   $0x65,-0x24(%rbp)
jmp    1347 <main+0x227>
movl   $0x6e,-0x24(%rbp)
jmp    1347 <main+0x227>
movl   $0x6f,-0x24(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x24(%rbp),%eax
lea    0xd17(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%r14
lea    0xeeb(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x309,%ecx
ja     1140 <main+0x20>
movzwl %cx,%eax
imul   $0xcccd,%eax,%esi
shr    $0x2,%eax
imul   $0x147b,%eax,%eax
shr    $0x11,%eax
imul   $0x64,%eax,%eax
mov    %ecx,%edx
sub    %eax,%edx
shr    $0x12,%esi
and    $0xfffffffe,%esi
lea    (%rsi,%rsi,4),%esi
mov    %ecx,%eax
sub    %esi,%eax
cmp    $0x4f,%dx
ja     1140 <main+0x20>
cmp    $0x7,%ax
ja     1140 <main+0x20>
movzwl %cx,%ecx
shr    $0x2,%ecx
imul   $0x147b,%ecx,%esi
shr    $0x11,%esi
movzbl %dl,%ecx
imul   $0xcd,%ecx,%edx
shr    $0xb,%edx
lea    -0x2(%rsi),%ecx
mov    $0x1,%r9d
mov    $0x1,%r8d
cmp    $0x5,%ecx
ja     11d3 <main+0xb3>
movslq %ecx,%rcx
lea    0xe81(%rip),%rdi
mov    (%rdi,%rcx,4),%r8d
movzwl %ax,%ecx
lea    -0x2(%rdx),%eax
cmp    $0x5,%eax
ja     11eb <main+0xcb>
cltq
lea    0xe69(%rip),%rdi
mov    (%rdi,%rax,4),%r9d
lea    -0x2(%rcx),%edi
mov    $0x1,%eax
cmp    $0x5,%edi
ja     1205 <main+0xe5>
movslq %edi,%rax
lea    0xe4e(%rip),%rdi
mov    (%rdi,%rax,4),%eax
mov    %eax,(%rsp)
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [34 x i8] c"Enter an octal number (0 - 777): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [40 x i8] c"Octal %d%d%d equals binary %03d%03d%03d\00"
@switch.table.main.4 = [6 x i32] [i32 10, i32 11, i32 100, i32 101, i32 110, i32 111]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %15, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp ugt i32 %6, 777
br i1 %7, label %15, label %8
8: ; preds = %3
%9 = trunc i32 %6 to i16
%10 = urem i16 %9, 100
%11 = urem i16 %9, 10
%12 = icmp ult i16 %10, 80
%13 = icmp ult i16 %11, 8
%14 = and i1 %12, %13
br i1 %14, label %16, label %15
15: ; preds = %8, %3
br label %3
16: ; preds = %8
%17 = trunc i32 %6 to i16
%18 = udiv i16 %17, 100
%19 = zext i16 %18 to i32
%20 = trunc i16 %10 to i8
%21 = udiv i8 %20, 10
%22 = zext i8 %21 to i32
%23 = zext i16 %11 to i32
%24 = add nsw i32 %19, -2
%25 = icmp ult i32 %24, 6
br i1 %25, label %26, label %30
26: ; preds = %16
%27 = sext i32 %24 to i64
%28 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.main.4, i64 0, i64 %27
%29 = load i32, i32* %28
br label %30
30: ; preds = %26, %16
%31 = phi i32 [ 1, %16 ], [ %29, %26 ]
%32 = add nsw i32 %22, -2
%33 = icmp ult i32 %32, 6
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = sext i32 %32 to i64
%36 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.main.4, i64 0, i64 %35
%37 = load i32, i32* %36
br label %38
38: ; preds = %34, %30
%39 = phi i32 [ 1, %30 ], [ %37, %34 ]
%40 = add nsw i32 %23, -2
%41 = icmp ult i32 %40, 6
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = sext i32 %40 to i64
%44 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.main.4, i64 0, i64 %43
%45 = load i32, i32* %44
br label %46
46: ; preds = %42, %38
%47 = phi i32 [ 1, %38 ], [ %45, %42 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %22, i32 %23, i32 %31, i32 %39, i32 %47)
ret i32 0
}