// File: /workspace/github_cpp_makefile_star2_O2/tokuhirom[P]nanouri/t/01_parse.c
// Function: main
int main () {
    const char * scheme;
    size_t scheme_len;
    const char * host;
    size_t host_len;
    int port;
    const char *path_query;
    int path_query_len;

#define TEST(uri, expect_scheme, expect_host, expect_port, expect_path_query) \
    do { \
        note(uri); \
        int ret = nanouri_parse_uri(uri, strlen(uri), &scheme, &scheme_len, &host, &host_len, &port, &path_query, &path_query_len); \
        ok(ret == 0, "retval"); \
        ok(strncmp(expect_scheme, scheme, scheme_len) == 0, "scheme"); \
        ok(strlen(expect_scheme) == scheme_len, "scheme_len"); \
        ok(strncmp(expect_host, host, host_len) == 0, "host"); \
        ok(strlen(expect_host) == host_len, "host_len"); \
        ok(port == expect_port, "port"); \
        ok(strncmp(expect_path_query, path_query, path_query_len) == 0, "path_query"); \
        ok(strlen(expect_path_query) == path_query_len, "path_query"); \
    } while (0)

#define TEST_ERROR(uri, expect_ret) \
    do { \
        note(uri); \
        int ret = nanouri_parse_uri(uri, strlen(uri), &scheme, &scheme_len, &host, &host_len, &port, &path_query, &path_query_len); \
        ok(ret == expect_ret, "retval"); \
    } while (0)

    TEST("http://mixi.jp:9090/foo=?bar=baz", "http", "mixi.jp", 9090, "/foo=?bar=baz");
    TEST("http://d.hatena.ne.jp", "http", "d.hatena.ne.jp", 0, "");
    TEST("http://d.hatena.ne.jp:80", "http", "d.hatena.ne.jp", 80, "");
    TEST("http://d.hatena.ne.jp/", "http", "d.hatena.ne.jp", 0, "/");
    TEST("http://livedoor.com/", "http", "livedoor.com", 0, "/");
    TEST("http://127.0.0.1:9090", "http", "127.0.0.1", 9090, "");
    TEST_ERROR("http", -2);
    TEST_ERROR("http:-", -1);

    done_testing();

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq 0xd9a(%rip), %rbx       # 0x2024
movq %rbx, %rdi
callq 0x1200
subq $0x8, %rsp
leaq -0x2c(%rbp), %r11
leaq -0x38(%rbp), %rax
leaq -0x30(%rbp), %r10
pushq $0x20
popq %rsi
leaq -0x48(%rbp), %rdx
leaq -0x58(%rbp), %rcx
leaq -0x50(%rbp), %r8
leaq -0x40(%rbp), %r9
movq %rbx, %rdi
movq %rdx, %r14
movq %rcx, %r13
movq %r8, %rbx
movq %r9, %r12
pushq %r11
pushq %rax
pushq %r10
movq %r10, %r15
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xd61(%rip), %rsi       # 0x2045
callq 0x118c
movq (%r14), %rsi
movq (%r13), %rdx
leaq 0xd55(%rip), %rdi       # 0x204c
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xd46(%rip), %rsi       # 0x2051
callq 0x118c
xorl %edi, %edi
cmpq $0x4, (%r13)
sete %dil
leaq 0xd36(%rip), %rsi       # 0x2058
callq 0x118c
movq (%rbx), %rsi
movq (%r12), %rdx
leaq 0xd2e(%rip), %rdi       # 0x2063
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xd22(%rip), %rsi       # 0x206b
callq 0x118c
xorl %edi, %edi
cmpq $0x7, (%r12)
sete %dil
leaq 0xd10(%rip), %rsi       # 0x2070
callq 0x118c
movl $0x2382, %eax           # imm = 0x2382
xorl %edi, %edi
cmpl %eax, (%r15)
sete %dil
leaq 0xcff(%rip), %rsi       # 0x2079
callq 0x118c
leaq -0x38(%rbp), %r13
movq (%r13), %rsi
leaq -0x2c(%rbp), %r12
movslq (%r12), %rdx
leaq 0xca1(%rip), %rdi       # 0x2037
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xcd4(%rip), %rbx       # 0x207e
movq %rbx, %rsi
callq 0x118c
xorl %edi, %edi
cmpl $0xd, (%r12)
sete %dil
movq %rbx, %rsi
callq 0x118c
leaq 0xcbd(%rip), %rbx       # 0x2089
movq %rbx, %rdi
callq 0x1200
subq $0x8, %rsp
pushq $0x15
popq %rsi
movq %rbx, %rdi
leaq -0x48(%rbp), %rbx
movq %rbx, %rdx
leaq -0x58(%rbp), %r14
movq %r14, %rcx
leaq -0x50(%rbp), %r8
movq %r8, %r15
leaq -0x40(%rbp), %r9
pushq %r12
pushq %r13
leaq -0x30(%rbp), %r13
pushq %r13
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xc2c(%rip), %rsi       # 0x2045
callq 0x118c
movq (%rbx), %rsi
movq (%r14), %rdx
leaq 0xc21(%rip), %rdi       # 0x204c
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xc12(%rip), %rsi       # 0x2051
callq 0x118c
xorl %edi, %edi
cmpq $0x4, (%r14)
sete %dil
leaq 0xc03(%rip), %rsi       # 0x2058
callq 0x118c
movq (%r15), %rsi
movq %r15, %r12
leaq -0x40(%rbp), %rbx
movq (%rbx), %rdx
leaq 0xc22(%rip), %rdi       # 0x2090
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xbe9(%rip), %rsi       # 0x206b
callq 0x118c
xorl %edi, %edi
cmpq $0xe, (%rbx)
sete %dil
leaq 0xbd8(%rip), %rsi       # 0x2070
callq 0x118c
xorl %edi, %edi
cmpl $0x0, (%r13)
sete %dil
leaq 0xbca(%rip), %rsi       # 0x2079
callq 0x118c
leaq -0x38(%rbp), %rax
movq (%rax), %rsi
leaq -0x2c(%rbp), %r15
movslq (%r15), %rdx
leaq 0xb5a(%rip), %rdi       # 0x2023
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xba1(%rip), %rbx       # 0x207e
movq %rbx, %rsi
callq 0x118c
xorl %edi, %edi
cmpl $0x0, (%r15)
sete %dil
movq %rbx, %rsi
callq 0x118c
leaq 0xba1(%rip), %rbx       # 0x209f
movq %rbx, %rdi
callq 0x1200
subq $0x8, %rsp
pushq $0x18
popq %rsi
movq %rbx, %rdi
leaq -0x48(%rbp), %r13
movq %r13, %rdx
movq %r14, %rcx
movq %r12, %r8
leaq -0x40(%rbp), %rbx
movq %rbx, %r9
pushq %r15
leaq -0x38(%rbp), %rax
pushq %rax
leaq -0x30(%rbp), %r15
pushq %r15
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xafc(%rip), %rsi       # 0x2045
callq 0x118c
movq (%r13), %rsi
movq (%r14), %rdx
leaq 0xaf0(%rip), %rdi       # 0x204c
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xae1(%rip), %rsi       # 0x2051
callq 0x118c
xorl %edi, %edi
cmpq $0x4, (%r14)
sete %dil
leaq 0xad2(%rip), %rsi       # 0x2058
callq 0x118c
movq (%r12), %rsi
movq (%rbx), %rdx
leaq 0xaf7(%rip), %rdi       # 0x2090
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xabe(%rip), %rsi       # 0x206b
callq 0x118c
xorl %edi, %edi
cmpq $0xe, (%rbx)
movq %rbx, %r12
sete %dil
leaq 0xaaa(%rip), %rsi       # 0x2070
callq 0x118c
xorl %edi, %edi
cmpl $0x50, (%r15)
sete %dil
leaq 0xa9d(%rip), %rsi       # 0x2079
callq 0x118c
leaq -0x38(%rbp), %rax
movq (%rax), %rsi
leaq -0x2c(%rbp), %r13
movslq (%r13), %rdx
leaq 0xa2c(%rip), %rdi       # 0x2023
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0xa73(%rip), %rbx       # 0x207e
movq %rbx, %rsi
callq 0x118c
xorl %edi, %edi
cmpl $0x0, (%r13)
sete %dil
movq %rbx, %rsi
callq 0x118c
leaq 0xa8b(%rip), %rbx       # 0x20b8
movq %rbx, %rdi
callq 0x1200
subq $0x8, %rsp
pushq $0x16
popq %rsi
movq %rbx, %rdi
leaq -0x48(%rbp), %rbx
movq %rbx, %rdx
movq %r14, %rcx
leaq -0x50(%rbp), %r15
movq %r15, %r8
movq %r12, %r9
pushq %r13
leaq -0x38(%rbp), %rax
pushq %rax
leaq -0x30(%rbp), %r13
pushq %r13
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x9cd(%rip), %rsi       # 0x2045
callq 0x118c
movq (%rbx), %rsi
movq (%r14), %rdx
leaq 0x9c2(%rip), %rdi       # 0x204c
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x9b3(%rip), %rsi       # 0x2051
callq 0x118c
xorl %edi, %edi
cmpq $0x4, (%r14)
sete %dil
leaq 0x9a4(%rip), %rsi       # 0x2058
callq 0x118c
movq (%r15), %rsi
movq (%r12), %rdx
leaq 0x9c9(%rip), %rdi       # 0x2090
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x990(%rip), %rsi       # 0x206b
callq 0x118c
xorl %edi, %edi
cmpq $0xe, (%r12)
sete %dil
leaq 0x97e(%rip), %rsi       # 0x2070
callq 0x118c
xorl %edi, %edi
cmpl $0x0, (%r13)
sete %dil
leaq 0x970(%rip), %rsi       # 0x2079
callq 0x118c
leaq -0x38(%rbp), %rax
movq (%rax), %rsi
leaq -0x2c(%rbp), %r14
movslq (%r14), %rdx
leaq 0x9bf(%rip), %rdi       # 0x20e2
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x947(%rip), %rbx       # 0x207e
movq %rbx, %rsi
callq 0x118c
xorl %edi, %edi
cmpl $0x1, (%r14)
sete %dil
movq %rbx, %rsi
callq 0x118c
leaq 0x977(%rip), %r15       # 0x20cf
movq %r15, %rdi
callq 0x1200
subq $0x8, %rsp
pushq $0x14
popq %rsi
movq %r15, %rdi
leaq -0x48(%rbp), %r13
movq %r13, %rdx
leaq -0x58(%rbp), %rbx
movq %rbx, %rcx
leaq -0x50(%rbp), %r12
movq %r12, %r8
leaq -0x40(%rbp), %r15
movq %r15, %r9
pushq %r14
leaq -0x38(%rbp), %r14
pushq %r14
leaq -0x30(%rbp), %rax
pushq %rax
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x89a(%rip), %rsi       # 0x2045
callq 0x118c
movq (%r13), %rsi
movq (%rbx), %rdx
leaq 0x88e(%rip), %rdi       # 0x204c
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x87f(%rip), %rsi       # 0x2051
callq 0x118c
xorl %edi, %edi
cmpq $0x4, (%rbx)
sete %dil
leaq 0x870(%rip), %rsi       # 0x2058
callq 0x118c
movq (%r12), %rsi
movq %r12, %r13
movq (%r15), %rdx
leaq 0x8e6(%rip), %rdi       # 0x20e4
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x859(%rip), %rsi       # 0x206b
callq 0x118c
xorl %edi, %edi
cmpq $0xc, (%r15)
sete %dil
leaq 0x848(%rip), %rsi       # 0x2070
callq 0x118c
xorl %edi, %edi
leaq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
sete %dil
leaq 0x838(%rip), %rsi       # 0x2079
callq 0x118c
movq (%r14), %rsi
leaq -0x2c(%rbp), %rbx
movslq (%rbx), %rdx
leaq 0x88b(%rip), %rdi       # 0x20e2
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x813(%rip), %r15       # 0x207e
movq %r15, %rsi
callq 0x118c
xorl %edi, %edi
cmpl $0x1, (%rbx)
movq %rbx, %r12
sete %dil
movq %r15, %rsi
callq 0x118c
leaq 0x863(%rip), %rbx       # 0x20f1
movq %rbx, %rdi
callq 0x1200
subq $0x8, %rsp
movq %rbx, %rdi
pushq $0x15
popq %rsi
leaq -0x48(%rbp), %rbx
movq %rbx, %rdx
leaq -0x58(%rbp), %r15
movq %r15, %rcx
movq %r13, %r8
leaq -0x40(%rbp), %r9
pushq %r12
pushq %r14
movq %r14, %r12
leaq -0x30(%rbp), %r14
pushq %r14
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x76b(%rip), %rsi       # 0x2045
callq 0x118c
movq (%rbx), %rsi
movq (%r15), %rdx
leaq 0x760(%rip), %rbx       # 0x204c
movq %rbx, %rdi
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x74e(%rip), %rsi       # 0x2051
callq 0x118c
xorl %edi, %edi
cmpq $0x4, (%r15)
sete %dil
leaq 0x73f(%rip), %rsi       # 0x2058
callq 0x118c
movq (%r13), %rsi
leaq -0x40(%rbp), %r15
movq (%r15), %rdx
leaq 0x7d7(%rip), %rdi       # 0x2107
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x727(%rip), %rsi       # 0x206b
callq 0x118c
xorl %edi, %edi
cmpq $0x9, (%r15)
sete %dil
leaq 0x716(%rip), %rsi       # 0x2070
callq 0x118c
xorl %edi, %edi
movl $0x2382, %eax           # imm = 0x2382
cmpl %eax, (%r14)
sete %dil
leaq 0x705(%rip), %rsi       # 0x2079
callq 0x118c
movq (%r12), %rsi
leaq -0x2c(%rbp), %r14
movslq (%r14), %rdx
leaq 0x698(%rip), %rdi       # 0x2023
callq 0x1030
xorl %edi, %edi
testl %eax, %eax
sete %dil
leaq 0x6df(%rip), %r15       # 0x207e
movq %r15, %rsi
callq 0x118c
xorl %edi, %edi
cmpl $0x0, (%r14)
sete %dil
movq %r15, %rsi
callq 0x118c
movq %rbx, %rdi
callq 0x1200
subq $0x8, %rsp
pushq $0x4
popq %rsi
movq %rbx, %rdi
leaq -0x48(%rbp), %r13
movq %r13, %rdx
leaq -0x58(%rbp), %r15
movq %r15, %rcx
leaq -0x50(%rbp), %r8
leaq -0x40(%rbp), %r9
pushq %r14
pushq %r12
leaq -0x30(%rbp), %r14
pushq %r14
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
cmpl $-0x2, %eax
sete %dil
leaq 0x641(%rip), %r12       # 0x2045
movq %r12, %rsi
callq 0x118c
leaq 0x6fe(%rip), %rbx       # 0x2111
movq %rbx, %rdi
callq 0x1200
subq $0x8, %rsp
pushq $0x6
popq %rsi
movq %rbx, %rdi
movq %r13, %rdx
movq %r15, %rcx
leaq -0x50(%rbp), %r8
leaq -0x40(%rbp), %r9
leaq -0x2c(%rbp), %rax
pushq %rax
leaq -0x38(%rbp), %rax
pushq %rax
pushq %r14
callq 0x1aad
addq $0x20, %rsp
xorl %edi, %edi
cmpl $-0x1, %eax
sete %dil
movq %r12, %rsi
callq 0x118c
callq 0x1253
nop