#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 scanf(char *, int *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int i, Code, Reverse = 0;
  for (i = 1; i < argc; i++) {
    if (!strcmp(argv[i], "--reverse"))
      Reverse = 1;
  }
  while (1) {
    printf("Enter an octal code: ");
    if (scanf("%o", &Code) == 1) {
      Code = ~Code;
      if (Reverse) {
        printf("Index=%d CODE1=%03o CODE2=%03o\n", 1 & (Code >> 14),
               (127 & (Code >> 7)) - 1, (127 & (Code)) - 1);
      } else {
        printf("Index=%d CODE1=%03o CODE2=%03o\n", 1 & (Code >> 14),
               (127 & (Code)) - 1, (127 & (Code >> 7)) - 1);
      }
      printf("Index=%d CODE=%02o VALUE=%04o\n", 1 & (Code >> 14),
             (15 & (Code >> 10)), (0x3FF & Code) - 1);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119b <main+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1188 <main+0x58>
movl   $0x1,-0x1c(%rbp)
jmp    118d <main+0x5d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
jmp    11a0 <main+0x70>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1263 <main+0x133>
mov    -0x18(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     120b <main+0xdb>
mov    -0x18(%rbp),%esi
sar    $0xe,%esi
and    $0x1,%esi
mov    -0x18(%rbp),%edx
sar    $0x7,%edx
and    $0x7f,%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%ecx
and    $0x7f,%ecx
sub    $0x1,%ecx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1237 <main+0x107>
mov    -0x18(%rbp),%esi
sar    $0xe,%esi
and    $0x1,%esi
mov    -0x18(%rbp),%edx
and    $0x7f,%edx
sub    $0x1,%edx
mov    -0x18(%rbp),%ecx
sar    $0x7,%ecx
and    $0x7f,%ecx
sub    $0x1,%ecx
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
sar    $0xe,%esi
and    $0x1,%esi
mov    -0x18(%rbp),%edx
sar    $0xa,%edx
and    $0xf,%edx
mov    -0x18(%rbp),%ecx
and    $0x3ff,%ecx
sub    $0x1,%ecx
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a0 <main+0x70>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%bpl
cmp    $0x2,%edi
jl     1181 <main+0x51>
mov    %rsi,%r15
mov    %edi,%r12d
xor    %ebx,%ebx
mov    $0x1,%ebp
lea    0xea9(%rip),%r14
mov    $0x1,%r13d
nopl   (%rax)
mov    (%r15,%rbp,8),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
cmove  %r13d,%ebx
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1160 <main+0x30>
test   %ebx,%ebx
sete   %bpl
lea    0xe82(%rip),%r14
lea    0xe91(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xe88(%rip),%r12
lea    0xea1(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11b0 <main+0x80>
mov    0x4(%rsp),%eax
not    %eax
mov    %eax,0x4(%rsp)
mov    %eax,%esi
shr    $0xe,%esi
and    $0x1,%esi
mov    %eax,%edx
shr    $0x7,%edx
test   %bpl,%bpl
mov    %eax,%ecx
cmovne %edx,%ecx
cmovne %eax,%edx
and    $0x7f,%edx
add    $0xffffffff,%edx
and    $0x7f,%ecx
add    $0xffffffff,%ecx
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%ecx
mov    %ecx,%esi
shr    $0xe,%esi
and    $0x1,%esi
mov    %ecx,%edx
shr    $0xa,%edx
and    $0xf,%edx
and    $0x3ff,%ecx
add    $0xffffffff,%ecx
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11b0 <main+0x80>

LLVM IR (-O0):
@.str = [10 x i8] c"--reverse\00"
@.str.1 = [22 x i8] c"Enter an octal code: \00"
@.str.2 = [3 x i8] c"%o\00"
@.str.3 = [32 x i8] c"Index=%d CODE1=%03o CODE2=%03o\0A\00"
@.str.4 = [31 x i8] c"Index=%d CODE=%02o VALUE=%04o\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 1, i32* %6
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %13
store i32 1, i32* %8
br label %22
22: ; preds = %21, %13
br label %23
23: ; preds = %22
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %9
26: ; preds = %9
br label %27
27: ; preds = %26, %71
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %71
31: ; preds = %27
%32 = load i32, i32* %7
%33 = xor i32 %32, -1
store i32 %33, i32* %7
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %48
36: ; preds = %31
%37 = load i32, i32* %7
%38 = ashr i32 %37, 14
%39 = and i32 1, %38
%40 = load i32, i32* %7
%41 = ashr i32 %40, 7
%42 = and i32 127, %41
%43 = sub nsw i32 %42, 1
%44 = load i32, i32* %7
%45 = and i32 127, %44
%46 = sub nsw i32 %45, 1
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %39, i32 %43, i32 %46)
br label %60
48: ; preds = %31
%49 = load i32, i32* %7
%50 = ashr i32 %49, 14
%51 = and i32 1, %50
%52 = load i32, i32* %7
%53 = and i32 127, %52
%54 = sub nsw i32 %53, 1
%55 = load i32, i32* %7
%56 = ashr i32 %55, 7
%57 = and i32 127, %56
%58 = sub nsw i32 %57, 1
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %51, i32 %54, i32 %58)
br label %60
60: ; preds = %48, %36
%61 = load i32, i32* %7
%62 = ashr i32 %61, 14
%63 = and i32 1, %62
%64 = load i32, i32* %7
%65 = ashr i32 %64, 10
%66 = and i32 15, %65
%67 = load i32, i32* %7
%68 = and i32 1023, %67
%69 = sub nsw i32 %68, 1
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %63, i32 %66, i32 %69)
br label %71
71: ; preds = %60, %27
br label %27
}

LLVM IR (-O2):
@.str = [10 x i8] c"--reverse\00"
@.str.1 = [22 x i8] c"Enter an octal code: \00"
@.str.2 = [3 x i8] c"%o\00"
@.str.3 = [32 x i8] c"Index=%d CODE1=%03o CODE2=%03o\0A\00"
@.str.4 = [31 x i8] c"Index=%d CODE=%02o VALUE=%04o\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %12
8: ; preds = %12
%9 = icmp eq i32 %19, 0
br label %10
10: ; preds = %8, %2
%11 = phi i1 [ true, %2 ], [ %9, %8 ]
br label %22
12: ; preds = %6, %12
%13 = phi i64 [ 1, %6 ], [ %20, %12 ]
%14 = phi i32 [ 0, %6 ], [ %19, %12 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %13
%16 = load i8*, i8** %15
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 1, i32 %14
%20 = add nuw nsw i64 %13, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %8, label %12
22: ; preds = %47, %10
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %47
26: ; preds = %22
%27 = load i32, i32* %3
%28 = xor i32 %27, -1
store i32 %28, i32* %3
%29 = lshr i32 %28, 14
%30 = and i32 %29, 1
%31 = lshr i32 %28, 7
%32 = select i1 %11, i32 %31, i32 %28
%33 = select i1 %11, i32 %28, i32 %31
%34 = and i32 %33, 127
%35 = add nsw i32 %34, -1
%36 = and i32 %32, 127
%37 = add nsw i32 %36, -1
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %35, i32 %37)
%39 = load i32, i32* %3
%40 = lshr i32 %39, 14
%41 = and i32 %40, 1
%42 = lshr i32 %39, 10
%43 = and i32 %42, 15
%44 = and i32 %39, 1023
%45 = add nsw i32 %44, -1
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %43, i32 %45)
br label %47
47: ; preds = %26, %22
br label %22
}