#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*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  FILE *file = fopen(argv[1], "r+b");
  if (file == 0) {
    printf("Could not open file\n");
    printf("Usage: frigate-skipper path/to/dol/file.dol\n");
  } else {
    int firstOffset = 0x1FF1E;
    int secondOffset = 0x1FF2A;
    fseek(file, firstOffset, SEEK_SET);
    unsigned char firstValue[] = {0x39, 0xF3};
    fwrite(firstValue, sizeof *firstValue, sizeof firstValue, file);
    fseek(file, secondOffset, SEEK_SET);
    unsigned char secondValue[] = {0xDE, 0x28};
    fwrite(secondValue, sizeof *secondValue, sizeof secondValue, file);
    fclose(file);
  }
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a6 <main+0x56>
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
jmp    122b <main+0xdb>
movl   $0x1ff1e,-0x1c(%rbp)
movl   $0x1ff2a,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    0xe76(%rip),%ax
mov    %ax,-0x22(%rbp)
lea    -0x22(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1070 <fwrite@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    0x2de7(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    0xe41(%rip),%ax
mov    %ax,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1070 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11d9 <main+0x89>
mov    %rax,%rbx
mov    0x2e6d(%rip),%r14
mov    (%r14),%edx
mov    %rax,%rdi
mov    $0x1ff1e,%esi
call   1050 <fseek@plt>
movw   $0xf339,0x6(%rsp)
lea    0x6(%rsp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x1ff2a,%esi
call   1050 <fseek@plt>
movw   $0x28de,0x4(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11f1 <main+0xa1>
lea    0xe24(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"r+b\00"
@.str.1 = [21 x i8] c"Could not open file\0A\00"
@.str.2 = [45 x i8] c"Usage: frigate-skipper path/to/dol/file.dol\0A\00"
@SEEK_SET = global i32 0
@__const.main.firstValue = [2 x i8] c"9\F3"
@__const.main.secondValue = [2 x i8] c"\DE("
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 [2 x i8]
%10 = alloca [2 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %39
20: ; preds = %2
store i32 130846, i32* %7
store i32 130858, i32* %8
%21 = load i32*, i32** %6
%22 = load i32, i32* %7
%23 = load i32, i32* @SEEK_SET
%24 = call i32 @fseek(i32* %21, i32 %22, i32 %23)
%25 = bitcast [2 x i8]* %9 to i8*
%26 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%27 = load i32*, i32** %6
%28 = call i32 @fwrite(i8* %26, i32 1, i32 2, i32* %27)
%29 = load i32*, i32** %6
%30 = load i32, i32* %8
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %29, i32 %30, i32 %31)
%33 = bitcast [2 x i8]* %10 to i8*
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%35 = load i32*, i32** %6
%36 = call i32 @fwrite(i8* %34, i32 1, i32 2, i32* %35)
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
br label %39
39: ; preds = %20, %17
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [4 x i8] c"r+b\00"
@SEEK_SET = global i32 0
@str = [20 x i8] c"Could not open file\00"
@str.3 = [44 x i8] c"Usage: frigate-skipper path/to/dol/file.dol\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = alloca i16
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.3, i64 0, i64 0))
br label %22
12: ; preds = %2
%13 = load i32, i32* @SEEK_SET
%14 = tail call i32 @fseek(i32* %7, i32 130846, i32 %13)
%15 = bitcast i16* %3 to i8*
store i16 -3271, i16* %3
%16 = call i32 @fwrite(i8* %15, i32 1, i32 2, i32* %7)
%17 = load i32, i32* @SEEK_SET
%18 = tail call i32 @fseek(i32* %7, i32 130858, i32 %17)
%19 = bitcast i16* %4 to i8*
store i16 10462, i16* %4
%20 = call i32 @fwrite(i8* %19, i32 1, i32 2, i32* %7)
%21 = tail call i32 @fclose(i32* %7)
br label %22
22: ; preds = %12, %9
ret i32 0
}