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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  uint8_t vals[4];
  int counter = 0;
  int mapnum;
  if (argc <= 1) {
    printf("\nShould pass a filename as input via command line\n");
    return 0;
  }
  FILE *fp = fopen(argv[1], "rb");
  if (!fp) {
    printf("\nFailed to open file named \"%s\" for reading\n", argv[1]);
    return 0;
  }
  if (!feof(fp)) {
    if (fread(vals, 2, 1, fp)) {
      printf(" BE_Cross_SwapGroup16LE(0x%02x, 0x%02x)", vals[0], vals[1]);
      printf("\n");
    }
  }
  for (mapnum = 0; mapnum < 100; ++mapnum) {
    if (feof(fp) || !fread(vals, 4, 1, fp)) {
      printf("WARNING: Input file ended unexpectedly\n");
      break;
    }
    printf(" BE_Cross_SwapGroup32LE(0x%02x, 0x%02x, 0x%02x, 0x%02x)", vals[0],
           vals[1], vals[2], vals[3]);
    if (++counter == 4) {
      counter = 0;
      printf("\n");
    }
  }
  counter = 0;
  while (!feof(fp)) {
    if (!fread(vals, 1, 1, fp)) {
      break;
    }
    printf(" 0x%02x,", vals[0]);
    if (++counter == 16) {
      counter = 0;
      printf("\n");
    }
  }
  fclose(fp);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1191 <main+0x41>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <main+0x232>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe93(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11d6 <main+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1382 <main+0x232>
mov    -0x30(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
jne    1231 <main+0xe1>
lea    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     122c <main+0xdc>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1231 <main+0xe1>
movl   $0x0,-0x28(%rbp)
cmpl   $0x64,-0x28(%rbp)
jge    12de <main+0x18e>
mov    -0x30(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
jne    1276 <main+0x126>
lea    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
jne    1289 <main+0x139>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12de <main+0x18e>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x4,%eax
jne    12cb <main+0x17b>
movl   $0x0,-0x24(%rbp)
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12d0 <main+0x180>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1238 <main+0xe8>
movl   $0x0,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1304 <main+0x1b4>
jmp    1364 <main+0x214>
lea    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
jne    1327 <main+0x1d7>
jmp    1364 <main+0x214>
mov    -0x20(%rbp),%esi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x10,%eax
jne    135f <main+0x20f>
movl   $0x0,-0x24(%rbp)
lea    0xcd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12e5 <main+0x195>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xcbd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1192 <main+0x22>
lea    0xf38(%rip),%rdi
call   1040 <puts@plt>
jmp    12ab <main+0x13b>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe60(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1299 <main+0x129>
mov    %rax,%r12
mov    %rax,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    11f7 <main+0x87>
mov    %rsp,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     11f7 <main+0x87>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x64,%ebp
mov    %rsp,%r14
lea    0xe52(%rip),%r15
xor    %ebx,%ebx
jmp    1215 <main+0xa5>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
je     1278 <main+0x108>
mov    %r12,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    126c <main+0xfc>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     126c <main+0xfc>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebx
cmp    $0x4,%ebx
jne    1210 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    1210 <main+0xa0>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1080 <feof@plt>
test   %rax,%rax
je     12ba <main+0x14a>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12ab <main+0x13b>
mov    0x8(%r14),%rsi
lea    0xd5f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r14
lea    0xdcc(%rip),%r15
xor    %ebx,%ebx
jmp    12dd <main+0x16d>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1080 <feof@plt>
test   %rax,%rax
jne    1285 <main+0x115>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     1285 <main+0x115>
mov    (%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebx
cmp    $0x10,%ebx
jne    12d0 <main+0x160>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    12d0 <main+0x160>

LLVM IR (-O0):
@.str = [51 x i8] c"\0AShould pass a filename as input via command line\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [45 x i8] c"\0AFailed to open file named \22%s\22 for reading\0A\00"
@.str.3 = [40 x i8] c" BE_Cross_SwapGroup16LE(0x%02x, 0x%02x)\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [40 x i8] c"WARNING: Input file ended unexpectedly\0A\00"
@.str.6 = [56 x i8] c" BE_Cross_SwapGroup32LE(0x%02x, 0x%02x, 0x%02x, 0x%02x)\00"
@.str.7 = [9 x i8] c" 0x%02x,\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %103
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %9
%19 = load i32*, i32** %9
%20 = icmp ne i32* %19, null
br i1 %20, label %26, label %21
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %24)
store i32 0, i32* %3
br label %103
26: ; preds = %14
%27 = load i32*, i32** %9
%28 = call i64 @feof(i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %43, label %30
30: ; preds = %26
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%32 = load i32*, i32** %9
%33 = call i64 @fread(i32* %31, i32 2, i32 1, i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %30
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%37 = load i32, i32* %36
%38 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 1
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %35, %30
br label %43
43: ; preds = %42, %26
store i32 0, i32* %8
br label %44
44: ; preds = %74, %43
%45 = load i32, i32* %8
%46 = icmp slt i32 %45, 100
br i1 %46, label %47, label %77
47: ; preds = %44
%48 = load i32*, i32** %9
%49 = call i64 @feof(i32* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %56, label %51
51: ; preds = %47
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%53 = load i32*, i32** %9
%54 = call i64 @fread(i32* %52, i32 4, i32 1, i32* %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %51, %47
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %77
58: ; preds = %51
%59 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%60 = load i32, i32* %59
%61 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 1
%62 = load i32, i32* %61
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 2
%64 = load i32, i32* %63
%65 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 3
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i32 %60, i32 %62, i32 %64, i32 %66)
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
%70 = icmp eq i32 %69, 4
br i1 %70, label %71, label %73
71: ; preds = %58
store i32 0, i32* %7
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %73
73: ; preds = %71, %58
br label %74
74: ; preds = %73
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %44
77: ; preds = %56, %44
store i32 0, i32* %7
br label %78
78: ; preds = %98, %77
%79 = load i32*, i32** %9
%80 = call i64 @feof(i32* %79)
%81 = icmp ne i64 %80, 0
%82 = xor i1 %81, true
br i1 %82, label %83, label %99
83: ; preds = %78
%84 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%85 = load i32*, i32** %9
%86 = call i64 @fread(i32* %84, i32 1, i32 1, i32* %85)
%87 = icmp ne i64 %86, 0
br i1 %87, label %89, label %88
88: ; preds = %83
br label %99
89: ; preds = %83
%90 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%91 = load i32, i32* %90
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %7
%94 = add nsw i32 %93, 1
store i32 %94, i32* %7
%95 = icmp eq i32 %94, 16
br i1 %95, label %96, label %98
96: ; preds = %89
store i32 0, i32* %7
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %98
98: ; preds = %96, %89
br label %78
99: ; preds = %88, %78
%100 = load i32*, i32** %9
%101 = call i32 @fclose(i32* %100)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %103
103: ; preds = %99, %21, %12
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [45 x i8] c"\0AFailed to open file named \22%s\22 for reading\0A\00"
@.str.3 = [40 x i8] c" BE_Cross_SwapGroup16LE(0x%02x, 0x%02x)\00"
@.str.6 = [56 x i8] c" BE_Cross_SwapGroup32LE(0x%02x, 0x%02x, 0x%02x, 0x%02x)\00"
@.str.7 = [9 x i8] c" 0x%02x,\00"
@str = [39 x i8] c"WARNING: Input file ended unexpectedly\00"
@str.8 = [50 x i8] c"\0AShould pass a filename as input via command line\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.8, i64 0, i64 0))
br label %79
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %79
16: ; preds = %8
%17 = tail call i64 @feof(i32* %11)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%21 = call i64 @fread(i32* %20, i32 2, i32 1, i32* %11)
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i32, i32* %20
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %26)
%28 = tail call i32 @putchar(i32 10)
br label %29
29: ; preds = %19, %23, %16
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
br label %34
34: ; preds = %29, %54
%35 = phi i32 [ 0, %29 ], [ %56, %54 ]
%36 = phi i32 [ 0, %29 ], [ %55, %54 ]
%37 = tail call i64 @feof(i32* %11)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = call i64 @fread(i32* %30, i32 4, i32 1, i32* %11)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39, %34
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %58
44: ; preds = %39
%45 = load i32, i32* %30
%46 = load i32, i32* %31
%47 = load i32, i32* %32
%48 = load i32, i32* %33
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i32 %45, i32 %46, i32 %47, i32 %48)
%50 = add nsw i32 %36, 1
%51 = icmp eq i32 %50, 4
br i1 %51, label %52, label %54
52: ; preds = %44
%53 = tail call i32 @putchar(i32 10)
br label %54
54: ; preds = %44, %52
%55 = phi i32 [ 0, %52 ], [ %50, %44 ]
%56 = add nuw nsw i32 %35, 1
%57 = icmp eq i32 %56, 100
br i1 %57, label %58, label %34
58: ; preds = %54, %42
%59 = tail call i64 @feof(i32* %11)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %76
61: ; preds = %58, %72
%62 = phi i32 [ %73, %72 ], [ 0, %58 ]
%63 = call i64 @fread(i32* %30, i32 1, i32 1, i32* %11)
%64 = icmp eq i64 %63, 0
br i1 %64, label %76, label %65
65: ; preds = %61
%66 = load i32, i32* %30
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %66)
%68 = add nsw i32 %62, 1
%69 = icmp eq i32 %68, 16
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = tail call i32 @putchar(i32 10)
br label %72
72: ; preds = %70, %65
%73 = phi i32 [ 0, %70 ], [ %68, %65 ]
%74 = tail call i64 @feof(i32* %11)
%75 = icmp eq i64 %74, 0
br i1 %75, label %61, label %76
76: ; preds = %72, %61, %58
%77 = tail call i32 @fclose(i32* %11)
%78 = tail call i32 @putchar(i32 10)
br label %79
79: ; preds = %13, %76, %6
ret i32 0
}