// File: menhits[P]phplus/src/main.cpp
// Function: getFlags(int, char**)
Flags getFlags(int argc, char ** argv)
{
	bool after = false;
	Flags flags;
	
	for (int i=1; i<argc; i++)
	{
		string arg(argv[i]);
		if (!after)
		{
			if (arg.size()>1 && arg[0]=='-')
			{
				string flag=arg.substr(1, string::npos);

				if (flag=="d" || flag=="debug")
				{
					flags.debug=true;
				}
				else if (flag=="v" || flag=="version")
				{
					flags.version=true;
				}
				else if (flag=="h" || flag=="help")
				{
					flags.help=true;
				}
				else if (flag=="r" || flag=="run")
				{
					flags.runCompiled=false;
					flags.runInterpreted=true;
					after = true;
				}
				else if (flag=="cpp")
				{
					if (i+1>=argc)
					{
						cout << "output file harus diikuti '-cpp' flag";
						flags.flagError=true;
					}

					flags.runInterpreted=false;

					flags.cppOutFile=string(argv[i+1]);

					i++;
				}
				else if (flag=="bin")
				{
					if (i+1>=argc)
					{
						cout << "output file harus diikuti '-bin' flag";
						flags.flagError=true;
					}

					flags.runInterpreted=false;

					flags.binOutFile=string(argv[i+1]);

					i++;
				}
				else if (flag=="e" || flag=="execute")
				{
					flags.runCompiled=true;
					flags.runInterpreted=false;
					after = true;
				}
				else
				{
					cout << "flag tidak diketahui '"+flag+"'" << endl;
					flags.flagError=true;
				}
			}
			else
			{
				flags.inFiles.push_back(arg);
				cmdLineArgs.push_back(arg);
			}
		}
		else
		{
			cmdLineArgs.push_back(arg);
		}
	}
	
	return flags;
}

// Assembly:
subq $0x178, %rsp            # imm = 0x178
movq %rdi, 0x60(%rsp)
movq %rdi, %rax
movq %rax, 0x68(%rsp)
movq %rdi, 0x170(%rsp)
movl %esi, 0x16c(%rsp)
movq %rdx, 0x160(%rsp)
movb $0x0, 0x15f(%rsp)
movb $0x0, 0x15e(%rsp)
callq 0xa7d00
movl $0x1, 0x158(%rsp)
movl 0x158(%rsp), %eax
cmpl 0x16c(%rsp), %eax
jge 0xa7bdf
movq 0x160(%rsp), %rax
movslq 0x158(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x50(%rsp)
leaq 0x137(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0xb690
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0x138(%rsp), %rdi
callq 0xb4c0
jmp 0xa75a3
leaq 0x137(%rsp), %rdi
callq 0xb3f0
testb $0x1, 0x15f(%rsp)
jne 0xa7b95
leaq 0x138(%rsp), %rdi
callq 0xb2a0
cmpq $0x1, %rax
jbe 0xa7b63
xorl %eax, %eax
movl %eax, %esi
leaq 0x138(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x48(%rsp)
jmp 0xa75ed
movq 0x48(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xa7b63
leaq 0x100(%rsp), %rdi
leaq 0x138(%rsp), %rsi
movl $0x1, %edx
movq $-0x1, %rcx
callq 0xb3a0
jmp 0xa7621
leaq 0x2dfcf(%rip), %rsi     # 0xd55f7
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x47(%rsp)
jmp 0xa763b
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0xa7669
jmp 0xa7645
leaq 0x2f319(%rip), %rsi     # 0xd6965
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x46(%rsp)
jmp 0xa765f
movb 0x46(%rsp), %al
testb $0x1, %al
jne 0xa7669
jmp 0xa76cf
movq 0x60(%rsp), %rax
movb $0x1, 0x38(%rax)
jmp 0xa7b45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
leaq 0x137(%rsp), %rdi
callq 0xb3f0
jmp 0xa7c08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
jmp 0xa7bd0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
jmp 0xa7b54
leaq 0x2a491(%rip), %rsi     # 0xd1b67
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x45(%rsp)
jmp 0xa76e9
movb 0x45(%rsp), %al
testb $0x1, %al
jne 0xa7717
jmp 0xa76f3
leaq 0x2f271(%rip), %rsi     # 0xd696b
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x44(%rsp)
jmp 0xa770d
movb 0x44(%rsp), %al
testb $0x1, %al
jne 0xa7717
jmp 0xa7725
movq 0x60(%rsp), %rax
movb $0x1, 0x3a(%rax)
jmp 0xa7b43
leaq 0x2dc68(%rip), %rsi     # 0xd5394
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x43(%rsp)
jmp 0xa773f
movb 0x43(%rsp), %al
testb $0x1, %al
jne 0xa776d
jmp 0xa7749
leaq 0x2f223(%rip), %rsi     # 0xd6973
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x42(%rsp)
jmp 0xa7763
movb 0x42(%rsp), %al
testb $0x1, %al
jne 0xa776d
jmp 0xa777b
movq 0x60(%rsp), %rax
movb $0x1, 0x39(%rax)
jmp 0xa7b41
leaq 0x2a63c(%rip), %rsi     # 0xd1dbe
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x41(%rsp)
jmp 0xa7795
movb 0x41(%rsp), %al
testb $0x1, %al
jne 0xa77c3
jmp 0xa779f
leaq 0x2f1d2(%rip), %rsi     # 0xd6978
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x40(%rsp)
jmp 0xa77b9
movb 0x40(%rsp), %al
testb $0x1, %al
jne 0xa77c3
jmp 0xa77e0
movq 0x60(%rsp), %rax
movb $0x0, 0x80(%rax)
movb $0x1, 0x3b(%rax)
movb $0x1, 0x15f(%rsp)
jmp 0xa7b3f
leaq 0x2f117(%rip), %rsi     # 0xd68fe
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x3f(%rsp)
jmp 0xa77fa
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0xa7807
jmp 0xa78f5
movl 0x158(%rsp), %eax
addl $0x1, %eax
cmpl 0x16c(%rsp), %eax
jl 0xa783b
movq 0x7078f(%rip), %rdi     # 0x117fb0
leaq 0x2f154(%rip), %rsi     # 0xd697c
callq 0xb380
jmp 0xa782f
movq 0x60(%rsp), %rax
movb $0x1, 0x81(%rax)
movq 0x60(%rsp), %rax
movb $0x0, 0x3b(%rax)
movq 0x160(%rsp), %rax
movslq 0x158(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
leaq 0xdf(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xb690
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0xe0(%rsp), %rdi
callq 0xb4c0
jmp 0xa7889
movq 0x60(%rsp), %rdi
addq $0x40, %rdi
leaq 0xe0(%rsp), %rsi
callq 0xb450
leaq 0xe0(%rsp), %rdi
callq 0xb6e8
leaq 0xdf(%rsp), %rdi
callq 0xb3f0
movl 0x158(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x158(%rsp)
jmp 0xa7b3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
leaq 0xdf(%rsp), %rdi
callq 0xb3f0
jmp 0xa7b54
leaq 0x2f0a6(%rip), %rsi     # 0xd69a2
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0x27(%rsp)
jmp 0xa790f
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0xa791c
jmp 0xa7a0a
movl 0x158(%rsp), %eax
addl $0x1, %eax
cmpl 0x16c(%rsp), %eax
jl 0xa7950
movq 0x7067a(%rip), %rdi     # 0x117fb0
leaq 0x2f069(%rip), %rsi     # 0xd69a6
callq 0xb380
jmp 0xa7944
movq 0x60(%rsp), %rax
movb $0x1, 0x81(%rax)
movq 0x60(%rsp), %rax
movb $0x0, 0x3b(%rax)
movq 0x160(%rsp), %rax
movslq 0x158(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
leaq 0xb7(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xb690
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0xb8(%rsp), %rdi
callq 0xb4c0
jmp 0xa799e
movq 0x60(%rsp), %rdi
addq $0x60, %rdi
leaq 0xb8(%rsp), %rsi
callq 0xb450
leaq 0xb8(%rsp), %rdi
callq 0xb6e8
leaq 0xb7(%rsp), %rdi
callq 0xb3f0
movl 0x158(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x158(%rsp)
jmp 0xa7b3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
leaq 0xb7(%rsp), %rdi
callq 0xb3f0
jmp 0xa7b54
leaq 0x29739(%rip), %rsi     # 0xd114a
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0xf(%rsp)
jmp 0xa7a24
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xa7a52
jmp 0xa7a2e
leaq 0x2ef97(%rip), %rsi     # 0xd69cc
leaq 0x100(%rsp), %rdi
callq 0x2d740
movb %al, 0xe(%rsp)
jmp 0xa7a48
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xa7a52
jmp 0xa7a6f
movq 0x60(%rsp), %rax
movb $0x1, 0x80(%rax)
movb $0x0, 0x3b(%rax)
movb $0x1, 0x15f(%rsp)
jmp 0xa7b39
leaq 0x2ef5e(%rip), %rsi     # 0xd69d4
leaq 0x70(%rsp), %rdi
leaq 0x100(%rsp), %rdx
callq 0xfab0
jmp 0xa7a8a
leaq 0x2f009(%rip), %rdx     # 0xd6a9a
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xfa60
jmp 0xa7aa5
movq 0x70504(%rip), %rdi     # 0x117fb0
leaq 0x90(%rsp), %rsi
callq 0xb340
movq %rax, (%rsp)
jmp 0xa7abf
movq (%rsp), %rdi
movq 0x704b6(%rip), %rsi     # 0x117f80
callq 0xb3c0
jmp 0xa7ad1
leaq 0x90(%rsp), %rdi
callq 0xb6e8
leaq 0x70(%rsp), %rdi
callq 0xb6e8
movq 0x60(%rsp), %rax
movb $0x1, 0x81(%rax)
jmp 0xa7b39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
jmp 0xa7b2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x128(%rsp)
movl %eax, 0x124(%rsp)
leaq 0x90(%rsp), %rdi
callq 0xb6e8
leaq 0x70(%rsp), %rdi
callq 0xb6e8
jmp 0xa7b54
jmp 0xa7b3b
jmp 0xa7b3d
jmp 0xa7b3f
jmp 0xa7b41
jmp 0xa7b43
jmp 0xa7b45
leaq 0x100(%rsp), %rdi
callq 0xb6e8
jmp 0xa7b93
leaq 0x100(%rsp), %rdi
callq 0xb6e8
jmp 0xa7bd0
movq 0x60(%rsp), %rdi
addq $0x20, %rdi
leaq 0x138(%rsp), %rsi
callq 0x2e5d0
jmp 0xa7b7b
leaq 0x7099e(%rip), %rdi     # 0x118520
leaq 0x138(%rsp), %rsi
callq 0x2e5d0
jmp 0xa7b91
jmp 0xa7b93
jmp 0xa7bad
leaq 0x70984(%rip), %rdi     # 0x118520
leaq 0x138(%rsp), %rsi
callq 0x2e5d0
jmp 0xa7bab
jmp 0xa7bad
leaq 0x138(%rsp), %rdi
callq 0xb6e8
movl 0x158(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x158(%rsp)
jmp 0xa754b
leaq 0x138(%rsp), %rdi
callq 0xb6e8
jmp 0xa7c08
movb $0x1, 0x15e(%rsp)
testb $0x1, 0x15e(%rsp)
jne 0xa7bfb
movq 0x60(%rsp), %rdi
callq 0xa7cb0
movq 0x68(%rsp), %rax
addq $0x178, %rsp            # imm = 0x178
retq
movq 0x60(%rsp), %rdi
callq 0xa7cb0
movq 0x128(%rsp), %rdi
callq 0xb680
nop