// File: AndreRenaud[P]simple_options/simple_options_test.c
// Function: simple_args
static void simple_args(void)
{
	const char *file = NULL;
	const char *filename = NULL;
	int64_t val = 5;
	float fval = 1.0;
	bool flag = false;
	struct option_entry entries[] = {
		{"filename", 'z', "Alternative filename", OPTION_FLAG_string, .string = &filename},
		{"file", 'f', "File to load", OPTION_FLAG_string, .string = &file},
		{"number", 'n', "Number", OPTION_FLAG_int, .integer = &val},
		{"bool", 'b', "Boolean", OPTION_FLAG_bool, .boolean = &flag},
		{"float", 'l', "Floating", OPTION_FLAG_float, .floating = &fval},
		{"missing", 'm', "Missing"},
		{NULL, 0},
	};
	const char *args[] = {"program", "--file", "fnord", "--number", "7", "--bool", "on", "--float", "0.57", "--filename", "wibble"};
	TEST_CHECK(opt_parse(11, args, entries) >= 0);
	TEST_CHECK(file && strcmp(file, "fnord") == 0);
	TEST_CHECK(filename && strcmp(filename, "wibble") == 0);
	TEST_CHECK(val == 7);
	TEST_CHECK(opt_parse_present('f', entries));
	TEST_CHECK(!opt_parse_present('m', entries));
	TEST_CHECK(opt_parse_present_long("bool", entries));
	TEST_CHECK(opt_parse_present_long("file", entries));
	TEST_CHECK(!opt_parse_present_long("unknown", entries));
	TEST_CHECK(opt_parse_present_long("float", entries));
	TEST_CHECK(fval > 0.56999 && fval < 0.57001);
	TEST_CHECK(flag == true);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq $0x0, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x5, -0x18(%rbp)
movss 0x2111(%rip), %xmm0     # 0x714c
movss %xmm0, -0x1c(%rbp)
movb $0x0, -0x1d(%rbp)
leaq 0x2dc8(%rip), %rax      # 0x7e13
movq %rax, -0x170(%rbp)
movb $0x7a, -0x168(%rbp)
leaq 0x2da7(%rip), %rax      # 0x7e07
movq %rax, -0x160(%rbp)
movl $0x4, -0x158(%rbp)
leaq -0x10(%rbp), %rax
movq %rax, -0x150(%rbp)
movb $0x0, -0x148(%rbp)
leaq 0x2dd1(%rip), %rax      # 0x7e5b
movq %rax, -0x140(%rbp)
movb $0x66, -0x138(%rbp)
leaq 0x2d7d(%rip), %rax      # 0x7e1c
movq %rax, -0x130(%rbp)
movl $0x4, -0x128(%rbp)
leaq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
movb $0x0, -0x118(%rbp)
leaq 0x2d9f(%rip), %rax      # 0x7e68
movq %rax, -0x110(%rbp)
movb $0x6e, -0x108(%rbp)
leaq 0x2d4b(%rip), %rax      # 0x7e29
movq %rax, -0x100(%rbp)
movl $0x2, -0xf8(%rbp)
leaq -0x18(%rbp), %rax
movq %rax, -0xf0(%rbp)
movb $0x0, -0xe8(%rbp)
leaq 0x2d69(%rip), %rax      # 0x7e71
movq %rax, -0xe0(%rbp)
movb $0x62, -0xd8(%rbp)
leaq 0x2d13(%rip), %rax      # 0x7e30
movq %rax, -0xd0(%rbp)
movl $0x1, -0xc8(%rbp)
leaq -0x1d(%rbp), %rax
movq %rax, -0xc0(%rbp)
movb $0x0, -0xb8(%rbp)
leaq 0x2d31(%rip), %rax      # 0x7e78
movq %rax, -0xb0(%rbp)
movb $0x6c, -0xa8(%rbp)
leaq 0x2cdc(%rip), %rax      # 0x7e38
movq %rax, -0xa0(%rbp)
movl $0x8, -0x98(%rbp)
leaq -0x1c(%rbp), %rax
movq %rax, -0x90(%rbp)
movb $0x0, -0x88(%rbp)
leaq -0x170(%rbp), %rdi
addq $0xf0, %rdi
leaq 0x2cad(%rip), %rax      # 0x7e41
movq %rax, -0x80(%rbp)
movb $0x6d, -0x78(%rbp)
leaq 0x2ca6(%rip), %rax      # 0x7e49
movq %rax, -0x70(%rbp)
movl $0x0, -0x68(%rbp)
addq $0x20, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2120
movb $0x0, -0x58(%rbp)
leaq -0x170(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
xorl %esi, %esi
movl $0x30, %edx
callq 0x2120
leaq -0x1d0(%rbp), %rdi
leaq 0x5a96(%rip), %rsi      # 0xac80
movl $0x58, %edx
callq 0x21a0
leaq -0x1d0(%rbp), %rsi
leaq -0x170(%rbp), %rdx
movl $0xb, %edi
callq 0x2660
cmpl $0x0, %eax
setge %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x2c70(%rip), %rsi      # 0x7e8e
movl $0x15, %edx
leaq 0x1e27(%rip), %rcx      # 0x7051
leaq 0x2c73(%rip), %r8       # 0x7ea4
movb $0x0, %al
callq 0x3080
xorl %eax, %eax
cmpq $0x0, -0x8(%rbp)
movb %al, -0x1d1(%rbp)
je 0x5263
movq -0x8(%rbp), %rdi
leaq 0x2c0e(%rip), %rsi      # 0x7e60
callq 0x2170
cmpl $0x0, %eax
sete %al
movb %al, -0x1d1(%rbp)
movb -0x1d1(%rbp), %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x2c19(%rip), %rsi      # 0x7e8e
movl $0x16, %edx
leaq 0x1dd0(%rip), %rcx      # 0x7051
leaq 0x2c3e(%rip), %r8       # 0x7ec6
movb $0x0, %al
callq 0x3080
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x1d2(%rbp)
je 0x52ba
movq -0x10(%rbp), %rdi
leaq 0x2fcd(%rip), %rsi      # 0x8276
callq 0x2170
cmpl $0x0, %eax
sete %al
movb %al, -0x1d2(%rbp)
movb -0x1d2(%rbp), %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x2bc2(%rip), %rsi      # 0x7e8e
movl $0x17, %edx
leaq 0x1d79(%rip), %rcx      # 0x7051
leaq 0x2c0a(%rip), %r8       # 0x7ee9
movb $0x0, %al
callq 0x3080
cmpq $0x7, -0x18(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x2b94(%rip), %rsi      # 0x7e8e
movl $0x18, %edx
leaq 0x1d4b(%rip), %rcx      # 0x7051
leaq 0x2c08(%rip), %r8       # 0x7f15
movb $0x0, %al
callq 0x3080
leaq -0x170(%rbp), %rsi
movl $0x66, %edi
callq 0x2dd0
andb $0x1, %al
movzbl %al, %edi
leaq 0x2b5d(%rip), %rsi      # 0x7e8e
movl $0x19, %edx
leaq 0x1d14(%rip), %rcx      # 0x7051
leaq 0x2bda(%rip), %r8       # 0x7f1e
movb $0x0, %al
callq 0x3080
leaq -0x170(%rbp), %rsi
movl $0x6d, %edi
callq 0x2dd0
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x2b24(%rip), %rsi      # 0x7e8e
movl $0x1a, %edx
leaq 0x1cdb(%rip), %rcx      # 0x7051
leaq 0x2bc1(%rip), %r8       # 0x7f3e
movb $0x0, %al
callq 0x3080
leaq -0x170(%rbp), %rsi
leaq 0x2adf(%rip), %rdi      # 0x7e71
callq 0x2e60
andb $0x1, %al
movzbl %al, %edi
leaq 0x2aeb(%rip), %rsi      # 0x7e8e
movl $0x1b, %edx
leaq 0x1ca2(%rip), %rcx      # 0x7051
leaq 0x2ba9(%rip), %r8       # 0x7f5f
movb $0x0, %al
callq 0x3080
leaq -0x170(%rbp), %rsi
leaq 0x2a90(%rip), %rdi      # 0x7e5b
callq 0x2e60
andb $0x1, %al
movzbl %al, %edi
leaq 0x2ab2(%rip), %rsi      # 0x7e8e
movl $0x1c, %edx
leaq 0x1c69(%rip), %rcx      # 0x7051
leaq 0x2b98(%rip), %r8       # 0x7f87
movb $0x0, %al
callq 0x3080
leaq -0x170(%rbp), %rsi
leaq 0x2bab(%rip), %rdi      # 0x7faf
callq 0x2e60
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x2a77(%rip), %rsi      # 0x7e8e
movl $0x1d, %edx
leaq 0x1c2e(%rip), %rcx      # 0x7051
leaq 0x2b8d(%rip), %r8       # 0x7fb7
movb $0x0, %al
callq 0x3080
leaq -0x170(%rbp), %rsi
leaq 0x2a39(%rip), %rdi      # 0x7e78
callq 0x2e60
andb $0x1, %al
movzbl %al, %edi
leaq 0x2a3e(%rip), %rsi      # 0x7e8e
movl $0x1e, %edx
leaq 0x1bf5(%rip), %rcx      # 0x7051
leaq 0x2b80(%rip), %r8       # 0x7fe3
movb $0x0, %al
callq 0x3080
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
xorl %eax, %eax
movsd 0x1cd3(%rip), %xmm1     # 0x7150
ucomisd %xmm1, %xmm0
movb %al, -0x1d3(%rbp)
jbe 0x54a7
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1cbe(%rip), %xmm0     # 0x7158
ucomisd %xmm1, %xmm0
seta %al
movb %al, -0x1d3(%rbp)
movb -0x1d3(%rbp), %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x29d5(%rip), %rsi      # 0x7e8e
movl $0x1f, %edx
leaq 0x1b8c(%rip), %rcx      # 0x7051
leaq 0x2b40(%rip), %r8       # 0x800c
movb $0x0, %al
callq 0x3080
movb -0x1d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x29a1(%rip), %rsi      # 0x7e8e
movl $0x20, %edx
leaq 0x1b58(%rip), %rcx      # 0x7051
leaq 0x2b2d(%rip), %r8       # 0x802d
movb $0x0, %al
callq 0x3080
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq