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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(struct SlaveInfo *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int main(int argc, char *argv[]) {
  char Title[100];
  struct SlaveInfo {
    unsigned long Security;
    char ID[8];
    unsigned short Version;
    unsigned short Flags;
    unsigned long BaseMemSize;
    unsigned long ExecInstall;
    unsigned short GameLoader;
    unsigned short CurrentDir;
    unsigned short DontCache;
    char keydebug;
    char keyexit;
    unsigned long ExpMem;
    unsigned short name;
    unsigned short copy;
    unsigned short info;
  };
  struct SlaveInfo sl;
  if (argc == 1) {
    printf("Usage: %s filename.slave\n", argv[0]);
    exit(0);
  }
  FILE *fp = fopen(argv[1], "rbe");
  if (fp == NULL) {
    printf("Could not open %s\n", argv[1]);
    exit(0);
  }
  fseek(fp, 32, SEEK_SET);
  fread(&sl, 1, sizeof(sl), fp);
  sl.Version = (sl.Version >> 8) | (sl.Version << 8);
  sl.name = (sl.name >> 8) | (sl.name << 8);
  printf("[%s] [%d]\n", sl.ID, sl.Version);
  fseek(fp, sl.name + 32, SEEK_SET);
  for (int i = 0; i <= 99; i++) {
    Title[i] = fgetc(fp);
    if (Title[i] == '\n') {
      Title[i] = '\0';
      break;
    }
  }
  printf("[%s]\n", Title);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jne    11e5 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0xc8(%rbp),%rdi
mov    0x2ded(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1060 <fseek@plt>
lea    -0xc0(%rbp),%rdi
mov    -0xc8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x40,%edx
call   1030 <fread@plt>
movzwl -0xb0(%rbp),%eax
sar    $0x8,%eax
movzwl -0xb0(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,-0xb0(%rbp)
movzwl -0x88(%rbp),%eax
sar    $0x8,%eax
movzwl -0x88(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,-0x88(%rbp)
lea    -0xc0(%rbp),%rsi
add    $0x8,%rsi
movzwl -0xb0(%rbp),%edx
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc8(%rbp),%rdi
movzwl -0x88(%rbp),%esi
add    $0x20,%esi
mov    0x2d52(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
movl   $0x0,-0xcc(%rbp)
cmpl   $0x63,-0xcc(%rbp)
jg     1304 <main+0x1a4>
mov    -0xc8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,%cl
movslq -0xcc(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
movslq -0xcc(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    12eb <main+0x18b>
movslq -0xcc(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
jmp    1304 <main+0x1a4>
jmp    12f0 <main+0x190>
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    129f <main+0x13f>
lea    -0x80(%rbp),%rsi
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xb0,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
je     1243 <main+0xe3>
mov    0x8(%r14),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     124f <main+0xef>
mov    %rax,%r15
mov    0x2e45(%rip),%r14
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0x20,%esi
call   1060 <fseek@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x40,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
movzwl 0x10(%rsp),%eax
rol    $0x8,%ax
mov    %ax,0x10(%rsp)
rolw   $0x8,0x38(%rsp)
lea    0x8(%rsp),%rsi
movzwl %ax,%edx
lea    0xe4e(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
movzwl 0x38(%rsp),%esi
add    $0x20,%esi
mov    (%r14),%edx
mov    %r15,%rdi
call   1060 <fseek@plt>
nop
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %al,0x40(%rsp,%rbx,1)
cmp    $0xa,%al
je     121c <main+0xbc>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1200 <main+0xa0>
jmp    1221 <main+0xc1>
movb   $0x0,0x40(%rsp,%rbx,1)
lea    0xe14(%rip),%rdi
lea    0x40(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    (%r14),%rsi
lea    0xdb3(%rip),%rdi
jmp    125a <main+0xfa>
mov    0x8(%r14),%rsi
lea    0xdc4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.SlaveInfo = type { i64, [8 x i8], i16, i16, i64, i64, i16, i16, i16, i8, i8, i64, i16, i16, i16 }
%struct.SlaveInfo.0 = type opaque
@.str = [26 x i8] c"Usage: %s filename.slave\0A\00"
@.str.1 = [4 x i8] c"rbe\00"
@.str.2 = [19 x i8] c"Could not open %s\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [11 x i8] c"[%s] [%d]\0A\00"
@.str.4 = [6 x i8] c"[%s]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca %struct.SlaveInfo
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %8
%23 = load i32*, i32** %8
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %31
25: ; preds = %18
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %18
%32 = load i32*, i32** %8
%33 = load i32, i32* @SEEK_SET
%34 = call i32 @fseek(i32* %32, i32 32, i32 %33)
%35 = bitcast %struct.SlaveInfo* %7 to %struct.SlaveInfo.0*
%36 = load i32*, i32** %8
%37 = call i32 @fread(%struct.SlaveInfo.0* %35, i32 1, i32 64, i32* %36)
%38 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 2
%39 = load i16, i16* %38
%40 = zext i16 %39 to i32
%41 = ashr i32 %40, 8
%42 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 2
%43 = load i16, i16* %42
%44 = zext i16 %43 to i32
%45 = shl i32 %44, 8
%46 = or i32 %41, %45
%47 = trunc i32 %46 to i16
%48 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 2
store i16 %47, i16* %48
%49 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 12
%50 = load i16, i16* %49
%51 = zext i16 %50 to i32
%52 = ashr i32 %51, 8
%53 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 12
%54 = load i16, i16* %53
%55 = zext i16 %54 to i32
%56 = shl i32 %55, 8
%57 = or i32 %52, %56
%58 = trunc i32 %57 to i16
%59 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 12
store i16 %58, i16* %59
%60 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 1
%61 = getelementptr inbounds [8 x i8], [8 x i8]* %60, i64 0, i64 0
%62 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 2
%63 = load i16, i16* %62
%64 = zext i16 %63 to i32
%65 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %61, i32 %64)
%66 = load i32*, i32** %8
%67 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %7, i32 0, i32 12
%68 = load i16, i16* %67
%69 = zext i16 %68 to i32
%70 = add nsw i32 %69, 32
%71 = load i32, i32* @SEEK_SET
%72 = call i32 @fseek(i32* %66, i32 %70, i32 %71)
store i32 0, i32* %9
br label %73
73: ; preds = %93, %31
%74 = load i32, i32* %9
%75 = icmp sle i32 %74, 99
br i1 %75, label %76, label %96
76: ; preds = %73
%77 = load i32*, i32** %8
%78 = call signext i8 @fgetc(i32* %77)
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %80
store i8 %78, i8* %81
%82 = load i32, i32* %9
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 10
br i1 %87, label %88, label %92
88: ; preds = %76
%89 = load i32, i32* %9
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %90
store i8 0, i8* %91
br label %96
92: ; preds = %76
br label %93
93: ; preds = %92
%94 = load i32, i32* %9
%95 = add nsw i32 %94, 1
store i32 %95, i32* %9
br label %73
96: ; preds = %88, %73
%97 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%98 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %97)
%99 = load i32, i32* %3
ret i32 %99
}

LLVM IR (-O2):
%struct.SlaveInfo = type { i64, [8 x i8], i16, i16, i64, i64, i16, i16, i16, i8, i8, i64, i16, i16, i16 }
%struct.SlaveInfo.0 = type opaque
@.str = [26 x i8] c"Usage: %s filename.slave\0A\00"
@.str.1 = [4 x i8] c"rbe\00"
@.str.2 = [19 x i8] c"Could not open %s\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [11 x i8] c"[%s] [%d]\0A\00"
@.str.4 = [6 x i8] c"[%s]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca %struct.SlaveInfo
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.SlaveInfo* %4 to i8*
%7 = icmp eq i32 %0, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i8*, i8** %13
%19 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %12
%22 = load i32, i32* @SEEK_SET
%23 = tail call i32 @fseek(i32* %15, i32 32, i32 %22)
%24 = bitcast %struct.SlaveInfo* %4 to %struct.SlaveInfo.0*
%25 = call i32 @fread(%struct.SlaveInfo.0* %24, i32 1, i32 64, i32* %15)
%26 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %4, i64 0, i32 2
%27 = load i16, i16* %26
%28 = tail call i16 @llvm.bswap.i16(i16 %27)
store i16 %28, i16* %26
%29 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %4, i64 0, i32 12
%30 = load i16, i16* %29
%31 = tail call i16 @llvm.bswap.i16(i16 %30)
store i16 %31, i16* %29
%32 = getelementptr inbounds %struct.SlaveInfo, %struct.SlaveInfo* %4, i64 0, i32 1, i64 0
%33 = zext i16 %28 to i32
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %32, i32 %33)
%35 = load i16, i16* %29
%36 = zext i16 %35 to i32
%37 = add nuw nsw i32 %36, 32
%38 = load i32, i32* @SEEK_SET
%39 = call i32 @fseek(i32* %15, i32 %37, i32 %38)
br label %40
40: ; preds = %21, %48
%41 = phi i64 [ 0, %21 ], [ %49, %48 ]
%42 = call signext i8 @fgetc(i32* %15)
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %41
store i8 %42, i8* %43
%44 = icmp eq i8 %42, 10
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = and i64 %41, 4294967295
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %46
store i8 0, i8* %47
br label %51
48: ; preds = %40
%49 = add nuw nsw i64 %41, 1
%50 = icmp eq i64 %49, 100
br i1 %50, label %51, label %40
51: ; preds = %48, %45
%52 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %5)
ret i32 0
}