// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/./softfptest_template.h
// Function: test_cvt_int_sf64
void test_cvt_int_sf(F_UINT a, RoundingModeEnum rm, int it)
{
    int32_t i32, i32_ref;
    int64_t i64, i64_ref;
    float_status st;
    uint32_t fflags;
    F_UINT a_ref;

    /* to int32 */
    fflags = 0;
    i32 = glue(glue(cvt_sf, F_SIZE), _i32)(a, rm, &fflags);

    softfloat_init_ctx(&st, rm);
    i32_ref = glue(glue(float, F_SIZE), _to_int32)(sf_to_softfloat(a), &st);
    if (i32 != i32_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_sf_i32 size=%d rm=%s it=%d:\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = "); print_sf(a); printf("\n");
        printf("ref= %d", i32_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = %d", i32); 
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }

#if F_SIZE <= 64
    /* XXX: softfloat_to_uint32() not available */
    /* to uint32 */
    fflags = 0;
    i32 = glue(glue(cvt_sf, F_SIZE), _u32)(a, rm, &fflags);

    softfloat_init_ctx(&st, rm);
    i32_ref = glue(glue(float, F_SIZE), _to_uint32)(sf_to_softfloat(a), &st);
    if (i32 != i32_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_sf_u32 size=%d rm=%s it=%d:\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = "); print_sf(a); printf("\n");
        printf("ref= %u", i32_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = %u", i32); 
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }
#endif

    /* to int64 */
    fflags = 0;
    i64 = glue(glue(cvt_sf, F_SIZE), _i64)(a, rm, &fflags);

    softfloat_init_ctx(&st, rm);
    i64_ref = glue(glue(float, F_SIZE), _to_int64)(sf_to_softfloat(a), &st);
    if (i64 != i64_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_sf_i64 size=%d rm=%s it=%d:\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = "); print_sf(a); printf("\n");
        printf("ref= %" PRId64 , i64_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = %" PRId64, i64); 
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }

#if F_SIZE <= 64
    /* XXX: softfloat_to_uint64() not available */
    /* to uint64 */
    fflags = 0;
    i64 = glue(glue(cvt_sf, F_SIZE), _u64)(a, rm, &fflags);

    softfloat_init_ctx(&st, rm);
    i64_ref = glue(glue(float, F_SIZE), _to_uint64)(sf_to_softfloat(a), &st);
    if (i64 != i64_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_sf_u64 size=%d rm=%s it=%d:\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = "); print_sf(a); printf("\n");
        printf("ref= %" PRIu64 , i64_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = %" PRIu64, i64); 
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }
#endif

    /* from int32 */
    i32 = rrandom_u32(32);

    fflags = 0;
    a = glue(cvt_i32_sf, F_SIZE)(i32, rm, &fflags);
    
    softfloat_init_ctx(&st, rm);
    a_ref = softfloat_to_sf(glue(int32_to_float, F_SIZE)(i32, &st));
    if (a != a_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_i32_sf size=%d rm=%s it=%d\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = %d", i32); printf("\n");
        printf("ref= "); print_sf(a_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = "); print_sf(a);
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }

#if F_SIZE <= 64
    /* from uint32 */
    fflags = 0;
    a = glue(cvt_u32_sf, F_SIZE)(i32, rm, &fflags);
    
    softfloat_init_ctx(&st, rm);
    a_ref = softfloat_to_sf(glue(uint32_to_float, F_SIZE)(i32, &st));
    if (a != a_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_u32_sf size=%d rm=%s it=%d\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = %ud", i32); printf("\n");
        printf("ref= "); print_sf(a_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = "); print_sf(a);
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }
#endif

    /* from int64 */
    i64 = rrandom_u64(64);

    fflags = 0;
    a = glue(cvt_i64_sf, F_SIZE)(i64, rm, &fflags);
    
    softfloat_init_ctx(&st, rm);
    a_ref = softfloat_to_sf(glue(int64_to_float, F_SIZE)(i64, &st));
    if (a != a_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_i64_sf size=%d rm=%s it=%d\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = %" PRId64, i64); printf("\n");
        printf("ref= "); print_sf(a_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = "); print_sf(a);
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }

#if F_SIZE <= 64
    /* from uint64 */
    fflags = 0;
    a = glue(cvt_u64_sf, F_SIZE)(i64, rm, &fflags);
    
    softfloat_init_ctx(&st, rm);
    a_ref = softfloat_to_sf(glue(uint64_to_float, F_SIZE)(i64, &st));
    if (a != a_ref || softfloat_to_fflags(&st) != fflags) {
        printf("ERROR op=cvt_u64_sf size=%d rm=%s it=%d\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = %" PRIu64, i64); printf("\n");
        printf("ref= "); print_sf(a_ref);
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = "); print_sf(a);
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }
#endif

#ifdef HAVE_INT128
    {
    int128_t i128, i128_ref;
    /* to/from int128 */
    /* XXX: no reference */
    fflags = 0;
    i128_ref = rrandom_u128(128) & (((uint128_t)1 << (MANT_SIZE + 1)) - 1);
    if (random() & 1)
        i128_ref = -i128_ref;
    a = glue(cvt_i128_sf, F_SIZE)(i128_ref, rm, &fflags);
    fflags = 0;
    i128 = glue(glue(cvt_sf, F_SIZE), _i128)(a, rm, &fflags);

    if (i128 != i128_ref) {
        printf("ERROR op=cvt_sf_i128 size=%d rm=%s it=%d:\n",
               F_SIZE, rm_to_str[rm], it);
        printf("a  = "); print_sf(a); printf("\n");
        printf("ref= "); print_u128(i128_ref); printf("\n");
        printf(" fflags=0x%02x\n", softfloat_to_fflags(&st));
        printf("r  = "); print_u128(i128); printf("\n");
        printf(" fflags=0x%02x\n", fflags);
        exit(1);
    }
    }
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r13d
movl %esi, %ebp
movq %rdi, %r14
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
callq 0x6996
movl %eax, %r15d
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movl %ebp, %ecx
leaq 0x11842(%rip), %rax     # 0x140d0
movq %rcx, 0x18(%rsp)
movb (%rax,%rcx,4), %bl
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movq %r14, %rdi
callq 0xbf3a
movl %eax, %r12d
cmpl %eax, %r15d
jne 0x2ba2
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2ba2
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movq %r14, %rdi
movl %ebp, %esi
callq 0x6a95
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movl %eax, %r15d
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movq %r14, %rdi
callq 0x127d5
movl %eax, %r12d
cmpl %eax, %r15d
jne 0x2c1b
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2c1b
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movq %r14, %rdi
movl %ebp, %esi
callq 0x6ad3
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movq %rax, %r15
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movq %r14, %rdi
callq 0xc136
movq %rax, %r12
cmpq %rax, %r15
jne 0x2ca1
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2ca1
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movq %r14, %rdi
movl %ebp, %esi
callq 0x6be7
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movq %rax, %r15
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movq %r14, %rdi
callq 0x127ff
movq %rax, %r12
cmpq %rax, %r15
jne 0x2d1a
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2d1a
pushq $0x20
popq %rdi
callq 0x11bc
movl %eax, %r14d
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movl %eax, %edi
movl %ebp, %esi
callq 0x6a9d
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movq %rax, %r15
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movl %r14d, %edi
callq 0x9299
movq %rax, %r12
cmpq %rax, %r15
jne 0x2da0
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2da0
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movl %r14d, %edi
movl %ebp, %esi
callq 0x6ace
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movq %rax, %r15
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movl %r14d, %edi
callq 0x126b9
movq %rax, %r12
cmpq %rax, %r15
jne 0x2dcd
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2dcd
pushq $0x40
popq %rdi
callq 0x1cc6
movq %rax, %r14
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movq %rax, %rdi
movl %ebp, %esi
callq 0x6bef
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movq %rax, %r15
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movq %r14, %rdi
callq 0x9559
movq %rax, %r12
cmpq %rax, %r15
jne 0x2e04
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2e04
movl %r13d, 0x24(%rsp)
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movq %r14, %rdi
movl %ebp, %esi
callq 0x6c40
leaq 0x10(%rsp), %rsi
andl $0x0, (%rsi)
andw $0x0, 0x4(%rsi)
movq %rax, %r15
movb %bl, 0x1(%rsi)
movb $0x1, 0x6(%rsi)
movq %r14, %rdi
callq 0x9703
movq %rax, %r12
cmpq %rax, %r15
jne 0x2e31
leaq 0x10(%rsp), %rdi
callq 0x137c
cmpl 0xc(%rsp), %eax
jne 0x2e31
leaq 0xc(%rsp), %r14
andl $0x0, (%r14)
movl $0x80, %edi
callq 0x1d49
movabsq $0x1fffffffffffff, %rbx # imm = 0x1FFFFFFFFFFFFF
andq %rax, %rbx
callq 0x1090
andl $0x1, %eax
movq %rax, %rcx
negq %rcx
xorl %r12d, %r12d
movq %rbx, %r13
negq %r13
sbbq %r12, %r12
testq %rax, %rax
cmoveq %rbx, %r13
andq %rcx, %r12
movq %r13, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %r14, %rcx
callq 0x6da2
movq %rax, %rbx
andl $0x0, (%r14)
movq %rax, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x6c45
movq %rax, %r14
xorq %r13, %rax
movq %rdx, %rcx
xorq %r12, %rcx
orq %rax, %rcx
jne 0x2ece
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19217(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x11609(%rip), %rdi     # 0x141c2
pushq $0x40
popq %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x115cd(%rip), %rdi     # 0x1419a
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
callq 0x2653
pushq $0xa
popq %rdi
callq 0x1030
leaq 0x11601(%rip), %rdi     # 0x141ec
movl %r12d, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x10(%rsp), %rdi
callq 0x137c
leaq 0x115a6(%rip), %rbx     # 0x141ac
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x115db(%rip), %rdi     # 0x141f4
jmp 0x2c92
leaq 0x1919e(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x115ca(%rip), %rdi     # 0x141fc
pushq $0x40
popq %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x11554(%rip), %rdi     # 0x1419a
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
callq 0x2653
pushq $0xa
popq %rdi
callq 0x1030
leaq 0x115c2(%rip), %rdi     # 0x14226
movl %r12d, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x10(%rsp), %rdi
callq 0x137c
leaq 0x1152d(%rip), %rbx     # 0x141ac
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x1159c(%rip), %rdi     # 0x1422e
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
jmp 0x2eb8
leaq 0x19118(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x1157e(%rip), %rdi     # 0x14236
pushq $0x40
popq %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x114ce(%rip), %rdi     # 0x1419a
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
callq 0x2653
pushq $0xa
popq %rdi
callq 0x1030
leaq 0x11576(%rip), %rdi     # 0x14260
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
leaq 0x10(%rsp), %rdi
callq 0x137c
leaq 0x114a7(%rip), %rbx     # 0x141ac
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x11551(%rip), %rdi     # 0x14269
jmp 0x2d91
leaq 0x1909f(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x11541(%rip), %rdi     # 0x14272
pushq $0x40
popq %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x11455(%rip), %rdi     # 0x1419a
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
callq 0x2653
pushq $0xa
popq %rdi
callq 0x1030
leaq 0x11539(%rip), %rdi     # 0x1429c
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
leaq 0x10(%rsp), %rdi
callq 0x137c
leaq 0x1142e(%rip), %rbx     # 0x141ac
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x11514(%rip), %rdi     # 0x142a5
movq %r15, %rsi
xorl %eax, %eax
callq 0x1070
jmp 0x2eb8
leaq 0x19019(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x114f7(%rip), %rdi     # 0x142ae
pushq $0x40
popq %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x1150c(%rip), %rdi     # 0x142d7
jmp 0x2df8
leaq 0x18fec(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x114fb(%rip), %rdi     # 0x142df
pushq $0x40
popq %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x11510(%rip), %rdi     # 0x14308
movl %r14d, %esi
xorl %eax, %eax
callq 0x1070
jmp 0x2e67
leaq 0x18fb5(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x114f6(%rip), %rdi     # 0x14311
pushq $0x40
popq %rsi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x1150b(%rip), %rdi     # 0x1433a
jmp 0x2e5d
leaq 0x18f88(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x114fb(%rip), %rdi     # 0x14343
pushq $0x40
popq %rsi
movl 0x24(%rsp), %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x1150f(%rip), %rdi     # 0x1436c
movq %r14, %rsi
xorl %eax, %eax
callq 0x1070
pushq $0xa
popq %rdi
callq 0x1030
leaq 0x11330(%rip), %rdi     # 0x141a6
xorl %eax, %eax
callq 0x1070
movq %r12, %rdi
callq 0x2653
leaq 0x10(%rsp), %rdi
callq 0x137c
leaq 0x11316(%rip), %rbx     # 0x141ac
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x11313(%rip), %rdi     # 0x141bc
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
callq 0x2653
movl 0xc(%rsp), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1070
pushq $0x1
popq %rdi
callq 0x10b0
movq %rdx, %r15
leaq 0x18ee8(%rip), %rax     # 0x1bdc0
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x1148d(%rip), %rdi     # 0x14375
pushq $0x40
popq %rsi
movl 0x24(%rsp), %ecx
xorl %eax, %eax
callq 0x1070
leaq 0x1129d(%rip), %rdi     # 0x1419a
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x2653
pushq $0xa
popq %rbx
movl %ebx, %edi
callq 0x1030
leaq 0x11289(%rip), %rdi     # 0x141a6
xorl %eax, %eax
callq 0x1070
movq %r13, %rdi
movq %r12, %rsi
callq 0x1e18
movl %ebx, %edi
callq 0x1030
leaq 0x10(%rsp), %rdi
callq 0x137c
leaq 0x11265(%rip), %r12     # 0x141ac
movq %r12, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x11262(%rip), %rdi     # 0x141bc
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movq %r15, %rsi
callq 0x1e18
movl %ebx, %edi
callq 0x1030
movl 0xc(%rsp), %esi
movq %r12, %rdi
jmp 0x2ebf