// File: /workspace/github_c_makefile_star2_O2/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 0x1db6
movq (%r14), %rsi
leaq 0x1294(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
pushq $0x1
jmp 0x1f71
movq 0x8(%r14), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x10c0
movq %rax, %rbx
callq 0x1050
cmpl $0x0, (%rax)
je 0x1de9
movq (%r14), %rsi
leaq 0x1261(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
pushq $0x2
jmp 0x1f71
movq %rax, %r15
movq 0x10(%r14), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x10c0
cmpl $0x0, (%r15)
je 0x1e18
movq (%r14), %rsi
leaq 0x1232(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
pushq $0x3
jmp 0x1f71
cmpl $0x1afa7, %ebx          # imm = 0x1AFA7
je 0x1e42
cmpl $0xadd1, %ebx           # imm = 0xADD1
je 0x1e39
cmpl $0x5aa9, %ebx           # imm = 0x5AA9
jne 0x1ea1
leaq 0x3259(%rip), %rbx      # 0x5090
jmp 0x1e49
leaq 0x10a50(%rip), %rbx     # 0x12890
jmp 0x1e49
leaq 0x1e247(%rip), %rbx     # 0x20090
testl $0xffffff80, %eax       # imm = 0xFFFFFF80
je 0x1e74
movq (%r14), %rsi
leaq 0x11e2(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
leaq 0x1253(%rip), %rdi      # 0x30bb
callq 0x1060
pushq $0x5
jmp 0x1f71
andl $0x7f, %eax
imulq $0x1b0, %rax, %rax      # imm = 0x1B0
addq %rax, %rbx
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x11ec
testl %eax, %eax
je 0x1ec5
leaq 0x1208(%rip), %rdi      # 0x30a4
jmp 0x1f6a
movq (%r14), %rsi
leaq 0x1191(%rip), %rdi      # 0x303c
xorl %eax, %eax
callq 0x1080
leaq 0x121f(%rip), %rdi      # 0x30d8
callq 0x1060
pushq $0x4
jmp 0x1f71
movq 0x3114(%rip), %rax      # 0x4fe0
movq (%rax), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x1959
leaq 0x1167(%rip), %rdi      # 0x304a
callq 0x1060
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x19bb
movq 0x1b0(%r14), %rdi
callq 0x1030
leaq 0x11f8(%rip), %rdx      # 0x3100
pushq $0x4
popq %rcx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x133b
testl %eax, %eax
je 0x1f23
leaq 0x1163(%rip), %rdi      # 0x3084
jmp 0x1f6a
leaq 0x1126(%rip), %rdi      # 0x3050
callq 0x1060
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x19bb
movq 0x1b0(%r14), %rdi
callq 0x1030
leaq 0x10e3(%rip), %rdx      # 0x3037
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1640
testl %eax, %eax
je 0x1f7f
leaq 0x10fc(%rip), %rdi      # 0x3066
callq 0x1060
pushq $-0x1
popq %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbx
popq %r14
popq %r15
retq
leaq 0x10d6(%rip), %rdi      # 0x305c
callq 0x1060
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x19bb
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1aa6
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1b8d
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1c08
movq %rbx, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1c8b
movq 0x1b0(%rbx), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x1f72