// File: ticky[P]ps2iconsys/src/iconsys_builder.cpp
// Function: main
int main(int argc, char* argv[])
{
	ParseCommandLine(argc, argv);

	if(argc < 2) {
		std::cout << "No parameters specified." << std::endl << std::endl;
		PrintHelp(argv[0]);
		exit(1);
	}

	CheckParameters();

	std::cout << "PS2 Icon.Sys Builder  V-1.0\n by Ghulbus Inc.  (http://www.ghulbus-inc.de/)\n" << std::endl;

	if(!output_file) {
		output_file = "icon.sys";
	}

	IconSys* icon_sys = NULL;

	if(input_file) {
		if(verbose_output)
			std::cout << " * Reading input file \"" << input_file << "\"...";
		try {
			icon_sys = new IconSys(input_file);
		} catch(Ghulbus::gbException e) {
			std::cout << "\nFile read error: \"" << input_file << "\"" << std::endl;
		}
		if(verbose_output)
			std::cout << "done." << std::endl;
	} else {
		icon_sys = new IconSys();
	}

	ProcessParameters(icon_sys);

	WriteOutput(icon_sys);

	if(list_file) {
		ListFile(icon_sys);
	}

	Cleanup();	
	delete icon_sys;

	std::cout << "Success :)" << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x106d0
cmpl $0x2, -0x8(%rbp)
jge 0x12892
movq 0x8786(%rip), %rdi      # 0x1afd8
leaq 0x1c19(%rip), %rsi      # 0x14472
callq 0x21c0
movq %rax, %rdi
movq 0x8758(%rip), %rsi      # 0x1afc0
callq 0x21f0
movq %rax, %rdi
movq 0x8749(%rip), %rsi      # 0x1afc0
callq 0x21f0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xf380
movl $0x1, %edi
callq 0x2230
callq 0x10910
movq 0x873a(%rip), %rdi      # 0x1afd8
leaq 0x1be6(%rip), %rsi      # 0x1448b
callq 0x21c0
movq %rax, %rdi
movq 0x870c(%rip), %rsi      # 0x1afc0
callq 0x21f0
cmpq $0x0, 0x89d7(%rip)      # 0x1b298
jne 0x128d1
leaq 0x14b0(%rip), %rax      # 0x13d7a
movq %rax, 0x89c7(%rip)      # 0x1b298
movq $0x0, -0x18(%rbp)
cmpq $0x0, 0x89af(%rip)      # 0x1b290
je 0x12a5f
testb $0x1, 0x89b3(%rip)      # 0x1b2a1
je 0x12921
movq 0x86e1(%rip), %rdi      # 0x1afd8
leaq 0x1bd9(%rip), %rsi      # 0x144d7
callq 0x21c0
movq %rax, %rdi
movq 0x8983(%rip), %rsi      # 0x1b290
callq 0x21c0
movq %rax, %rdi
leaq 0x1b3c(%rip), %rsi      # 0x14458
callq 0x21c0
movl $0x42c, %edi            # imm = 0x42C
callq 0x21d0
movq %rax, -0x48(%rbp)
jmp 0x12931
movq -0x48(%rbp), %rdi
movq 0x8954(%rip), %rsi      # 0x1b290
callq 0x82d0
jmp 0x12943
movq -0x48(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x12a0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x12978
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x42c, %esi            # imm = 0x42C
callq 0x21e0
movl -0x24(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x12b1b
movq -0x20(%rbp), %rdi
movq %rdi, -0x58(%rbp)
callq 0x2250
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0xf120
movq -0x58(%rbp), %rdi
callq 0x20c0
movq 0x8627(%rip), %rdi      # 0x1afd8
leaq 0x1b37(%rip), %rsi      # 0x144ef
callq 0x21c0
movq %rax, -0x50(%rbp)
jmp 0x129c3
movq -0x50(%rbp), %rdi
movq 0x88c2(%rip), %rsi      # 0x1b290
callq 0x21c0
movq %rax, -0x60(%rbp)
jmp 0x129d9
movq -0x60(%rbp), %rdi
leaq 0x1918(%rip), %rsi      # 0x142fc
callq 0x21c0
movq %rax, -0x68(%rbp)
jmp 0x129ef
movq -0x68(%rbp), %rdi
movq 0x85c6(%rip), %rsi      # 0x1afc0
callq 0x21f0
jmp 0x12a01
leaq -0x40(%rbp), %rdi
callq 0xf170
callq 0x2350
testb $0x1, 0x888b(%rip)      # 0x1b2a1
je 0x12a5d
movq 0x85b9(%rip), %rdi      # 0x1afd8
leaq 0x189e(%rip), %rsi      # 0x142c4
callq 0x21c0
movq %rax, %rdi
movq 0x858b(%rip), %rsi      # 0x1afc0
callq 0x21f0
jmp 0x12a5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xf170
callq 0x2350
jmp 0x12a58
jmp 0x12b1b
jmp 0x12aa0
movl $0x42c, %edi            # imm = 0x42C
callq 0x21d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
callq 0x8030
jmp 0x12a7a
movq -0x70(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x12aa0
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x42c, %esi            # imm = 0x42C
callq 0x21e0
jmp 0x12b1b
movq -0x18(%rbp), %rdi
callq 0x10a40
movq -0x18(%rbp), %rdi
callq 0x123d0
testb $0x1, 0x87e7(%rip)      # 0x1b2a0
je 0x12ac4
movq -0x18(%rbp), %rdi
callq 0x11370
callq 0x12540
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0x12aee
movq -0x78(%rbp), %rdi
callq 0x8510
movq -0x78(%rbp), %rdi
movl $0x42c, %esi            # imm = 0x42C
callq 0x21e0
movq 0x84e3(%rip), %rdi      # 0x1afd8
leaq 0x1a07(%rip), %rsi      # 0x14503
callq 0x21c0
movq %rax, %rdi
movq 0x84b5(%rip), %rsi      # 0x1afc0
callq 0x21f0
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x2390
movq %rax, %rdi
callq 0x5490
nopl (%rax)