// File: /workspace/github_c_makefile_star2_O0/lengjingzju[P]json/jnum_test.c
// Function: main
int main(int argc, char *argv[])
{
    char buf[64] = {0};

    if (argc != 2 && argc != 3 && argc != 4) {
        printf("Usage: %s <num>\n", argv[0]);
        printf("       %s <num> <cnt>\n", argv[0]);
        printf("       %s a <num>\n", argv[0]);
        printf("       %s a <num> <cnt>\n", argv[0]);
        printf("       %s <i/l/h/L/d> <num>\n", argv[0]);
        printf("       %s <i/l/h/L/d> <num>\n", argv[0]);
        printf("a: atod, i: itoa, l: ltoa, h: htoa, L: lhtoa, d or default: dtoa/grisu2/dragonbox/...\n");
        return -1;
    }

    switch (*argv[1]) {
    case 'i':
        {
            int32_t d = jnum_atoi(argv[2]);
            jnum_itoa(d, buf);
            printf("original  : %s\nprintf    : %d\njnum      : %s\n", argv[2], d, buf);
            break;
        }
    case 'l':
        {
            int64_t d = jnum_atol(argv[2]);
            jnum_ltoa(d, buf);
            printf("original  : %s\nprintf    : %lld\njnum      : %s\n", argv[2], (long long)d, buf);
            break;
        }
    case 'h':
        {
            uint32_t d = jnum_atoh(argv[2]);
            jnum_htoa(d, buf);
            printf("original  : %s\nprintf    : 0x%x\njnum      : %s\n", argv[2], d, buf);
            break;
        }
    case 'L':
        {
            uint64_t d = jnum_atolh(argv[2]);
            jnum_lhtoa(d, buf);
            printf("original  : %s\nprintf    : 0x%llx\njnum      : %s\n", argv[2], (unsigned long long)d, buf);
            break;
        }
    case 'd':
        {
            double d = jnum_atod(argv[2]);
            printf("original  : %s\nprintf    : %0.16g\n", argv[2], d);
            jnum_dtoa(d, buf);
            printf("ldouble   : %s\n", buf);
            grisu2_dtoa(d, buf);
            printf("grisu2    : %s\n", buf);
            dragonbox_dtoa(d, buf);
            printf("dragonbox : %s\n", buf);
            break;
        }

    case 'a':
        if (argc == 3) {
            volatile double d1, d2;
            d1 = strtod(argv[2], NULL);
            d2 = jnum_atod(argv[2]);
            if (d1 != d2)
                printf("----%s----\nstrtod:    %0.16g\njnum_atod: %0.16g\n", argv[2], d1, d2);
        } else {
            int i;
            int cnt = atoi(argv[3]);
            volatile double d1, d2;
            unsigned int ms1, ms2, ms3;
            char tmp[64] = {0};

            ms1 = _system_ms_get();
            for (i = 0; i < cnt; ++i) {
                d1 = strtod(argv[2], NULL);
            }
            ms2 = _system_ms_get();
            for (i = 0; i < cnt; ++i) {
                d2 = jnum_atod(argv[2]);
            }
            ms3 = _system_ms_get();

            jnum_dtoa(d1, buf);
            jnum_dtoa(d2, tmp);
            printf("original  : %s\nstrtod:    %s %ums\njnum_atod: %s %ums\t%.0lf%%\n", argv[2], buf, ms2 - ms1, tmp, ms3 - ms2,
                 ms3 - ms2 ? 100.0 * (ms2 - ms1) / (ms3 - ms2) : 0);
        }
        break;

    default:
        if (argc == 2) {
            double d = strtod(argv[1], NULL);
            char tmp[64] = {0};

            snprintf(tmp, sizeof(tmp), "%0.16g", d);
            jnum_dtoa(d, buf);
            if (strcmp(buf, tmp)) {
                printf("original  : %s\nprintf    : %s\n", argv[1], tmp);
                printf("ldouble   : %s\n", buf);
            }
        } else {
            int i;
            double d = strtod(argv[1], NULL);
            int cnt = atoi(argv[2]);
            unsigned int ms, ms1, ms2, ms3;

            ms1 = _system_ms_get();
            for (i = 0; i < cnt; ++i) {
                snprintf(buf, sizeof(buf), "%0.16g", d);
            }
            ms2 = _system_ms_get();
            ms = ms2 - ms1;
            printf("original  : %s\nprintf    : %0.16g\t%ums\n", argv[1], d, ms);

            ms1 = _system_ms_get();
            for (i = 0; i < cnt; ++i) {
                jnum_dtoa(d, buf);
            }
            ms2 = _system_ms_get();
            ms3 = ms2 - ms1;
            printf("ldouble   : %s\t%ums\t%.0lf%%\n", buf, ms3, ms3 ? 100.0 * ms / ms3 : 0);

            ms1 = _system_ms_get();
            for (i = 0; i < cnt; ++i) {
                grisu2_dtoa(d, buf);
            }
            ms2 = _system_ms_get();
            ms3 = ms2 - ms1;
            printf("grisu2    : %s\t%ums\t%.0lf%%\n", buf, ms3, ms3 ? 100.0 * ms / ms3 : 0);

            ms1 = _system_ms_get();
            for (i = 0; i < cnt; ++i) {
                dragonbox_dtoa(d, buf);
            }
            ms2 = _system_ms_get();
            ms3 = ms2 - ms1;
            printf("dragonbox : %s\t%ums\t%.0lf%%\n", buf, ms3, ms3 ? 100.0 * ms / ms3 : 0);
        }
        break;
    }

    return 0;
}

// Assembly:
subq $0x1f8, %rsp            # imm = 0x1F8
movl $0x0, 0x1f4(%rsp)
movl %edi, 0x1f0(%rsp)
movq %rsi, 0x1e8(%rsp)
leaq 0x1a0(%rsp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x1070
cmpl $0x2, 0x1f0(%rsp)
je 0x65d3
cmpl $0x3, 0x1f0(%rsp)
je 0x65d3
cmpl $0x4, 0x1f0(%rsp)
je 0x65d3
movq 0x1e8(%rsp), %rax
movq (%rax), %rsi
leaq 0x6f43(%rip), %rdi      # 0xd474
movb $0x0, %al
callq 0x1050
movq 0x1e8(%rsp), %rax
movq (%rax), %rsi
leaq 0x6f3b(%rip), %rdi      # 0xd485
movb $0x0, %al
callq 0x1050
movq 0x1e8(%rsp), %rax
movq (%rax), %rsi
leaq 0x6f39(%rip), %rdi      # 0xd49c
movb $0x0, %al
callq 0x1050
movq 0x1e8(%rsp), %rax
movq (%rax), %rsi
leaq 0x6f33(%rip), %rdi      # 0xd4af
movb $0x0, %al
callq 0x1050
movq 0x1e8(%rsp), %rax
movq (%rax), %rsi
leaq 0x6f33(%rip), %rdi      # 0xd4c8
movb $0x0, %al
callq 0x1050
movq 0x1e8(%rsp), %rax
movq (%rax), %rsi
leaq 0x6f1a(%rip), %rdi      # 0xd4c8
movb $0x0, %al
callq 0x1050
leaq 0x6f29(%rip), %rdi      # 0xd4e5
movb $0x0, %al
callq 0x1050
movl $0xffffffff, 0x1f4(%rsp) # imm = 0xFFFFFFFF
jmp 0x6f40
movq 0x1e8(%rsp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
addl $-0x4c, %eax
movl %eax, %ecx
movq %rcx, 0x80(%rsp)
subl $0x20, %eax
ja 0x6ac2
movq 0x80(%rsp), %rax
leaq 0x6de9(%rip), %rcx      # 0xd3f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x3420
movl %eax, 0x19c(%rsp)
movl 0x19c(%rsp), %edi
leaq 0x1a0(%rsp), %rsi
callq 0x11b0
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rsi
movl 0x19c(%rsp), %edx
leaq 0x1a0(%rsp), %rcx
leaq 0x6ede(%rip), %rdi      # 0xd53c
movb $0x0, %al
callq 0x1050
jmp 0x6f35
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x3540
movq %rax, 0x190(%rsp)
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x1560
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x190(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
leaq 0x6eaf(%rip), %rdi      # 0xd56a
movb $0x0, %al
callq 0x1050
jmp 0x6f35
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x35f0
movl %eax, 0x18c(%rsp)
movl 0x18c(%rsp), %edi
leaq 0x1a0(%rsp), %rsi
callq 0x1750
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rsi
movl 0x18c(%rsp), %edx
leaq 0x1a0(%rsp), %rcx
leaq 0x6e85(%rip), %rdi      # 0xd59a
movb $0x0, %al
callq 0x1050
jmp 0x6f35
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x36a0
movq %rax, 0x180(%rsp)
movq 0x180(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x1870
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x180(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
leaq 0x6e58(%rip), %rdi      # 0xd5ca
movb $0x0, %al
callq 0x1050
jmp 0x6f35
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x3780
movsd %xmm0, 0x178(%rsp)
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rsi
movsd 0x178(%rsp), %xmm0
leaq 0x6e48(%rip), %rdi      # 0xd5fc
movb $0x1, %al
callq 0x1050
movsd 0x178(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x19b0
leaq 0x1a0(%rsp), %rsi
leaq 0x6e3f(%rip), %rdi      # 0xd61f
movb $0x0, %al
callq 0x1050
movsd 0x178(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x4100
leaq 0x1a0(%rsp), %rsi
leaq 0x6e23(%rip), %rdi      # 0xd62f
movb $0x0, %al
callq 0x1050
movsd 0x178(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x5010
leaq 0x1a0(%rsp), %rsi
leaq 0x6e07(%rip), %rdi      # 0xd63f
movb $0x0, %al
callq 0x1050
jmp 0x6f35
cmpl $0x3, 0x1f0(%rsp)
jne 0x68d7
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1030
movsd %xmm0, 0x170(%rsp)
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x3780
movsd %xmm0, 0x168(%rsp)
movsd 0x170(%rsp), %xmm0
movsd 0x168(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jne 0x68a6
jp 0x68a6
jmp 0x68d2
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rsi
movsd 0x170(%rsp), %xmm0
movsd 0x168(%rsp), %xmm1
leaq 0x6d84(%rip), %rdi      # 0xd64f
movb $0x2, %al
callq 0x1050
jmp 0x6abd
movq 0x1e8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x10a0
movl %eax, 0x160(%rsp)
leaq 0x100(%rsp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x1070
callq 0x6f50
movl %eax, 0x14c(%rsp)
movl $0x0, 0x164(%rsp)
movl 0x164(%rsp), %eax
cmpl 0x160(%rsp), %eax
jge 0x695b
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1030
movsd %xmm0, 0x158(%rsp)
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0x691a
callq 0x6f50
movl %eax, 0x148(%rsp)
movl $0x0, 0x164(%rsp)
movl 0x164(%rsp), %eax
cmpl 0x160(%rsp), %eax
jge 0x69af
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x3780
movsd %xmm0, 0x150(%rsp)
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0x6972
callq 0x6f50
movl %eax, 0x144(%rsp)
movsd 0x158(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x19b0
movsd 0x150(%rsp), %xmm0
leaq 0x100(%rsp), %rdi
callq 0x19b0
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x58(%rsp)
leaq 0x1a0(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0x148(%rsp), %eax
subl 0x14c(%rsp), %eax
movl %eax, 0x6c(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0x144(%rsp), %eax
subl 0x148(%rsp), %eax
movl %eax, 0x7c(%rsp)
movl 0x144(%rsp), %eax
subl 0x148(%rsp), %eax
cmpl $0x0, %eax
je 0x6a86
movl 0x148(%rsp), %ecx
movl 0x14c(%rsp), %edx
movl %ecx, %eax
subl %edx, %eax
cvtsi2sd %rax, %xmm0
movsd 0x6980(%rip), %xmm1     # 0xd3e8
mulsd %xmm1, %xmm0
movl 0x144(%rsp), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0x6a91
xorps %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
jmp 0x6a91
movl 0x7c(%rsp), %r9d
movq 0x70(%rsp), %r8
movl 0x6c(%rsp), %ecx
movq 0x60(%rsp), %rdx
movq 0x58(%rsp), %rsi
movsd 0x50(%rsp), %xmm0
leaq 0x6bc9(%rip), %rdi      # 0xd67f
movb $0x1, %al
callq 0x1050
jmp 0x6f35
cmpl $0x2, 0x1f0(%rsp)
jne 0x6b93
movq 0x1e8(%rsp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1030
movsd %xmm0, 0xf8(%rsp)
leaq 0xb0(%rsp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x1070
leaq 0xb0(%rsp), %rdi
movsd 0xf8(%rsp), %xmm0
movl $0x40, %esi
leaq 0x6b9e(%rip), %rdx      # 0xd6bd
movb $0x1, %al
callq 0x1060
movsd 0xf8(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x19b0
leaq 0x1a0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1080
cmpl $0x0, %eax
je 0x6b8e
movq 0x1e8(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x6b53(%rip), %rdi      # 0xd6c4
movb $0x0, %al
callq 0x1050
leaq 0x1a0(%rsp), %rsi
leaq 0x6a98(%rip), %rdi      # 0xd61f
movb $0x0, %al
callq 0x1050
jmp 0x6f33
movq 0x1e8(%rsp), %rax
movq 0x8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1030
movsd %xmm0, 0xa0(%rsp)
movq 0x1e8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x10a0
movl %eax, 0x9c(%rsp)
callq 0x6f50
movl %eax, 0x94(%rsp)
movl $0x0, 0xac(%rsp)
movl 0xac(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jge 0x6c27
leaq 0x1a0(%rsp), %rdi
movsd 0xa0(%rsp), %xmm0
movl $0x40, %esi
leaq 0x6ab0(%rip), %rdx      # 0xd6bd
movb $0x1, %al
callq 0x1060
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x6be0
callq 0x6f50
movl %eax, 0x90(%rsp)
movl 0x90(%rsp), %eax
subl 0x94(%rsp), %eax
movl %eax, 0x98(%rsp)
movq 0x1e8(%rsp), %rax
movq 0x8(%rax), %rsi
movsd 0xa0(%rsp), %xmm0
movl 0x98(%rsp), %edx
leaq 0x6a78(%rip), %rdi      # 0xd6e3
movb $0x1, %al
callq 0x1050
callq 0x6f50
movl %eax, 0x94(%rsp)
movl $0x0, 0xac(%rsp)
movl 0xac(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jge 0x6cc2
movsd 0xa0(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x19b0
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x6c89
callq 0x6f50
movl %eax, 0x90(%rsp)
movl 0x90(%rsp), %eax
subl 0x94(%rsp), %eax
movl %eax, 0x8c(%rsp)
leaq 0x1a0(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, 0x4c(%rsp)
cmpl $0x0, 0x8c(%rsp)
je 0x6d35
movl 0x98(%rsp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x66cf(%rip), %xmm1     # 0xd3e8
mulsd %xmm1, %xmm0
movl 0x8c(%rsp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0x6d40
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
jmp 0x6d40
movl 0x4c(%rsp), %edx
movq 0x40(%rsp), %rsi
movsd 0x38(%rsp), %xmm0
leaq 0x69b5(%rip), %rdi      # 0xd70b
movb $0x1, %al
callq 0x1050
callq 0x6f50
movl %eax, 0x94(%rsp)
movl $0x0, 0xac(%rsp)
movl 0xac(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jge 0x6dad
movsd 0xa0(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x4100
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x6d74
callq 0x6f50
movl %eax, 0x90(%rsp)
movl 0x90(%rsp), %eax
subl 0x94(%rsp), %eax
movl %eax, 0x8c(%rsp)
leaq 0x1a0(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x8c(%rsp)
je 0x6e20
movl 0x98(%rsp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x65e4(%rip), %xmm1     # 0xd3e8
mulsd %xmm1, %xmm0
movl 0x8c(%rsp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x6e2b
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x6e2b
movl 0x34(%rsp), %edx
movq 0x28(%rsp), %rsi
movsd 0x20(%rsp), %xmm0
leaq 0x68e7(%rip), %rdi      # 0xd728
movb $0x1, %al
callq 0x1050
callq 0x6f50
movl %eax, 0x94(%rsp)
movl $0x0, 0xac(%rsp)
movl 0xac(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jge 0x6e98
movsd 0xa0(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
callq 0x5010
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x6e5f
callq 0x6f50
movl %eax, 0x90(%rsp)
movl 0x90(%rsp), %eax
subl 0x94(%rsp), %eax
movl %eax, 0x8c(%rsp)
leaq 0x1a0(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, 0x1c(%rsp)
cmpl $0x0, 0x8c(%rsp)
je 0x6f0b
movl 0x98(%rsp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x64f9(%rip), %xmm1     # 0xd3e8
mulsd %xmm1, %xmm0
movl 0x8c(%rsp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x6f16
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x6f16
movl 0x1c(%rsp), %edx
movq 0x10(%rsp), %rsi
movsd 0x8(%rsp), %xmm0
leaq 0x6819(%rip), %rdi      # 0xd745
movb $0x1, %al
callq 0x1050
jmp 0x6f35
movl $0x0, 0x1f4(%rsp)
movl 0x1f4(%rsp), %eax
addq $0x1f8, %rsp            # imm = 0x1F8
retq
nop