// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/test_kstring.c
// Function: test_kputw
static int test_kputw(int64_t start, int64_t end) {
    kstring_t str = { 0, 0, NULL };
    int64_t val;

    str.s = malloc(2);
    if (!str.s) {
        perror("malloc");
        return -1;
    }
    str.m = 2;

    for (val = 1; val < INT_MAX; val *= 10) {
        if (test_kputw_from_to(&str, val > 5 ? val - 5 : 0, val + 5) < 0) {
            free(ks_release(&str));
            return -1;
        }
    }

    for (val = -1; val > INT_MIN; val *= 10) {
        if (test_kputw_from_to(&str, val - 5, val < -5 ? val + 5 : 0) < 0) {
            free(ks_release(&str));
            return -1;
        }
    }

    if (test_kputw_from_to(&str, INT_MAX - 5, INT_MAX) < 0) {
        free(ks_release(&str));
        return -1;
    }

    if (test_kputw_from_to(&str, INT_MIN, INT_MIN + 5) < 0) {
        free(ks_release(&str));
        return -1;
    }

    str.m = 1; // Force a resize
    clamp(&start, INT_MIN, INT_MAX);
    clamp(&end,   INT_MIN, INT_MAX);

    if (test_kputw_from_to(&str, start, end) < 0) {
        free(ks_release(&str));
        return -1;
    }

    free(ks_release(&str));

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x10b0
movl $0x2, %edi
callq 0x1130
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x1ccd
leaq 0x47b1(%rip), %rdi      # 0x646d
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eac
movq $0x2, -0x28(%rbp)
movq $0x1, -0x38(%rbp)
cmpq $0x7fffffff, -0x38(%rbp) # imm = 0x7FFFFFFF
jge 0x1d4c
cmpq $0x5, -0x38(%rbp)
jle 0x1cfc
movq -0x38(%rbp), %rax
subq $0x5, %rax
movq %rax, -0x40(%rbp)
jmp 0x1d04
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x1d04
movq -0x40(%rbp), %rax
movl %eax, %esi
movq -0x38(%rbp), %rax
addq $0x5, %rax
movl %eax, %edx
leaq -0x30(%rbp), %rdi
callq 0x3030
cmpl $0x0, %eax
jge 0x1d3f
leaq -0x30(%rbp), %rdi
callq 0x2d60
movq %rax, %rdi
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eac
jmp 0x1d41
imulq $0xa, -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x1cdd
movq $-0x1, -0x38(%rbp)
cmpq $-0x80000000, -0x38(%rbp) # imm = 0x80000000
jle 0x1dc7
movq -0x38(%rbp), %rax
subq $0x5, %rax
movl %eax, -0x44(%rbp)
cmpq $-0x5, -0x38(%rbp)
jge 0x1d7e
movq -0x38(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x50(%rbp)
jmp 0x1d86
xorl %eax, %eax
movq %rax, -0x50(%rbp)
jmp 0x1d86
movl -0x44(%rbp), %esi
movq -0x50(%rbp), %rax
movl %eax, %edx
leaq -0x30(%rbp), %rdi
callq 0x3030
cmpl $0x0, %eax
jge 0x1dba
leaq -0x30(%rbp), %rdi
callq 0x2d60
movq %rax, %rdi
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eac
jmp 0x1dbc
imulq $0xa, -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x1d54
leaq -0x30(%rbp), %rdi
movl $0x7ffffffa, %esi       # imm = 0x7FFFFFFA
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
callq 0x3030
cmpl $0x0, %eax
jge 0x1dfc
leaq -0x30(%rbp), %rdi
callq 0x2d60
movq %rax, %rdi
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eac
leaq -0x30(%rbp), %rdi
movl $0x80000000, %esi       # imm = 0x80000000
movl $0x80000005, %edx       # imm = 0x80000005
callq 0x3030
cmpl $0x0, %eax
jge 0x1e2e
leaq -0x30(%rbp), %rdi
callq 0x2d60
movq %rax, %rdi
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eac
movq $0x1, -0x28(%rbp)
leaq -0x10(%rbp), %rdi
movq $-0x80000000, %rsi      # imm = 0x80000000
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
callq 0x2da0
leaq -0x18(%rbp), %rdi
movq $-0x80000000, %rsi      # imm = 0x80000000
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
callq 0x2da0
movq -0x10(%rbp), %rax
movl %eax, %esi
movq -0x18(%rbp), %rax
movl %eax, %edx
leaq -0x30(%rbp), %rdi
callq 0x3030
cmpl $0x0, %eax
jge 0x1e94
leaq -0x30(%rbp), %rdi
callq 0x2d60
movq %rax, %rdi
callq 0x1120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1eac
leaq -0x30(%rbp), %rdi
callq 0x2d60
movq %rax, %rdi
callq 0x1120
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)