// File: /workspace/github_c_makefile_star2_O0/rajatxjain[P]gpiocfg/gpiocfg.c
// Function: main
int main(int argc, char **argv)
{
	int c;
        struct community *cmty = NULL;
        unsigned int pin_no_in_cmty;
	u_int32_t dw0 = 0, dw1 = 0;
	char pin_name[MAX_PIN_NAME_WIDTH] = "";

	if (argc <= 1) {
		usage(argv[0]);
		return -1;
	}

	while (1) {
		static struct option long_options[] = {
			{"platform", required_argument, 0, 'p'},
			{"read", required_argument, 0, 'r'},
			{"value", required_argument, 0, 'v'},
			{"list", no_argument, 0, 'l'},
			{"help", no_argument, 0, 'h'},
			{0, 0, 0, 0}
		};
		int option_index = 0;
		c = getopt_long (argc, argv, "p:r:v:lh", long_options,
				 &option_index);
		if (c == -1)
			break;

		switch (c) {
		case 'p':
			printf("Platform requested            : %s\n", optarg);
			platform = lookup_platform(optarg);
			break;
		case 'r':
			printf("Pin lookup requested for pin  : %s\n", optarg);
			if (!lookup_pin(optarg, &cmty, &pin_no_in_cmty)) {
				printf("Pin lookup failure: %s\n", optarg);
				return -1;
			}
			strcpy(pin_name, optarg);
			break;
		case 'v':
			dw0 = (u_int32_t) strtoul(optarg, NULL, 0);
			printf("DW0 Value parse requested for : 0x%08X\n", dw0);
			break;
		case 'l':
			list_gpios();
			return 0;
		case 'h':
		case '?':
			/* getopt_long already printed an error message. */
		default:
			usage(argv[0]);
			return -1;
		}
	}
	if (!cmty && !dw0) {
		usage(argv[0]);
		return -1;
	}
		

	printf("Platform : %s\n", platform->name);

	if (cmty)
		read_pin_pad(pin_name, &dw0, &dw1);

	parse_dw0(dw0);
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x1070
cmpl $0x1, -0x8(%rbp)
jg 0x124a
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1410
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13fe
jmp 0x124c
movl $0x0, -0x54(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x1ee9(%rip), %rdx      # 0x314a
leaq 0x4e68(%rip), %rcx      # 0x60d0
leaq -0x54(%rbp), %r8
callq 0x1050
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x127f
jmp 0x139d
movl -0x14(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x37, %eax
ja 0x1383
movq -0x60(%rbp), %rax
leaq 0x1d65(%rip), %rcx      # 0x3004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x4d31(%rip), %rax      # 0x5fe0
movq (%rax), %rsi
leaq 0x1e9a(%rip), %rdi      # 0x3153
movb $0x0, %al
callq 0x1060
movq 0x4d19(%rip), %rax      # 0x5fe0
movq (%rax), %rdi
callq 0x14a0
movq %rax, 0x4dea(%rip)      # 0x60c0
jmp 0x1398
movq 0x4cfe(%rip), %rax      # 0x5fe0
movq (%rax), %rsi
leaq 0x1e8b(%rip), %rdi      # 0x3177
movb $0x0, %al
callq 0x1060
movq 0x4ce6(%rip), %rax      # 0x5fe0
movq (%rax), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x24(%rbp), %rdx
callq 0x1530
cmpl $0x0, %eax
jne 0x1333
movq 0x4cca(%rip), %rax      # 0x5fe0
movq (%rax), %rsi
leaq 0x1e7b(%rip), %rdi      # 0x319b
movb $0x0, %al
callq 0x1060
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13fe
leaq -0x50(%rbp), %rdi
movq 0x4ca2(%rip), %rax      # 0x5fe0
movq (%rax), %rsi
callq 0x1030
jmp 0x1398
movq 0x4c91(%rip), %rax      # 0x5fe0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x10c0
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %esi
leaq 0x1e49(%rip), %rdi      # 0x31b3
movb $0x0, %al
callq 0x1060
jmp 0x1398
callq 0x2010
movl $0x0, -0x4(%rbp)
jmp 0x13fe
jmp 0x1383
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1410
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13fe
jmp 0x124c
cmpq $0x0, -0x20(%rbp)
jne 0x13bf
cmpl $0x0, -0x28(%rbp)
jne 0x13bf
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1410
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x13fe
movq 0x4cfa(%rip), %rax      # 0x60c0
movq (%rax), %rsi
leaq 0x1e0b(%rip), %rdi      # 0x31db
movb $0x0, %al
callq 0x1060
cmpq $0x0, -0x20(%rbp)
je 0x13ef
leaq -0x50(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x1600
movl -0x28(%rbp), %edi
callq 0x17a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)