// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: generator
static int generator(const char *name)
{
    FILE *f = fopen(name, "w");
    char *ref = NULL;
    char qual[101];
    size_t i;
    uint32_t lfsr = 0xbadcafe;
    int res = -1;

    if (!f) {
        fail("Couldn't open \"%s\"", name);
        return -1;
    }

    ref = malloc(MAX_RECS + SEQ_LEN + 1);
    if (!ref) goto cleanup;
    for (i = 0; i < MAX_RECS + SEQ_LEN; i++) {
        // Linear-feedback shift register to make random reference
        lfsr ^= lfsr << 13;
        lfsr ^= lfsr >> 17;
        lfsr ^= lfsr << 5;
        ref[i] = "ACGT"[lfsr & 3];
    }
    ref[MAX_RECS + SEQ_LEN] = '\0';
    for (i = 0; i < SEQ_LEN; i++) {
        qual[i] = 'A' + (i & 0xf);
    }

    if (fputs("@HD\tVN:1.4\n", f) < 0) goto cleanup;
    if (fprintf(f, "@SQ\tSN:ref1\tLN:%d\n", MAX_RECS + SEQ_LEN) < 0)
        goto cleanup;
    for (i = 0; i < MAX_RECS; i++) {
        if (fprintf(f, "read%zu\t0\tref1\t%zu\t64\t100M\t*\t0\t0\t%.*s\t%.*s\n",
                    i + 1, i + 1, SEQ_LEN, ref + i, SEQ_LEN, qual) < 0)
            goto cleanup;
    }

    if (fclose(f) == 0)
        res = 0;
    f = NULL;

 cleanup:
    if (f) fclose(f);
    free(ref);
    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xe8534(%rip), %rsi     # 0xf6cee
callq 0x4590
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0xbadcafe, -0x9c(%rbp) # imm = 0xBADCAFE
movl $0xffffffff, -0xa0(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x18(%rbp)
jne 0xe804
movq -0x10(%rbp), %rsi
leaq 0xe419b(%rip), %rdi     # 0xf298c
movb $0x0, %al
callq 0x5b50
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xea02
movl $0x44d, %edi            # imm = 0x44D
callq 0x4650
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xe81e
jmp 0xe9e0
movq $0x0, -0x98(%rbp)
cmpq $0x44c, -0x98(%rbp) # imm = 0x44C
jae 0xe8b1
movl -0x9c(%rbp), %eax
shll $0xd, %eax
xorl -0x9c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
shrl $0x11, %eax
xorl -0x9c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
shll $0x5, %eax
xorl -0x9c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
andl $0x3, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0xeac21(%rip), %rax     # 0xf94aa
movb (%rax,%rcx), %dl
movq -0x20(%rbp), %rax
movq -0x98(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0xe829
movq -0x20(%rbp), %rax
movb $0x0, 0x44c(%rax)
movq $0x0, -0x98(%rbp)
cmpq $0x64, -0x98(%rbp)
jae 0xe904
movq -0x98(%rbp), %rax
andq $0xf, %rax
addq $0x41, %rax
movb %al, %cl
movq -0x98(%rbp), %rax
movb %cl, -0x90(%rbp,%rax)
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0xe8c7
movq -0x18(%rbp), %rsi
leaq 0xe4090(%rip), %rdi     # 0xf299f
callq 0x4530
cmpl $0x0, %eax
jge 0xe91e
jmp 0xe9e0
movq -0x18(%rbp), %rdi
leaq 0xe4082(%rip), %rsi     # 0xf29ab
movl $0x44c, %edx            # imm = 0x44C
movb $0x0, %al
callq 0x46d0
cmpl $0x0, %eax
jge 0xe93f
jmp 0xe9e0
movq $0x0, -0x98(%rbp)
cmpq $0x3e8, -0x98(%rbp) # imm = 0x3E8
jae 0xe9c0
movq -0x18(%rbp), %rdi
movq -0x98(%rbp), %rdx
addq $0x1, %rdx
movq -0x98(%rbp), %rcx
addq $0x1, %rcx
movq -0x20(%rbp), %r9
addq -0x98(%rbp), %r9
leaq -0x90(%rbp), %rax
leaq 0xe4034(%rip), %rsi     # 0xf29be
movl $0x64, %r8d
movl $0x64, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x46d0
cmpl $0x0, %eax
jge 0xe9aa
jmp 0xe9e0
jmp 0xe9ac
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0xe94a
movq -0x18(%rbp), %rdi
callq 0x4490
cmpl $0x0, %eax
jne 0xe9d8
movl $0x0, -0xa0(%rbp)
movq $0x0, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xe9f0
movq -0x18(%rbp), %rdi
callq 0x4490
movq -0x20(%rbp), %rdi
callq 0x45a0
movl -0xa0(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nop