// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/gcx-decompile.c
// Function: gcx_param
uint16_t gcx_param(unsigned char *data, FILE *out) {
	unsigned int i;
	uint16_t size = 0;
	gcxdef blank;
	blank.name = 0;
	blank.off = 0;
	printf("gcx_param == type %04x == size ????\n", data[0]);
	switch(data[0]) {
		case 0x30: {
			size = data[1];
			fprintf(out, "STACKOP!\n");
			break;
		}
		case 0x40: {
			gcx_proc(blank, data, out);
			break;
		}
		case 0x50: {
			// size of params plus param letter
			size = data[2] + 1;
			switch(data[1]) {
				case 'm': {
					fprintf(out, "-m [%02x]:%04x\n", data[3], bswap_16(*(uint16_t *)(data+4)));
					break;
				}
				case 's': {
					fprintf(out, "-s [%02x]:%02x\n", data[3], data[4]);
					break;
				}
				default: {
					fprintf(out, "-%c ", *(char *)(data+1));
					for(i = 0; i < (size-1); size++) fprintf(out, "%02x", data[3+i]);
					fprintf(out, "\n");
					break;
				}
			}
			break;
		}
		default: {
			printf("unknown param %02x size %04x\n", data[0], size);
			break;
		}
	}
	return size+1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw $0x0, -0x16(%rbp)
movw $0x0, -0x1a(%rbp)
movw $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movzbl (%rax), %esi
leaq 0xd44(%rip), %rdi       # 0x2004
xorl %eax, %eax
callq 0x1080
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x20(%rbp)
subl $0x30, %eax
je 0x12ef
jmp 0x12d8
movl -0x20(%rbp), %eax
subl $0x40, %eax
je 0x1312
jmp 0x12e2
movl -0x20(%rbp), %eax
subl $0x50, %eax
je 0x1327
jmp 0x1425
movq -0x8(%rbp), %rax
movzbl 0x1(%rax), %eax
movw %ax, -0x16(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xd23(%rip), %rsi       # 0x2029
movb $0x0, %al
callq 0x1090
jmp 0x143e
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl -0x1a(%rbp), %edi
callq 0x1450
jmp 0x143e
movq -0x8(%rbp), %rax
movzbl 0x2(%rax), %eax
incl %eax
movw %ax, -0x16(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x24(%rbp)
subl $0x6d, %eax
je 0x1351
jmp 0x1347
movl -0x24(%rbp), %eax
subl $0x73, %eax
je 0x138e
jmp 0x13b2
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x3(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x4(%rax), %edi
callq 0x1260
movq -0x30(%rbp), %rdi
movl -0x28(%rbp), %edx
movzwl %ax, %ecx
leaq 0xcb1(%rip), %rsi       # 0x2033
movb $0x0, %al
callq 0x1090
jmp 0x1423
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movzbl 0x3(%rax), %edx
movq -0x8(%rbp), %rax
movzbl 0x4(%rax), %ecx
leaq 0xc9a(%rip), %rsi       # 0x2043
movb $0x0, %al
callq 0x1090
jmp 0x1423
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %edx
leaq 0xc8e(%rip), %rsi       # 0x2053
movb $0x0, %al
callq 0x1090
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movzwl -0x16(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x1411
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %edx
leaq 0xc5c(%rip), %rsi       # 0x2058
movb $0x0, %al
callq 0x1090
movw -0x16(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x16(%rbp)
jmp 0x13d3
movq -0x10(%rbp), %rdi
leaq 0xc15(%rip), %rsi       # 0x2031
movb $0x0, %al
callq 0x1090
jmp 0x143e
movq -0x8(%rbp), %rax
movzbl (%rax), %esi
movzwl -0x16(%rbp), %edx
leaq 0xc26(%rip), %rdi       # 0x205d
movb $0x0, %al
callq 0x1080
movzwl -0x16(%rbp), %eax
addl $0x1, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)