// File: /workspace/github_c_makefile_star2_O1/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 0x1de0
movq (%rbx), %rsi
leaq 0x25e(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
movl $0x1, %eax
jmp 0x1fba
movq 0x8(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x10c0
movq %rax, %r14
callq 0x1050
cmpl $0x0, (%rax)
je 0x1e18
movq (%rbx), %rsi
leaq 0x226(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
movl $0x2, %eax
jmp 0x1fba
movq %rax, %r15
movq 0x10(%rbx), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x10c0
cmpl $0x0, (%r15)
je 0x1e4c
movq (%rbx), %rsi
leaq 0x1f2(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
movl $0x3, %eax
jmp 0x1fba
cmpl $0x2bcd, %r14d          # imm = 0x2BCD
je 0x1e7d
cmpl $0xadd1, %r14d          # imm = 0xADD1
je 0x1e74
cmpl $0x5aa9, %r14d          # imm = 0x5AA9
jne 0x1f98
leaq 0x480e(%rip), %r14      # 0x6680
jmp 0x1e84
leaq 0x6e05(%rip), %r14      # 0x8c80
jmp 0x1e84
leaq 0x21fc(%rip), %r14      # 0x4080
testl $0xffffff80, %eax       # imm = 0xFFFFFF80
je 0x1eb2
movq (%rbx), %rsi
leaq 0x198(%rip), %rdi       # 0x202d
xorl %eax, %eax
callq 0x1080
leaq 0x1b4(%rip), %rdi       # 0x2057
callq 0x1060
movl $0x5, %eax
jmp 0x1fba
andl $0x7f, %eax
imulq $0x4c, %rax, %rax
addq %rax, %r14
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x11dc
movq 0x2108(%rip), %rax      # 0x3fe0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x18e1
leaq 0x151(%rip), %rdi       # 0x203b
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a76
leaq 0x19d(%rip), %rdx       # 0x20a0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %ecx
callq 0x12ca
leaq 0x127(%rip), %rdi       # 0x2041
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a76
leaq 0xf5(%rip), %rdx        # 0x2028
movq %rbx, %rdi
movq %r14, %rsi
callq 0x15c2
leaq 0x108(%rip), %rdi       # 0x204d
callq 0x1060
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1a76
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1b09
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1bb2
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1c5b
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1d0b
movq 0x50(%rbx), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x1fba
movq (%rbx), %rsi
leaq 0x8b(%rip), %rdi        # 0x202d
xorl %eax, %eax
callq 0x1080
leaq 0xc4(%rip), %rdi        # 0x2074
callq 0x1060
movl $0x4, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq