#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*/ DecodeAnimation(unsigned char *, unsigned short);
unsigned char *ReadFile(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ stderr;
scalar_t__ strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  unsigned char *data;
  unsigned short offset;
  if (argc != 2) {
    fprintf(stderr, "Usage: iscript hexoffset\n");
    return -1;
  }
  offset = (unsigned short)strtoul(argv[1], NULL, 16);
  data = ReadFile("iscript.bin");
  if (!data) {
    return -1;
  }
  DecodeAnimation(data, offset);
  free(data);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ef <main+0x9f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1070 <strtoul@plt>
mov    %ax,-0x1a(%rbp)
lea    0xe68(%rip),%rdi
call   1040 <ReadFile@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d2 <main+0x82>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ef <main+0x9f>
mov    -0x18(%rbp),%rdi
movzwl -0x1a(%rbp),%esi
call   1060 <DecodeAnimation@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    119a <main+0x4a>
mov    0x8(%rsi),%rdi
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <strtoul@plt>
mov    %rax,%r14
lea    0xea3(%rip),%rdi
call   1040 <ReadFile@plt>
test   %rax,%rax
je     11af <main+0x5f>
mov    %rax,%rbx
movzwl %r14w,%esi
mov    %rax,%rdi
call   1060 <DecodeAnimation@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11b5 <main+0x65>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: iscript hexoffset\0A\00"
@.str.1 = [12 x i8] c"iscript.bin\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %29
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strtoul(i8* %16, i32* null, i32 16)
%18 = trunc i64 %17 to i16
store i16 %18, i16* %7
%19 = call i8* @ReadFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %13
store i32 -1, i32* %3
br label %29
23: ; preds = %13
%24 = load i8*, i8** %6
%25 = load i16, i16* %7
%26 = call i32 @DecodeAnimation(i8* %24, i16 zeroext %25)
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
store i32 0, i32* %3
br label %29
29: ; preds = %23, %22, %10
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: iscript hexoffset\0A\00"
@.str.1 = [12 x i8] c"iscript.bin\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %17
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strtoul(i8* nocapture %9, i32* null, i32 16)
%11 = tail call i8* @ReadFile(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = trunc i64 %10 to i16
%15 = tail call i32 @DecodeAnimation(i8* %11, i16 zeroext %14)
%16 = tail call i32 @free(i8* %11)
br label %17
17: ; preds = %7, %13, %4
%18 = phi i32 [ -1, %4 ], [ 0, %13 ], [ -1, %7 ]
ret i32 %18
}