// File: /workspace/github_c_makefile_star2_O3/MersenneTwister-Lab[P]MTGP/mtgp64-fast.c
// Function: main
int main(int argc, char *argv[]) {
    int mexp;
    int no;
    uint64_t seed = 1;
    uint64_t seed_ar[4] = {1, 2, 3, 4};
    char seed_str[] = "\01\02\03\04";
    mtgp64_params_fast_t *params;
    mtgp64_fast_t mtgp64;
    int rc;

    if (argc <= 2) {
	printf("%s: mexp no.\n", argv[0]);
	return 1;
    }
    mexp = strtol(argv[1], NULL, 10);
    if (errno) {
	printf("%s: mexp no.\n", argv[0]);
	return 2;
    }
    no = strtol(argv[2], NULL, 10);
    if (errno) {
	printf("%s: mexp no.\n", argv[0]);
	return 3;
    }
    switch (mexp) {
    case 44497:
	params = mtgp64_params_fast_44497;
	break;
    case 23209:
	params = mtgp64_params_fast_23209;
	break;
    case 110503:
	params = mtgp64_params_fast_110503;
	break;
    default:
	printf("%s: mexp no.\n", argv[0]);
	printf("mexp = 23209, 44497 or 110503\n");
	return 4;
    }
    if (no >= 128 || no < 0) {
	printf("%s: mexp no.\n", argv[0]);
	printf("no must be between 0 and 127\n");
	return 5;
    }
    params += no;
    rc = mtgp64_init(&mtgp64, params, seed);
    if (rc) {
	printf("failure in mtgp64_init\n");
	return -1;
    }
    mtgp64_print_idstring(&mtgp64, stdout);
    printf("init:\n");
    print_uint64(&mtgp64, 1000);
    mtgp64_free(&mtgp64);

    rc = mtgp64_init_by_array(&mtgp64, params, seed_ar, 4);
    if (rc) {
	printf("failure in mtgp64_init_by_array\n");
	return -1;
    }
    printf("init_array:\n");
    print_uint64(&mtgp64, 1000);
    mtgp64_free(&mtgp64);

    rc = mtgp64_init_by_str(&mtgp64, params, seed_str);
    if (rc) {
	printf("failure in mtgp64_init_by_str\n");
	return -1;
    }
    printf("init_str:\n");
    print_uint64(&mtgp64, 1000);
    print_close1_open2(&mtgp64, 1000);
    print_close_open(&mtgp64, 1000);
    print_open_close(&mtgp64, 1000);
    print_open_open(&mtgp64, 1000);

    mtgp64_free(&mtgp64);
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rsi, %r14
cmpl $0x2, %edi
jg 0x21c2
movq (%r14), %rsi
leaq 0xe8b(%rip), %rdi       # 0x303c
xorl %eax, %eax
callq 0x1080
movl $0x1, %eax
jmp 0x2394
movq 0x8(%r14), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x10c0
movq %rax, %rbx
callq 0x1050
cmpl $0x0, (%rax)
je 0x21fa
movq (%r14), %rsi
leaq 0xe53(%rip), %rdi       # 0x303c
xorl %eax, %eax
callq 0x1080
movl $0x2, %eax
jmp 0x2394
movq %rax, %r15
movq 0x10(%r14), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x10c0
cmpl $0x0, (%r15)
je 0x222e
movq (%r14), %rsi
leaq 0xe1f(%rip), %rdi       # 0x303c
xorl %eax, %eax
callq 0x1080
movl $0x3, %eax
jmp 0x2394
cmpl $0x1afa7, %ebx          # imm = 0x1AFA7
je 0x2258
cmpl $0xadd1, %ebx           # imm = 0xADD1
je 0x224f
cmpl $0x5aa9, %ebx           # imm = 0x5AA9
jne 0x22bc
leaq 0x2e43(%rip), %rbx      # 0x5090
jmp 0x225f
leaq 0x1063a(%rip), %rbx     # 0x12890
jmp 0x225f
leaq 0x1de31(%rip), %rbx     # 0x20090
testl $0xffffff80, %eax       # imm = 0xFFFFFF80
je 0x228d
movq (%r14), %rsi
leaq 0xdcc(%rip), %rdi       # 0x303c
xorl %eax, %eax
callq 0x1080
leaq 0xe3d(%rip), %rdi       # 0x30bb
callq 0x1060
movl $0x5, %eax
jmp 0x2394
andl $0x7f, %eax
imulq $0x1b0, %rax, %rax      # imm = 0x1B0
addq %rax, %rbx
leaq 0x8(%rsp), %rdi
movl $0x1, %edx
movq %rbx, %rsi
callq 0x11ec
testl %eax, %eax
je 0x22e3
leaq 0xded(%rip), %rdi       # 0x30a4
jmp 0x238a
movq (%r14), %rsi
leaq 0xd76(%rip), %rdi       # 0x303c
xorl %eax, %eax
callq 0x1080
leaq 0xe04(%rip), %rdi       # 0x30d8
callq 0x1060
movl $0x4, %eax
jmp 0x2394
movq 0x2cf6(%rip), %rax      # 0x4fe0
movq (%rax), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x19f3
leaq 0xd49(%rip), %rdi       # 0x304a
callq 0x1060
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a55
movq 0x1b0(%r14), %rdi
callq 0x1030
leaq 0xdda(%rip), %rdx       # 0x3100
movq %r14, %rdi
movq %rbx, %rsi
movl $0x4, %ecx
callq 0x1361
testl %eax, %eax
je 0x2343
leaq 0xd43(%rip), %rdi       # 0x3084
jmp 0x238a
leaq 0xd06(%rip), %rdi       # 0x3050
callq 0x1060
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a55
movq 0x1b0(%r14), %rdi
callq 0x1030
leaq 0xcc3(%rip), %rdx       # 0x3037
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1697
testl %eax, %eax
je 0x23a1
leaq 0xcdc(%rip), %rdi       # 0x3066
callq 0x1060
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbx
popq %r14
popq %r15
retq
leaq 0xcb4(%rip), %rdi       # 0x305c
callq 0x1060
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a55
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1bbb
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1d29
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1e9f
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x2019
movq 0x1b0(%rbx), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x2394
nop