// File: /workspace/github_c_makefile_star2_O0/been-jamming[P]MinimalCC/compile.c
// Function: parse_arguments
void parse_arguments(int argc, char **argv, char *filenames[], unsigned int num_filenames, char **output_filename){
	unsigned int current_arg;
	unsigned int current_filename = 0;
	enum cmd_argtype argtype = cmd_source_file;

	for(current_arg = 1; current_arg < argc; current_arg++){
		switch(argtype){
			case cmd_source_file:
				if(argv[current_arg][0] == '-'){
					if(argv[current_arg][1] == 'h' || (argv[current_arg][1] == '-' && argv[current_arg][2] == 'h')){//Display help message
						printf("Arguments:\n-h --help     Displays this help message\n-o            Specify output file\n\nTo compile:\nmcc [SOURCE1] [SOURCE2] [SOURCE3] ... -o [OUTPUT_FILE]\n");
						exit(1);
					} else if(argv[current_arg][1] == 'o'){
						argtype = cmd_output_file;
					} else {
						fprintf(stderr, "Unrecognized option '%s'\n", argv[current_arg]);
						exit(1);
					}
				} else {
					if(current_filename < num_filenames){
						filenames[current_filename] = argv[current_arg];
						current_filename++;
					} else {
						fprintf(stderr, "Too many source files\n");
						exit(1);
					}
				}
				break;
			case cmd_output_file:
				if(argv[current_arg][0] == '-'){
					fprintf(stderr, "Expected output file name after '-o'\n");
					exit(1);
				}
				*output_filename = argv[current_arg];
				argtype = cmd_source_file;
				break;
		}
	}
}

// Assembly:
subq $0x38, %rsp
movl %edi, 0x34(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movl %ecx, 0x1c(%rsp)
movq %r8, 0x10(%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl $0x1, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x34(%rsp), %eax
jae 0xaaa2
movl 0x4(%rsp), %eax
movl %eax, (%rsp)
testl %eax, %eax
je 0xa91f
jmp 0xa90e
movl (%rsp), %eax
subl $0x1, %eax
je 0xaa3c
jmp 0xaa90
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xa9e5
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x68, %eax
je 0xa97a
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0xa992
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movsbl 0x2(%rax), %eax
cmpl $0x68, %eax
jne 0xa992
leaq 0x36f6(%rip), %rdi      # 0xe077
movb $0x0, %al
callq 0x1090
movl $0x1, %edi
callq 0x1170
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x6f, %eax
jne 0xa9b2
movl $0x1, 0x4(%rsp)
jmp 0xa9e1
movq 0x663f(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rdx
leaq 0x3742(%rip), %rsi      # 0xe112
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1170
jmp 0xa9e3
jmp 0xaa3a
movl 0x8(%rsp), %eax
cmpl 0x1c(%rsp), %eax
jae 0xaa16
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rdx
movq 0x20(%rsp), %rax
movl 0x8(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0xaa38
movq 0x65db(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x3705(%rip), %rsi      # 0xe12c
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1170
jmp 0xaa3a
jmp 0xaa90
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xaa73
movq 0x65a0(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x36e1(%rip), %rsi      # 0xe143
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1170
movq 0x28(%rsp), %rax
movl 0xc(%rsp), %ecx
movq (%rax,%rcx,8), %rcx
movq 0x10(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x4(%rsp)
jmp 0xaa92
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xa8f3
addq $0x38, %rsp
retq
nopw (%rax,%rax)