#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int getBank(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int decompile(int page) {
  unsigned char b[2];
  int value, count = 0;
  FILE *fin, *fout;
  fin = fopen("oct2bin.bin", "r");
  if (fin == NULL) {
    printf("Error: input file oct2bin.bin does not exist.\n");
    return (1);
  }
  fout = fopen("oct2bin.binsource", "w");
  if (fout == NULL) {
    fclose(fin);
    printf("Error: cannot create output file oct2bin.binsource.\n");
    return (1);
  }
  fprintf(fout, "; Copyright: Public domain\n");
  fprintf(fout, "; Filename:  XXXX.binsource\n");
  fprintf(fout, "; Purpose:   XXXX\n");
  fprintf(fout, "; Contact:   info@sandroid.org\n");
  fprintf(fout, "; Mods:      XXXX-XX-XX XXX    Auto-generated by oct2bin.\n");
  fprintf(fout, ";            XXXX-XX-XX XXX    XXXX\n");
  while (fread(b, 2, 1, fin) == 1) {
    value = (b[0] << 7) | (b[1] >> 1);
    if ((count % 8) == 0)
      fprintf(fout, "\n");
    if ((count % 32) == 0)
      fprintf(fout, "\n");
    if ((count % 256) == 0) {
      char pageString[33], bankString[33];
      if (page <= 0)
        pageString[0] = 0;
      else
        sprintf(pageString, " p. %d,", page++);
      if (count < 2048)
        sprintf(bankString, " %o", 04000 + count);
      else
        sprintf(bankString, " %02o,%04o", getBank(count),
                02000 + (count % 1024));
      fprintf(fout, ";%s%s\n\n", pageString, bankString);
    }
    if ((count % 1024) == 0)
      fprintf(fout, "BANK=%o\n\n", getBank(count));
    fprintf(fout, "%05o ", value);
    count++;
  }
  fclose(fin);
  fclose(fout);
  return (0);
}


x86 assembly (clang, -O0):
<decompile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe74(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bf <decompile+0x4f>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1439 <decompile+0x2c9>
lea    0xe77(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1202 <decompile+0x92>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1439 <decompile+0x2c9>
mov    -0x28(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0xa(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1420 <decompile+0x2b0>
movzbl -0xa(%rbp),%eax
shl    $0x7,%eax
movzbl -0x9(%rbp),%ecx
sar    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12c7 <decompile+0x157>
mov    -0x28(%rbp),%rdi
lea    0xeb9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12ed <decompile+0x17d>
mov    -0x28(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13bf <decompile+0x24f>
cmpl   $0x0,-0x8(%rbp)
jg     1314 <decompile+0x1a4>
movb   $0x0,-0x50(%rbp)
jmp    1331 <decompile+0x1c1>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
cmpl   $0x800,-0x14(%rbp)
jge    135e <decompile+0x1ee>
lea    -0x80(%rbp),%rdi
mov    -0x14(%rbp),%edx
add    $0x800,%edx
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    13a5 <decompile+0x235>
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <getBank@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,-0x84(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x84(%rbp),%edx
add    $0x400,%ecx
lea    0xdc0(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    -0x80(%rbp),%rcx
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    13fd <decompile+0x28d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <getBank@plt>
mov    -0x98(%rbp),%rdi
mov    %eax,%edx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xd70(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    126e <decompile+0xfe>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decompile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edi,%r14d
lea    0xe58(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     140e <decompile+0x27e>
mov    %rax,%r15
lea    0xe47(%rip),%rdi
lea    0xe52(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1417 <decompile+0x287>
mov    %rax,%rbx
lea    0xe3c(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
lea    0xe3f(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe43(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe3d(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe44(%rip),%rdi
mov    $0x3a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe66(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    13fa <decompile+0x26a>
xor    %r13d,%r13d
jmp    12d7 <decompile+0x147>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xe6d(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%r13d
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    13fa <decompile+0x26a>
movzbl 0xe(%rsp),%ebp
movzbl 0xf(%rsp),%r12d
test   $0x7,%r13b
je     1350 <decompile+0x1c0>
test   $0x1f,%r13b
je     1363 <decompile+0x1d3>
shl    $0x7,%ebp
shr    %r12d
test   %r13b,%r13b
jne    13ca <decompile+0x23a>
test   %r14d,%r14d
jle    1375 <decompile+0x1e5>
mov    %r14,%rdx
add    $0x1,%r14d
lea    0x40(%rsp),%rdi
lea    0xdd9(%rip),%rsi
xor    %eax,%eax
call   10a0 <sprintf@plt>
cmp    $0x7ff,%r13d
ja     1383 <decompile+0x1f3>
lea    0x800(%r13),%edx
lea    0x10(%rsp),%rdi
lea    0xdbe(%rip),%rsi
xor    %eax,%eax
call   10a0 <sprintf@plt>
jmp    13af <decompile+0x21f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
test   $0x1f,%r13b
jne    12ee <decompile+0x15e>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
jmp    12ee <decompile+0x15e>
movb   $0x0,0x40(%rsp)
cmp    $0x7ff,%r13d
jbe    1325 <decompile+0x195>
mov    %r13d,%edi
call   1080 <getBank@plt>
mov    %r13d,%ecx
and    $0x3ff,%ecx
or     $0x400,%ecx
lea    0x10(%rsp),%rdi
lea    0xd54(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
lea    0xd4c(%rip),%rsi
lea    0x40(%rsp),%rdx
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
or     %r12d,%ebp
test   $0x3ff,%r13d
jne    12a0 <decompile+0x110>
mov    %r13d,%edi
call   1080 <getBank@plt>
mov    %rbx,%rdi
lea    0xd21(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12a0 <decompile+0x110>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1430 <decompile+0x2a0>
lea    0xd3c(%rip),%rdi
jmp    1426 <decompile+0x296>
mov    %r15,%rdi
call   1050 <fclose@plt>
lea    0xcf7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"oct2bin.bin\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"Error: input file oct2bin.bin does not exist.\0A\00"
@.str.3 = [18 x i8] c"oct2bin.binsource\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [53 x i8] c"Error: cannot create output file oct2bin.binsource.\0A\00"
@.str.6 = [28 x i8] c"; Copyright: Public domain\0A\00"
@.str.7 = [29 x i8] c"; Filename: XXXX.binsource\0A\00"
@.str.8 = [19 x i8] c"; Purpose: XXXX\0A\00"
@.str.9 = [32 x i8] c"; Contact: info@sandroid.org\0A\00"
@.str.10 = [59 x i8] c"; Mods: XXXX-XX-XX XXX Auto-generated by oct2bin.\0A\00"
@.str.11 = [37 x i8] c"; XXXX-XX-XX XXX XXXX\0A\00"
@.str.12 = [2 x i8] c"\0A\00"
@.str.13 = [8 x i8] c" p. %d,\00"
@.str.14 = [4 x i8] c" %o\00"
@.str.15 = [11 x i8] c" %02o,%04o\00"
@.str.16 = [8 x i8] c";%s%s\0A\0A\00"
@.str.17 = [10 x i8] c"BANK=%o\0A\0A\00"
@.str.18 = [6 x i8] c"%05o \00"
define i32 @decompile(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [33 x i8]
%10 = alloca [33 x i8]
store i32 %0, i32* %3
store i32 0, i32* %6
%11 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %120
16: ; preds = %1
%17 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %17, i32** %8
%18 = load i32*, i32** %8
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32*, i32** %7
%22 = call i32 @fclose(i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %120
24: ; preds = %16
%25 = load i32*, i32** %8
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%27 = load i32*, i32** %8
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
%29 = load i32*, i32** %8
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%31 = load i32*, i32** %8
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%33 = load i32*, i32** %8
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0))
%35 = load i32*, i32** %8
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
br label %37
37: ; preds = %109, %24
%38 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%39 = load i32*, i32** %7
%40 = call i32 @fread(i8* %38, i32 2, i32 1, i32* %39)
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %115
42: ; preds = %37
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = shl i32 %45, 7
%47 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = ashr i32 %49, 1
%51 = or i32 %46, %50
store i32 %51, i32* %5
%52 = load i32, i32* %6
%53 = srem i32 %52, 8
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %42
%56 = load i32*, i32** %8
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %58
58: ; preds = %55, %42
%59 = load i32, i32* %6
%60 = srem i32 %59, 32
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i32*, i32** %8
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %65
65: ; preds = %62, %58
%66 = load i32, i32* %6
%67 = srem i32 %66, 256
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %100
69: ; preds = %65
%70 = load i32, i32* %3
%71 = icmp sle i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = getelementptr inbounds [33 x i8], [33 x i8]* %9, i64 0, i64 0
store i8 0, i8* %73
br label %79
74: ; preds = %69
%75 = getelementptr inbounds [33 x i8], [33 x i8]* %9, i64 0, i64 0
%76 = load i32, i32* %3
%77 = add nsw i32 %76, 1
store i32 %77, i32* %3
%78 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i32 %76)
br label %79
79: ; preds = %74, %72
%80 = load i32, i32* %6
%81 = icmp slt i32 %80, 2048
br i1 %81, label %82, label %87
82: ; preds = %79
%83 = getelementptr inbounds [33 x i8], [33 x i8]* %10, i64 0, i64 0
%84 = load i32, i32* %6
%85 = add nsw i32 2048, %84
%86 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 %85)
br label %95
87: ; preds = %79
%88 = getelementptr inbounds [33 x i8], [33 x i8]* %10, i64 0, i64 0
%89 = load i32, i32* %6
%90 = call i32 @getBank(i32 %89)
%91 = load i32, i32* %6
%92 = srem i32 %91, 1024
%93 = add nsw i32 1024, %92
%94 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %88, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i32 %90, i32 %93)
br label %95
95: ; preds = %87, %82
%96 = load i32*, i32** %8
%97 = getelementptr inbounds [33 x i8], [33 x i8]* %9, i64 0, i64 0
%98 = getelementptr inbounds [33 x i8], [33 x i8]* %10, i64 0, i64 0
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %96, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* %97, i8* %98)
br label %100
100: ; preds = %95, %65
%101 = load i32, i32* %6
%102 = srem i32 %101, 1024
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %109
104: ; preds = %100
%105 = load i32*, i32** %8
%106 = load i32, i32* %6
%107 = call i32 @getBank(i32 %106)
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32 %107)
br label %109
109: ; preds = %104, %100
%110 = load i32*, i32** %8
%111 = load i32, i32* %5
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %110, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i32 %111)
%113 = load i32, i32* %6
%114 = add nsw i32 %113, 1
store i32 %114, i32* %6
br label %37
115: ; preds = %37
%116 = load i32*, i32** %7
%117 = call i32 @fclose(i32* %116)
%118 = load i32*, i32** %8
%119 = call i32 @fclose(i32* %118)
store i32 0, i32* %2
br label %120
120: ; preds = %115, %20, %14
%121 = load i32, i32* %2
ret i32 %121
}

LLVM IR (-O2):
@.str = [12 x i8] c"oct2bin.bin\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [18 x i8] c"oct2bin.binsource\00"
@.str.4 = [2 x i8] c"w\00"
@.str.6 = [28 x i8] c"; Copyright: Public domain\0A\00"
@.str.7 = [29 x i8] c"; Filename: XXXX.binsource\0A\00"
@.str.8 = [19 x i8] c"; Purpose: XXXX\0A\00"
@.str.9 = [32 x i8] c"; Contact: info@sandroid.org\0A\00"
@.str.10 = [59 x i8] c"; Mods: XXXX-XX-XX XXX Auto-generated by oct2bin.\0A\00"
@.str.11 = [37 x i8] c"; XXXX-XX-XX XXX XXXX\0A\00"
@.str.13 = [8 x i8] c" p. %d,\00"
@.str.14 = [4 x i8] c" %o\00"
@.str.15 = [11 x i8] c" %02o,%04o\00"
@.str.16 = [8 x i8] c";%s%s\0A\0A\00"
@.str.17 = [10 x i8] c"BANK=%o\0A\0A\00"
@.str.18 = [6 x i8] c"%05o \00"
@str = [52 x i8] c"Error: cannot create output file oct2bin.binsource.\00"
@str.19 = [46 x i8] c"Error: input file oct2bin.bin does not exist.\00"
define i32 @decompile(i32 %0) {
%2 = alloca [2 x i8]
%3 = alloca [33 x i8]
%4 = alloca [33 x i8]
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.19, i64 0, i64 0))
br label %85
10: ; preds = %1
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = tail call i32 @fclose(i32* %6)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
br label %85
16: ; preds = %10
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i64 27, i64 1, i32* %11)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i64 28, i64 1, i32* %11)
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i64 18, i64 1, i32* %11)
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i64 31, i64 1, i32* %11)
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0), i64 58, i64 1, i32* %11)
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0), i64 36, i64 1, i32* %11)
%23 = call i32 @fread(i8* %5, i32 2, i32 1, i32* %6)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %82
25: ; preds = %16
%26 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
%27 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%28 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
br label %29
29: ; preds = %25, %77
%30 = phi i32 [ %0, %25 ], [ %71, %77 ]
%31 = phi i32 [ 0, %25 ], [ %79, %77 ]
%32 = load i8, i8* %5
%33 = zext i8 %32 to i32
%34 = shl nuw nsw i32 %33, 7
%35 = load i8, i8* %26
%36 = lshr i8 %35, 1
%37 = zext i8 %36 to i32
%38 = or i32 %34, %37
%39 = and i32 %31, 7
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %29
%42 = call i32 @fputc(i32 10, i32* %11)
br label %43
43: ; preds = %41, %29
%44 = and i32 %31, 31
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @fputc(i32 10, i32* %11)
br label %48
48: ; preds = %46, %43
%49 = and i32 %31, 255
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %70
51: ; preds = %48
%52 = icmp slt i32 %30, 1
br i1 %52, label %53, label %54
53: ; preds = %51
store i8 0, i8* %27
br label %57
54: ; preds = %51
%55 = add nuw nsw i32 %30, 1
%56 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %27, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0), i32 %30)
br label %57
57: ; preds = %54, %53
%58 = phi i32 [ %30, %53 ], [ %55, %54 ]
%59 = icmp ult i32 %31, 2048
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = add nuw nsw i32 %31, 2048
%62 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %28, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 %61)
br label %68
63: ; preds = %57
%64 = call i32 @getBank(i32 %31)
%65 = and i32 %31, 1023
%66 = or i32 %65, 1024
%67 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %28, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i32 %64, i32 %66)
br label %68
68: ; preds = %63, %60
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i64 0, i64 0), i8* %27, i8* %28)
br label %70
70: ; preds = %68, %48
%71 = phi i32 [ %58, %68 ], [ %30, %48 ]
%72 = and i32 %31, 1023
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = call i32 @getBank(i32 %31)
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %74, %70
%78 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i32 %38)
%79 = add nuw nsw i32 %31, 1
%80 = call i32 @fread(i8* %5, i32 2, i32 1, i32* %6)
%81 = icmp eq i32 %80, 1
br i1 %81, label %29, label %82
82: ; preds = %77, %16
%83 = call i32 @fclose(i32* %6)
%84 = call i32 @fclose(i32* %11)
br label %85
85: ; preds = %82, %13, %8
%86 = phi i32 [ 1, %8 ], [ 1, %13 ], [ 0, %82 ]
ret i32 %86
}