// File: /workspace/github_c_makefile_star2_O2/MersenneTwister-Lab[P]MTGP/mtgp32-ref.c
// Function: main
int main(int argc, char *argv[]) {
    int mexp;
    int no;
    uint32_t seed = 1;
    uint32_t seed_ar[4] = {1, 2, 3, 4};
    char seed_str[] = "\01\02\03\04";
    mtgp32_params_ref_t *params;
    mtgp32_ref_t mtgp32;
    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 11213:
	params = mtgp32_params_ref_11213;
	break;
    case 23209:
	params = mtgp32_params_ref_23209;
	break;
    case 44497:
	params = mtgp32_params_ref_44497;
	break;
    default:
	printf("%s: mexp no.\n", argv[0]);
	printf("mexp should be 11213, 23209 or 44497 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;
    mtgp32_init(&mtgp32, params, seed);
    mtgp32_print_idstring(&mtgp32, stdout);
    printf("init:\n");
    print_uint32(&mtgp32, 1000);
    mtgp32_init_by_array(&mtgp32, params, seed_ar, 4);
    printf("init_array:\n");
    print_uint32(&mtgp32, 1000);
    mtgp32_init_by_str(&mtgp32, params, seed_str);
    printf("init_str:\n");
    print_uint32(&mtgp32, 1000);
    print_close1_open2(&mtgp32, 1000);
    print_close_open(&mtgp32, 1000);
    print_open_close(&mtgp32, 1000);
    print_open_open(&mtgp32, 1000);

    mtgp32_free(&mtgp32);
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rsi, %rbx
cmpl $0x2, %edi
jg 0x1ccf
movq (%rbx), %rsi
leaq 0x36c(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
pushq $0x1
jmp 0x1e95
movq 0x8(%rbx), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x10c0
movq %rax, %r14
callq 0x1050
cmpl $0x0, (%rax)
je 0x1d02
movq (%rbx), %rsi
leaq 0x339(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
pushq $0x2
jmp 0x1e95
movq %rax, %r15
movq 0x10(%rbx), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x10c0
cmpl $0x0, (%r15)
je 0x1d31
movq (%rbx), %rsi
leaq 0x30a(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
pushq $0x3
jmp 0x1e95
cmpl $0x2bcd, %r14d          # imm = 0x2BCD
je 0x1d62
cmpl $0xadd1, %r14d          # imm = 0xADD1
je 0x1d59
cmpl $0x5aa9, %r14d          # imm = 0x5AA9
jne 0x1e76
leaq 0x4929(%rip), %r14      # 0x6680
jmp 0x1d69
leaq 0x6f20(%rip), %r14      # 0x8c80
jmp 0x1d69
leaq 0x2317(%rip), %r14      # 0x4080
testl $0xffffff80, %eax       # imm = 0xFFFFFF80
je 0x1d94
movq (%rbx), %rsi
leaq 0x2b3(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
leaq 0x2cf(%rip), %rdi       # 0x2057
callq 0x1060
pushq $0x5
jmp 0x1e95
andl $0x7f, %eax
imulq $0x4c, %rax, %rax
addq %rax, %r14
leaq 0x8(%rsp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11dc
movq 0x2228(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x1836
leaq 0x271(%rip), %rdi       # 0x203b
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x19b6
leaq 0x2bd(%rip), %rdx       # 0x20a0
pushq $0x4
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12a8
leaq 0x249(%rip), %rdi       # 0x2041
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x19b6
leaq 0x217(%rip), %rdx       # 0x2028
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1568
leaq 0x22a(%rip), %rdi       # 0x204d
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x19b6
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a4d
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1ade
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1b76
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1c0e
movq 0x50(%rbx), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x1e96
movq (%rbx), %rsi
leaq 0x1ad(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
leaq 0x1e6(%rip), %rdi       # 0x2074
callq 0x1060
pushq $0x4
popq %rax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq