#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*/ _IOFBF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ nc_fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ put16(int /*<<< orphan*/ *, int);
int read16(int /*<<< orphan*/ *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                           int);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  FILE *f;
  int w, h, d, N;
  float dx, dy, dz;
  int bits;
  int *data;
  char z[4096];
  char *buffer;
  int i, j;
  if (argc != 2) {
    fprintf(stderr, "usage: scnsunfix scn-file\n\n");
    return 1;
  }
  f = fopen(argv[1], "r");
  buffer = (char *)malloc(65536);
  if (!buffer)
    goto kaput;
  setvbuf(f, buffer, _IOFBF, 65536);
  if (!f) {
    fprintf(stderr, "unable to open file %s\n", argv[1]);
    return 2;
  }
  if (!nc_fgets(z, 4095, f))
    goto kaput;
  if (z[0] != 'S' || z[1] != 'C' || z[2] != 'N')
    goto kaput;
  if (!nc_fgets(z, 4095, f))
    goto kaput;
  if (sscanf(z, " %d %d %d \n", &w, &h, &d) != 3)
    goto kaput;
  if (!nc_fgets(z, 4095, f))
    goto kaput;
  if (sscanf(z, " %f %f %f \n", &dx, &dy, &dz) != 3)
    goto kaput;
  if (!nc_fgets(z, 4095, f))
    goto kaput;
  if (sscanf(z, " %d \n", &bits) != 1)
    goto kaput;
  N = w * h * d;
  if (bits == 8) {
    printf("8-bit data, there's nothign to do.\n");
    return 0;
  }
  if (bits != 16)
    goto kaput;
  data = (int *)malloc(sizeof(int) * N);
  if (!data)
    goto kaput;
  for (i = 0; i < N; i++) {
    j = read16(f);
    data[i] = (j >> 8) | ((j & 0xff) << 8);
  }
  fclose(f);
  f = fopen(argv[1], "w");
  if (!f)
    goto kaput;
  fprintf(f, "SCN\n%d %d %d\n%f %f %f\n16\n", w, h, d, dx, dy, dz);
  for (i = 0; i < N; i++)
    put16(f, data[i]);
  fclose(f);
  return 0;
kaput:
  fprintf(stderr, "error!\n");
  return 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11e6 <main+0x46>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1562 <main+0x3c2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe27(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0x10000,%edi
call   1090 <malloc@plt>
mov    %rax,-0x1048(%rbp)
cmpq   $0x0,-0x1048(%rbp)
jne    1222 <main+0x82>
jmp    1544 <main+0x3a4>
mov    -0x18(%rbp),%rdi
mov    -0x1048(%rbp),%rsi
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%ecx
call   10b0 <setvbuf@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1276 <main+0xd6>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1562 <main+0x3c2>
lea    -0x1040(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xfff,%esi
call   1030 <nc_fgets@plt>
cmp    $0x0,%eax
jne    1299 <main+0xf9>
jmp    1544 <main+0x3a4>
movsbl -0x1040(%rbp),%eax
cmp    $0x53,%eax
jne    12c9 <main+0x129>
movsbl -0x103f(%rbp),%eax
cmp    $0x43,%eax
jne    12c9 <main+0x129>
movsbl -0x103e(%rbp),%eax
cmp    $0x4e,%eax
je     12ce <main+0x12e>
jmp    1544 <main+0x3a4>
lea    -0x1040(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xfff,%esi
call   1030 <nc_fgets@plt>
cmp    $0x0,%eax
jne    12f1 <main+0x151>
jmp    1544 <main+0x3a4>
lea    -0x1040(%rbp),%rdi
lea    0xd37(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x3,%eax
je     1320 <main+0x180>
jmp    1544 <main+0x3a4>
lea    -0x1040(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xfff,%esi
call   1030 <nc_fgets@plt>
cmp    $0x0,%eax
jne    1343 <main+0x1a3>
jmp    1544 <main+0x3a4>
lea    -0x1040(%rbp),%rdi
lea    0xcf1(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x3,%eax
je     1372 <main+0x1d2>
jmp    1544 <main+0x3a4>
lea    -0x1040(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xfff,%esi
call   1030 <nc_fgets@plt>
cmp    $0x0,%eax
jne    1395 <main+0x1f5>
jmp    1544 <main+0x3a4>
lea    -0x1040(%rbp),%rdi
lea    0xc99(%rip),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     13bc <main+0x21c>
jmp    1544 <main+0x3a4>
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x8,-0x38(%rbp)
jne    13ec <main+0x24c>
lea    0xc73(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1562 <main+0x3c2>
cmpl   $0x10,-0x38(%rbp)
je     13fb <main+0x25b>
jmp    1544 <main+0x3a4>
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    141e <main+0x27e>
jmp    1544 <main+0x3a4>
movl   $0x0,-0x104c(%rbp)
mov    -0x104c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1481 <main+0x2e1>
mov    -0x18(%rbp),%rdi
call   1060 <read16@plt>
mov    %eax,-0x1050(%rbp)
mov    -0x1050(%rbp),%edx
sar    $0x8,%edx
mov    -0x1050(%rbp),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     %eax,%edx
mov    -0x40(%rbp),%rax
movslq -0x104c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x104c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104c(%rbp)
jmp    1428 <main+0x288>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xbd9(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    14b2 <main+0x312>
jmp    1544 <main+0x3a4>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x30(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x34(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xb90(%rip),%rsi
mov    $0x3,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x104c(%rbp)
mov    -0x104c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    152f <main+0x38f>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rax
movslq -0x104c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1070 <put16@plt>
mov    -0x104c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104c(%rbp)
jmp    14f5 <main+0x355>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1562 <main+0x3c2>
mov    0x2a95(%rip),%rax
mov    (%rax),%edi
lea    0xb3a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
cmp    $0x2,%edi
jne    132a <main+0x18a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe54(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r14
mov    $0x10000,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1444 <main+0x2a4>
mov    0x2dee(%rip),%rcx
mov    (%rcx),%edx
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x10000,%ecx
call   10b0 <setvbuf@plt>
test   %r14,%r14
je     134b <main+0x1ab>
lea    0x20(%rsp),%rdi
mov    $0xfff,%esi
mov    %r14,%rdx
call   1030 <nc_fgets@plt>
test   %eax,%eax
je     1444 <main+0x2a4>
cmpb   $0x53,0x20(%rsp)
jne    1444 <main+0x2a4>
cmpb   $0x43,0x21(%rsp)
jne    1444 <main+0x2a4>
cmpb   $0x4e,0x22(%rsp)
jne    1444 <main+0x2a4>
lea    0x20(%rsp),%rdi
mov    $0xfff,%esi
mov    %r14,%rdx
call   1030 <nc_fgets@plt>
test   %eax,%eax
je     1444 <main+0x2a4>
lea    0xdd5(%rip),%rsi
lea    0x20(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x3,%eax
jne    1444 <main+0x2a4>
lea    0x20(%rsp),%rdi
mov    $0xfff,%esi
mov    %r14,%rdx
call   1030 <nc_fgets@plt>
test   %eax,%eax
je     1444 <main+0x2a4>
lea    0xd9c(%rip),%rsi
lea    0x20(%rsp),%rdi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x3,%eax
jne    1444 <main+0x2a4>
lea    0x20(%rsp),%rdi
mov    $0xfff,%esi
mov    %r14,%rdx
call   1030 <nc_fgets@plt>
test   %eax,%eax
je     1444 <main+0x2a4>
lea    0xd51(%rip),%rsi
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
jne    1444 <main+0x2a4>
mov    0x10(%rsp),%eax
cmp    $0x10,%eax
je     136b <main+0x1cb>
cmp    $0x8,%eax
jne    1444 <main+0x2a4>
lea    0xd54(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    1460 <main+0x2c0>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
lea    0xcc6(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    1460 <main+0x2c0>
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xcbf(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    145b <main+0x2bb>
mov    0x8(%rsp),%r13d
imul   0xc(%rsp),%r13d
imul   0x4(%rsp),%r13d
lea    0x0(,%r13,4),%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1444 <main+0x2a4>
mov    %rax,%r15
mov    %r13d,%r12d
test   %r13d,%r13d
jle    13c1 <main+0x221>
xor    %ebp,%ebp
mov    %r14,%rdi
call   1060 <read16@plt>
mov    %eax,%ecx
sar    $0x8,%ecx
shl    $0x8,%eax
movzwl %ax,%eax
or     %ecx,%eax
mov    %eax,(%r15,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    139f <main+0x1ff>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x8(%rbx),%rdi
lea    0xc7a(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1444 <main+0x2a4>
mov    %rax,%rbx
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0x4(%rsp),%r8d
movss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x18(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xc3d(%rip),%rsi
mov    %ebx,%edi
mov    $0x3,%al
call   1080 <fprintf@plt>
test   %r13d,%r13d
jle    1438 <main+0x298>
xor    %ebp,%ebp
mov    (%r15,%rbp,4),%esi
mov    %rbx,%rdi
call   1070 <put16@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1423 <main+0x283>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    1460 <main+0x2c0>
mov    0x2b95(%rip),%rax
mov    (%rax),%edi
lea    0xc16(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x2,%eax
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"usage: scnsunfix scn-file\0A\0A\00"
@.str.1 = [2 x i8] c"r\00"
@_IOFBF = global i32 0
@.str.2 = [24 x i8] c"unable to open file %s\0A\00"
@.str.3 = [12 x i8] c" %d %d %d \0A\00"
@.str.4 = [12 x i8] c" %f %f %f \0A\00"
@.str.5 = [6 x i8] c" %d \0A\00"
@.str.6 = [36 x i8] c"8-bit data, there's nothign to do.\0A\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [26 x i8] c"SCN\0A%d %d %d\0A%f %f %f\0A16\0A\00"
@.str.9 = [8 x i8] c"error!\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
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca i32
%15 = alloca i32*
%16 = alloca [4096 x i8]
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %192
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %6
%30 = call i64 @malloc(i32 65536)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %17
%32 = load i8*, i8** %17
%33 = icmp ne i8* %32, null
br i1 %33, label %35, label %34
34: ; preds = %25
br label %189
35: ; preds = %25
%36 = load i32*, i32** %6
%37 = load i8*, i8** %17
%38 = load i32, i32* @_IOFBF
%39 = call i32 @setvbuf(i32* %36, i8* %37, i32 %38, i32 65536)
%40 = load i32*, i32** %6
%41 = icmp ne i32* %40, null
br i1 %41, label %48, label %42
42: ; preds = %35
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %46)
store i32 2, i32* %3
br label %192
48: ; preds = %35
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%50 = load i32*, i32** %6
%51 = call i32 @nc_fgets(i8* %49, i32 4095, i32* %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %48
br label %189
54: ; preds = %48
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 83
br i1 %58, label %69, label %59
59: ; preds = %54
%60 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 1
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 67
br i1 %63, label %69, label %64
64: ; preds = %59
%65 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 2
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %67, 78
br i1 %68, label %69, label %70
69: ; preds = %64, %59, %54
br label %189
70: ; preds = %64
%71 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%72 = load i32*, i32** %6
%73 = call i32 @nc_fgets(i8* %71, i32 4095, i32* %72)
%74 = icmp ne i32 %73, 0
br i1 %74, label %76, label %75
75: ; preds = %70
br label %189
76: ; preds = %70
%77 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%78 = call i32 (i8*, i8*, ...) @sscanf(i8* %77, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%79 = icmp ne i32 %78, 3
br i1 %79, label %80, label %81
80: ; preds = %76
br label %189
81: ; preds = %76
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%83 = load i32*, i32** %6
%84 = call i32 @nc_fgets(i8* %82, i32 4095, i32* %83)
%85 = icmp ne i32 %84, 0
br i1 %85, label %87, label %86
86: ; preds = %81
br label %189
87: ; preds = %81
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%89 = call i32 (i8*, i8*, ...) @sscanf(i8* %88, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), float* %11, float* %12, float* %13)
%90 = icmp ne i32 %89, 3
br i1 %90, label %91, label %92
91: ; preds = %87
br label %189
92: ; preds = %87
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%94 = load i32*, i32** %6
%95 = call i32 @nc_fgets(i8* %93, i32 4095, i32* %94)
%96 = icmp ne i32 %95, 0
br i1 %96, label %98, label %97
97: ; preds = %92
br label %189
98: ; preds = %92
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %16, i64 0, i64 0
%100 = call i32 (i8*, i8*, ...) @sscanf(i8* %99, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %14)
%101 = icmp ne i32 %100, 1
br i1 %101, label %102, label %103
102: ; preds = %98
br label %189
103: ; preds = %98
%104 = load i32, i32* %7
%105 = load i32, i32* %8
%106 = mul nsw i32 %104, %105
%107 = load i32, i32* %9
%108 = mul nsw i32 %106, %107
store i32 %108, i32* %10
%109 = load i32, i32* %14
%110 = icmp eq i32 %109, 8
br i1 %110, label %111, label %113
111: ; preds = %103
%112 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %192
113: ; preds = %103
%114 = load i32, i32* %14
%115 = icmp ne i32 %114, 16
br i1 %115, label %116, label %117
116: ; preds = %113
br label %189
117: ; preds = %113
%118 = load i32, i32* %10
%119 = sext i32 %118 to i64
%120 = mul i64 4, %119
%121 = trunc i64 %120 to i32
%122 = call i64 @malloc(i32 %121)
%123 = inttoptr i64 %122 to i32*
store i32* %123, i32** %15
%124 = load i32*, i32** %15
%125 = icmp ne i32* %124, null
br i1 %125, label %127, label %126
126: ; preds = %117
br label %189
127: ; preds = %117
store i32 0, i32* %18
br label %128
128: ; preds = %145, %127
%129 = load i32, i32* %18
%130 = load i32, i32* %10
%131 = icmp slt i32 %129, %130
br i1 %131, label %132, label %148
132: ; preds = %128
%133 = load i32*, i32** %6
%134 = call i32 @read16(i32* %133)
store i32 %134, i32* %19
%135 = load i32, i32* %19
%136 = ashr i32 %135, 8
%137 = load i32, i32* %19
%138 = and i32 %137, 255
%139 = shl i32 %138, 8
%140 = or i32 %136, %139
%141 = load i32*, i32** %15
%142 = load i32, i32* %18
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds i32, i32* %141, i64 %143
store i32 %140, i32* %144
br label %145
145: ; preds = %132
%146 = load i32, i32* %18
%147 = add nsw i32 %146, 1
store i32 %147, i32* %18
br label %128
148: ; preds = %128
%149 = load i32*, i32** %6
%150 = call i32 @fclose(i32* %149)
%151 = load i8**, i8*** %5
%152 = getelementptr inbounds i8*, i8** %151, i64 1
%153 = load i8*, i8** %152
%154 = call i32* @fopen(i8* %153, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %154, i32** %6
%155 = load i32*, i32** %6
%156 = icmp ne i32* %155, null
br i1 %156, label %158, label %157
157: ; preds = %148
br label %189
158: ; preds = %148
%159 = load i32*, i32** %6
%160 = ptrtoint i32* %159 to i32
%161 = load i32, i32* %7
%162 = load i32, i32* %8
%163 = load i32, i32* %9
%164 = load float, float* %11
%165 = fpext float %164 to double
%166 = load float, float* %12
%167 = fpext float %166 to double
%168 = load float, float* %13
%169 = fpext float %168 to double
%170 = call i32 (i32, i8*, ...) @fprintf(i32 %160, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %161, i32 %162, i32 %163, double %165, double %167, double %169)
store i32 0, i32* %18
br label %171
171: ; preds = %183, %158
%172 = load i32, i32* %18
%173 = load i32, i32* %10
%174 = icmp slt i32 %172, %173
br i1 %174, label %175, label %186
175: ; preds = %171
%176 = load i32*, i32** %6
%177 = load i32*, i32** %15
%178 = load i32, i32* %18
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i32, i32* %177, i64 %179
%181 = load i32, i32* %180
%182 = call i32 @put16(i32* %176, i32 %181)
br label %183
183: ; preds = %175
%184 = load i32, i32* %18
%185 = add nsw i32 %184, 1
store i32 %185, i32* %18
br label %171
186: ; preds = %171
%187 = load i32*, i32** %6
%188 = call i32 @fclose(i32* %187)
store i32 0, i32* %3
br label %192
189: ; preds = %157, %126, %116, %102, %97, %91, %86, %80, %75, %69, %53, %34
%190 = load i32, i32* @stderr
%191 = call i32 (i32, i8*, ...) @fprintf(i32 %190, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
store i32 2, i32* %3
br label %192
192: ; preds = %189, %186, %111, %42, %22
%193 = load i32, i32* %3
ret i32 %193
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"usage: scnsunfix scn-file\0A\0A\00"
@.str.1 = [2 x i8] c"r\00"
@_IOFBF = global i32 0
@.str.2 = [24 x i8] c"unable to open file %s\0A\00"
@.str.3 = [12 x i8] c" %d %d %d \0A\00"
@.str.4 = [12 x i8] c" %f %f %f \0A\00"
@.str.5 = [6 x i8] c" %d \0A\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [26 x i8] c"SCN\0A%d %d %d\0A%f %f %f\0A16\0A\00"
@.str.9 = [8 x i8] c"error!\0A\00"
@str = [35 x i8] c"8-bit data, there's nothign to do.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i32
%10 = alloca [4096 x i8]
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast float* %6 to i8*
%15 = bitcast float* %7 to i8*
%16 = bitcast float* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%19 = icmp eq i32 %0, 2
br i1 %19, label %23, label %20
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %130
23: ; preds = %2
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i64 @malloc(i32 65536)
%28 = icmp eq i64 %27, 0
br i1 %28, label %127, label %29
29: ; preds = %23
%30 = inttoptr i64 %27 to i8*
%31 = load i32, i32* @_IOFBF
%32 = tail call i32 @setvbuf(i32* %26, i8* %30, i32 %31, i32 65536)
%33 = icmp eq i32* %26, null
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %24
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %130
38: ; preds = %29
%39 = call i32 @nc_fgets(i8* %18, i32 4095, i32* %26)
%40 = icmp eq i32 %39, 0
br i1 %40, label %127, label %41
41: ; preds = %38
%42 = load i8, i8* %18
%43 = icmp ne i8 %42, 83
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 1
%45 = load i8, i8* %44
%46 = icmp ne i8 %45, 67
%47 = select i1 %43, i1 true, i1 %46
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 2
%49 = load i8, i8* %48
%50 = icmp ne i8 %49, 78
%51 = select i1 %47, i1 true, i1 %50
br i1 %51, label %127, label %52
52: ; preds = %41
%53 = call i32 @nc_fgets(i8* %18, i32 4095, i32* %26)
%54 = icmp eq i32 %53, 0
br i1 %54, label %127, label %55
55: ; preds = %52
%56 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%57 = icmp eq i32 %56, 3
br i1 %57, label %58, label %127
58: ; preds = %55
%59 = call i32 @nc_fgets(i8* %18, i32 4095, i32* %26)
%60 = icmp eq i32 %59, 0
br i1 %60, label %127, label %61
61: ; preds = %58
%62 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), float* %6, float* %7, float* %8)
%63 = icmp eq i32 %62, 3
br i1 %63, label %64, label %127
64: ; preds = %61
%65 = call i32 @nc_fgets(i8* %18, i32 4095, i32* %26)
%66 = icmp eq i32 %65, 0
br i1 %66, label %127, label %67
67: ; preds = %64
%68 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %9)
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %127
70: ; preds = %67
%71 = load i32, i32* %3
%72 = load i32, i32* %4
%73 = mul nsw i32 %72, %71
%74 = load i32, i32* %5
%75 = mul i32 %73, %74
%76 = load i32, i32* %9
switch i32 %76, label %127 [
i32 8, label %77
i32 16, label %79
]
77: ; preds = %70
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %130
79: ; preds = %70
%80 = shl i32 %75, 2
%81 = call i64 @malloc(i32 %80)
%82 = inttoptr i64 %81 to i32*
%83 = icmp eq i64 %81, 0
br i1 %83, label %127, label %84
84: ; preds = %79
%85 = icmp sgt i32 %75, 0
br i1 %85, label %86, label %98
86: ; preds = %84
%87 = zext i32 %75 to i64
br label %88
88: ; preds = %86, %88
%89 = phi i64 [ 0, %86 ], [ %96, %88 ]
%90 = call i32 @read16(i32* %26)
%91 = ashr i32 %90, 8
%92 = shl i32 %90, 8
%93 = and i32 %92, 65280
%94 = or i32 %93, %91
%95 = getelementptr inbounds i32, i32* %82, i64 %89
store i32 %94, i32* %95
%96 = add nuw nsw i64 %89, 1
%97 = icmp eq i64 %96, %87
br i1 %97, label %98, label %88
98: ; preds = %88, %84
%99 = call i32 @fclose(i32* %26)
%100 = load i8*, i8** %24
%101 = call i32* @fopen(i8* %100, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%102 = icmp eq i32* %101, null
br i1 %102, label %127, label %103
103: ; preds = %98
%104 = ptrtoint i32* %101 to i64
%105 = trunc i64 %104 to i32
%106 = load i32, i32* %3
%107 = load i32, i32* %4
%108 = load i32, i32* %5
%109 = load float, float* %6
%110 = fpext float %109 to double
%111 = load float, float* %7
%112 = fpext float %111 to double
%113 = load float, float* %8
%114 = fpext float %113 to double
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %106, i32 %107, i32 %108, double %110, double %112, double %114)
br i1 %85, label %116, label %125
116: ; preds = %103
%117 = zext i32 %75 to i64
br label %118
118: ; preds = %116, %118
%119 = phi i64 [ 0, %116 ], [ %123, %118 ]
%120 = getelementptr inbounds i32, i32* %82, i64 %119
%121 = load i32, i32* %120
%122 = call i32 @put16(i32* %101, i32 %121)
%123 = add nuw nsw i64 %119, 1
%124 = icmp eq i64 %123, %117
br i1 %124, label %125, label %118
125: ; preds = %118, %103
%126 = call i32 @fclose(i32* %101)
br label %130
127: ; preds = %70, %98, %79, %67, %64, %61, %58, %55, %52, %41, %38, %23
%128 = load i32, i32* @stderr
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %130
130: ; preds = %127, %125, %77, %34, %20
%131 = phi i32 [ 1, %20 ], [ 2, %127 ], [ 0, %77 ], [ 0, %125 ], [ 2, %34 ]
ret i32 %131
}