// File: /workspace/github_c_makefile_star2_O1/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 0x1e54
movq (%rbx), %rsi
leaq 0x11f9(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
movl $0x1, %eax
jmp 0x202e
movq 0x8(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x10c0
movq %rax, %r14
callq 0x1050
cmpl $0x0, (%rax)
je 0x1e8c
movq (%rbx), %rsi
leaq 0x11c1(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
movl $0x2, %eax
jmp 0x202e
movq %rax, %r15
movq 0x10(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x10c0
cmpl $0x0, (%r15)
je 0x1ec0
movq (%rbx), %rsi
leaq 0x118d(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
movl $0x3, %eax
jmp 0x202e
cmpl $0x1afa7, %r14d         # imm = 0x1AFA7
je 0x1ef1
cmpl $0xadd1, %r14d          # imm = 0xADD1
je 0x1ee8
cmpl $0x5aa9, %r14d          # imm = 0x5AA9
jne 0x200c
leaq 0x319a(%rip), %r14      # 0x5080
jmp 0x1ef8
leaq 0x6991(%rip), %r14      # 0x8880
jmp 0x1ef8
leaq 0xa188(%rip), %r14      # 0xc080
testl $0xffffff80, %eax       # imm = 0xFFFFFF80
je 0x1f26
movq (%rbx), %rsi
leaq 0x1133(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
leaq 0x114f(%rip), %rdi      # 0x3066
callq 0x1060
movl $0x5, %eax
jmp 0x202e
andl $0x7f, %eax
imulq $0x70, %rax, %rax
addq %rax, %r14
leaq 0x8(%rsp), %rbx
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11dc
movq 0x3094(%rip), %rax      # 0x4fe0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x195c
leaq 0x10ec(%rip), %rdi      # 0x304a
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1b45
leaq 0x1139(%rip), %rdx      # 0x30b0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %ecx
callq 0x12e5
leaq 0x10c2(%rip), %rdi      # 0x3050
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1b45
leaq 0x1090(%rip), %rdx      # 0x3037
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1605
leaq 0x10a3(%rip), %rdi      # 0x305c
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1b45
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1bc1
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1c53
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1ced
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1d8b
movq 0x70(%rbx), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x202e
movq (%rbx), %rsi
leaq 0x1026(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
leaq 0x105f(%rip), %rdi      # 0x3083
callq 0x1060
movl $0x4, %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop