// File: sjtuwrk[P]SunwayMR/sunwaymr.cpp
// Function: main
int main(int argc, char *argv[]) {
	if (argc <= 1) {
		printUsage();
	} else {
		string cmdType = string(argv[1]);

		if (cmdType == "-t" || cmdType == "-a") {
			if (cmdType == "-t") { // listen
				if (argc >= 6) {
					string master = string(argv[2]);
					int masterListenPort = atoi(argv[3]);
					int threads = atoi(argv[4]);
					int memory = atoi(argv[5]);

					SunwayMRHelper helper = SunwayMRHelper(false);
					helper.start(master, masterListenPort, threads, memory);


				} else {
					printUsage();
				}

			} else { // start app
				if (argc >= 3) {
					string filePath = string(argv[2]);
					bool localMode = false;
					if (argc>3) {
						string argv4 = string(argv[3]);
						if (argv4 == "-local") localMode = true;
					}

					SunwayMRHelper helper = SunwayMRHelper(true);
					helper.runApplication(filePath, localMode);

				} else {
					printUsage();
				}
			}

		} else {
			printUsage();
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x1, -0x8(%rbp)
jg 0xde19
callq 0xdd70
jmp 0xe278
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x448(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x47a0
movq -0x448(%rbp), %rsi
movq -0x440(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0xe8d0
jmp 0xde51
leaq -0x31(%rbp), %rdi
callq 0x4470
leaq 0xca59(%rip), %rsi      # 0x1a8ba
leaq -0x30(%rbp), %rdi
callq 0xef60
movb %al, -0x449(%rbp)
jmp 0xde72
movb -0x449(%rbp), %al
testb $0x1, %al
jne 0xdea5
jmp 0xde7e
leaq 0xca38(%rip), %rsi      # 0x1a8bd
leaq -0x30(%rbp), %rdi
callq 0xef60
movb %al, -0x44a(%rbp)
jmp 0xde96
movb -0x44a(%rbp), %al
testb $0x1, %al
jne 0xdea5
jmp 0xe259
leaq 0xca0e(%rip), %rsi      # 0x1a8ba
leaq -0x30(%rbp), %rdi
callq 0xef60
movb %al, -0x44b(%rbp)
jmp 0xdebd
movb -0x44b(%rbp), %al
testb $0x1, %al
jne 0xdecc
jmp 0xe04f
cmpl $0x6, -0x8(%rbp)
jl 0xe041
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x460(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0x47a0
movq -0x460(%rbp), %rsi
movq -0x458(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0xe8d0
jmp 0xdf0e
leaq -0x69(%rbp), %rdi
callq 0x4470
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x4690
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4690
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x4690
movl %eax, -0x78(%rbp)
leaq -0x210(%rbp), %rdi
xorl %esi, %esi
callq 0xa080
jmp 0xdf57
leaq -0x230(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x41a0
jmp 0xdf69
movl -0x70(%rbp), %edx
movl -0x74(%rbp), %ecx
movl -0x78(%rbp), %r8d
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0xa750
jmp 0xdf88
leaq -0x230(%rbp), %rdi
callq 0x4878
leaq -0x210(%rbp), %rdi
callq 0xabf0
leaq -0x68(%rbp), %rdi
callq 0x4878
jmp 0xe04a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x4470
jmp 0xe283
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe26d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x4470
jmp 0xe26d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe033
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe027
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x4878
leaq -0x210(%rbp), %rdi
callq 0xabf0
leaq -0x68(%rbp), %rdi
callq 0x4878
jmp 0xe26d
callq 0xdd70
jmp 0xe048
jmp 0xe04a
jmp 0xe257
cmpl $0x3, -0x8(%rbp)
jl 0xe24c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x470(%rbp)
leaq -0x251(%rbp), %rdi
movq %rdi, -0x468(%rbp)
callq 0x47a0
movq -0x470(%rbp), %rsi
movq -0x468(%rbp), %rdx
leaq -0x250(%rbp), %rdi
callq 0xe8d0
jmp 0xe097
leaq -0x251(%rbp), %rdi
callq 0x4470
movb $0x0, -0x252(%rbp)
cmpl $0x3, -0x8(%rbp)
jle 0xe191
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x480(%rbp)
leaq -0x279(%rbp), %rdi
movq %rdi, -0x478(%rbp)
callq 0x47a0
movq -0x480(%rbp), %rsi
movq -0x478(%rbp), %rdx
leaq -0x278(%rbp), %rdi
callq 0xe8d0
jmp 0xe0f2
leaq -0x279(%rbp), %rdi
callq 0x4470
leaq 0xc7bb(%rip), %rsi      # 0x1a8c0
leaq -0x278(%rbp), %rdi
callq 0xef60
movb %al, -0x481(%rbp)
jmp 0xe119
movb -0x481(%rbp), %al
testb $0x1, %al
jne 0xe125
jmp 0xe185
movb $0x1, -0x252(%rbp)
jmp 0xe185
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x251(%rbp), %rdi
callq 0x4470
jmp 0xe26d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x279(%rbp), %rdi
callq 0x4470
jmp 0xe23e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x4878
jmp 0xe23e
leaq -0x278(%rbp), %rdi
callq 0x4878
leaq -0x418(%rbp), %rdi
movl $0x1, %esi
callq 0xa080
jmp 0xe1a4
leaq -0x438(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x41a0
jmp 0xe1b9
movzbl -0x252(%rbp), %edx
andl $0x1, %edx
leaq -0x418(%rbp), %rdi
leaq -0x438(%rbp), %rsi
callq 0xb090
jmp 0xe1d8
leaq -0x438(%rbp), %rdi
callq 0x4878
leaq -0x418(%rbp), %rdi
callq 0xabf0
leaq -0x250(%rbp), %rdi
callq 0x4878
jmp 0xe255
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe23e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe232
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x438(%rbp), %rdi
callq 0x4878
leaq -0x418(%rbp), %rdi
callq 0xabf0
leaq -0x250(%rbp), %rdi
callq 0x4878
jmp 0xe26d
callq 0xdd70
jmp 0xe253
jmp 0xe255
jmp 0xe257
jmp 0xe262
callq 0xdd70
jmp 0xe260
jmp 0xe262
leaq -0x30(%rbp), %rdi
callq 0x4878
jmp 0xe278
leaq -0x30(%rbp), %rdi
callq 0x4878
jmp 0xe283
xorl %eax, %eax
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x4780
nopl (%rax)