#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*/ CleanUp();
int /*<<< orphan*/ FindResourceNames();
int /*<<< orphan*/ OpenFile(char *);
int /*<<< orphan*/ WriteGfxFiles();
int /*<<< orphan*/ WriteGfxHeader1();
int /*<<< orphan*/ WriteGfxHeader2();
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  if (argc == 2) {
    OpenFile(argv[1]);
    FindResourceNames();
    WriteGfxHeader1();
    WriteGfxFiles();
    WriteGfxHeader2();
    CleanUp();
    printf("Graphics extracted successfully");
  } else {
    printf(
        "GfxLink2 v1.0 by David Kinder.\n\n"
        "Extractor for the pictures in the Magnetic Windows versions of\n"
        "Magnetic Scrolls games (Wonderland and the MS Collection Volume 1),\n"
        "Amiga versions.\n\n"
        "Usage: GfxLink2 user.rsc\n\n"
        "\"user.rsc\" is taken from an Amiga Magnetic Scrolls installation\n"
        "in which the option to expand all the graphics files has been\n"
        "selected. For Wonderland there is only one output file\n"
        "(\"wonder.gfx\"), for the Collection there are three "
        "(\"corrupt.gfx\",\n"
        "\"fish.gfx\" and \"guild.gfx\").\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11d1 <main+0x61>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <OpenFile@plt>
mov    $0x0,%al
call   1090 <FindResourceNames@plt>
mov    $0x0,%al
call   1060 <WriteGfxHeader1@plt>
mov    $0x0,%al
call   1080 <WriteGfxFiles@plt>
mov    $0x0,%al
call   1030 <WriteGfxHeader2@plt>
mov    $0x0,%al
call   1070 <CleanUp@plt>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
jmp    11dd <main+0x6d>
lea    0xe48(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    11c0 <main+0x40>
mov    0x8(%rsi),%rdi
call   1040 <OpenFile@plt>
xor    %eax,%eax
call   10a0 <FindResourceNames@plt>
xor    %eax,%eax
call   1070 <WriteGfxHeader1@plt>
xor    %eax,%eax
call   1090 <WriteGfxFiles@plt>
xor    %eax,%eax
call   1030 <WriteGfxHeader2@plt>
xor    %eax,%eax
call   1080 <CleanUp@plt>
lea    0xe47(%rip),%rdi
call   1060 <printf@plt>
jmp    11cc <main+0x4c>
lea    0xe59(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Graphics extracted successfully\00"
@.str.1 = [484 x i8] c"GfxLink2 v1.0 by David Kinder.\0A\0AExtractor for the pictures in the Magnetic Windows versions of\0AMagnetic Scrolls games (Wonderland and the MS Collection Volume 1),\0AAmiga versions.\0A\0AUsage: GfxLink2 user.rsc\0A\0A\22user.rsc\22 is taken from an Amiga Magnetic Scrolls installation\0Ain which the option to expand all the graphics files has been\0Aselected. For Wonderland there is only one output file\0A(\22wonder.gfx\22), for the Collection there are three (\22corrupt.gfx\22,\0A\22fish.gfx\22 and \22guild.gfx\22).\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @OpenFile(i8* %11)
%13 = call i32 (...) @FindResourceNames()
%14 = call i32 (...) @WriteGfxHeader1()
%15 = call i32 (...) @WriteGfxFiles()
%16 = call i32 (...) @WriteGfxHeader2()
%17 = call i32 (...) @CleanUp()
%18 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([484 x i8], [484 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Graphics extracted successfully\00"
@str = [483 x i8] c"GfxLink2 v1.0 by David Kinder.\0A\0AExtractor for the pictures in the Magnetic Windows versions of\0AMagnetic Scrolls games (Wonderland and the MS Collection Volume 1),\0AAmiga versions.\0A\0AUsage: GfxLink2 user.rsc\0A\0A\22user.rsc\22 is taken from an Amiga Magnetic Scrolls installation\0Ain which the option to expand all the graphics files has been\0Aselected. For Wonderland there is only one output file\0A(\22wonder.gfx\22), for the Collection there are three (\22corrupt.gfx\22,\0A\22fish.gfx\22 and \22guild.gfx\22).\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @OpenFile(i8* %6)
%8 = tail call i32 (...) @FindResourceNames()
%9 = tail call i32 (...) @WriteGfxHeader1()
%10 = tail call i32 (...) @WriteGfxFiles()
%11 = tail call i32 (...) @WriteGfxHeader2()
%12 = tail call i32 (...) @CleanUp()
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %16
14: ; preds = %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([483 x i8], [483 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %14, %4
ret i32 0
}