// File: /workspace/github_c_makefile_star2_O2/MersenneTwister-Lab[P]MTGP/mtgp64-ref.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_ref_t *params;
    mtgp64_ref_t mtgp64;
    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_ref_44497;
	break;
    case 23209:
	params = mtgp64_params_ref_23209;
	break;
    case 110503:
	params = mtgp64_params_ref_110503;
	break;
    default:
	printf("%s: mexp no.\n", argv[0]);
	printf("mexp = 23209, 44497 or 110503 only\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;
    mtgp64_init(&mtgp64, params, seed);
    mtgp64_print_idstring(&mtgp64, stdout);
    printf("init:\n");
    print_uint64(&mtgp64, 1000);
    mtgp64_init_by_array(&mtgp64, params, seed_ar, 4);
    printf("init_array:\n");
    print_uint64(&mtgp64, 1000);
    mtgp64_init_by_str(&mtgp64, params, seed_str);
    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 $0x80, %rsp
movq %rsi, %rbx
cmpl $0x2, %edi
jg 0x1cee
movq (%rbx), %rsi
leaq 0x35c(%rip), %rdi       # 0x203c
xorl %eax, %eax
callq 0x1080
pushq $0x1
jmp 0x1eb4
movq 0x8(%rbx), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x10c0
movq %rax, %r14
callq 0x1050
cmpl $0x0, (%rax)
je 0x1d21
movq (%rbx), %rsi
leaq 0x329(%rip), %rdi       # 0x203c
xorl %eax, %eax
callq 0x1080
pushq $0x2
jmp 0x1eb4
movq %rax, %r15
movq 0x10(%rbx), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x10c0
cmpl $0x0, (%r15)
je 0x1d50
movq (%rbx), %rsi
leaq 0x2fa(%rip), %rdi       # 0x203c
xorl %eax, %eax
callq 0x1080
pushq $0x3
jmp 0x1eb4
cmpl $0x1afa7, %r14d         # imm = 0x1AFA7
je 0x1d81
cmpl $0xadd1, %r14d          # imm = 0xADD1
je 0x1d78
cmpl $0x5aa9, %r14d          # imm = 0x5AA9
jne 0x1e95
leaq 0x230a(%rip), %r14      # 0x4080
jmp 0x1d88
leaq 0x5b01(%rip), %r14      # 0x7880
jmp 0x1d88
leaq 0x92f8(%rip), %r14      # 0xb080
testl $0xffffff80, %eax       # imm = 0xFFFFFF80
je 0x1db3
movq (%rbx), %rsi
leaq 0x2a3(%rip), %rdi       # 0x203c
xorl %eax, %eax
callq 0x1080
leaq 0x2bf(%rip), %rdi       # 0x2066
callq 0x1060
pushq $0x5
jmp 0x1eb4
andl $0x7f, %eax
imulq $0x70, %rax, %rax
addq %rax, %r14
leaq 0x8(%rsp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11dc
movq 0x2209(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x18c1
leaq 0x261(%rip), %rdi       # 0x204a
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a82
leaq 0x2ae(%rip), %rdx       # 0x20b0
pushq $0x4
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12c6
leaq 0x239(%rip), %rdi       # 0x2050
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a82
leaq 0x207(%rip), %rdx       # 0x2037
movq %rbx, %rdi
movq %r14, %rsi
callq 0x15bc
leaq 0x21a(%rip), %rdi       # 0x205c
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a82
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1afa
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1b6c
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1bde
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1c50
movq 0x70(%rbx), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x1eb5
movq (%rbx), %rsi
leaq 0x19d(%rip), %rdi       # 0x203c
xorl %eax, %eax
callq 0x1080
leaq 0x1d6(%rip), %rdi       # 0x2083
callq 0x1060
pushq $0x4
popq %rax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop