// File: /workspace/github_c_makefile_star2_O0/lecram[P]congif/main.c
// Function: convert_script
int
convert_script()
{
    FILE *ft;
    int fd;
    float t;
    int n;
    uint8_t ch;
    Font *font;
    int w, h;
    int i, c;
    float d;
    uint16_t rd, id = 0;
    float lastdone, done;
    char pb[options.barsize+1];
    char fl[512];
    int fln = 0;
    GIF *gif;
    Term *term;

    ft = fopen(options.timings, "r");
    if (!ft) {
        fprintf(stderr, "error: could not load timings: %s\n", options.timings);
        goto no_ft;
    }
    fd = open(options.dialogue, O_RDONLY);
    if (fd == -1) {
        fprintf(stderr, "error: could not load dialogue: %s\n", options.dialogue);
        goto no_fd;
    }
    if (options.font == 0) {
	font = default_font;
    } else {
	font = load_font(options.font);
	if (!font) {
	    fprintf(stderr, "error: could not load font: %s\n", options.font);
	    goto no_font;
	}
    }

    /* Save first line of dialogue */
    do {
        if (read(fd, &ch, 1) <= 0) break;
        if (fln<(int)sizeof(fl)-1) fl[fln++]=ch;
    } while (ch != '\n');
    /* Inspect it for the terminal size if needed */
    if (fln > 16 && (options.height == 0 || options.width == 0)) {
        int col=0, ln=0;
        char * s;
        fl[fln] = 0;
        s = strstr(fl, "COLUMNS=\"");
        if (s) col = atoi(s+9);
        s = strstr(fl, "LINES=\"");
        if (s) ln = atoi(s+7);

        if (ln>0 && col>0) {
            if (options.width <= 0)
                options.width = col;
            if (options.height <= 0)
                options.height = ln;
        }
    }

    /* Default the VT to our real terminal */
    if (options.has_winsize && (options.height == 0 || options.width == 0)) {
        if (options.height <= 0)
            options.height = options.size.ws_row;
        if (options.width <= 0)
            options.width = options.size.ws_col;
    }

    if (options.width <= 0 || options.height <= 0) {
        fprintf(stderr, "error: no terminal size specified\n");
        goto no_termsize;
    }

    term = new_term(options.height, options.width);
    w = term->cols * font->header.w;
    h = term->rows * font->header.h;
    gif = new_gif(options.output, w, h, term->plt, options.loop);
    if (!gif) {
        fprintf(stderr, "error: could not create GIF: %s\n", options.output);
        goto no_gif;
    }
    if (options.barsize) {
        pb[0] = '[';
        pb[options.barsize-1] = ']';
        pb[options.barsize] = '\0';
        for (i = 1; i < options.barsize-1; i++)
            pb[i] = '-';
        lastdone = 0;
        printf("%s\r[", pb);
        /* get number of chunks */
        for (c = 0; fscanf(ft, "%f %d\n", &t, &n) == 2; c++);
        rewind(ft);
    }
    i = 0;
    d = rd = 0;
    while (fscanf(ft, "%f %d\n", &t, &n) == 2) {
        if (options.barsize) {
            done = i * (options.barsize-1) / c;
            if (done > lastdone) {
                while (done > lastdone) {
                    putchar('#');
                    lastdone++;
                }
                fflush(stdout);
            }
        }
        d += (MIN(t, options.maxdelay) * 100.0 / options.divisor);
        rd = (uint16_t) MIN((int)(d + 0.5), 65535);
        if (i && rd >= MIN_DELAY) {
            render(term, font, gif, rd);
            d = 0;
        }
        if (i == 0) { id = rd; rd = 0; d = 0; }
        while (n--) {
            read(fd, &ch, 1);
            parse(term, ch);
        }
        if (!options.cursor)
            term->mode &= ~M_CURSORVIS;
        i++;
    }
    rd += id;
    if (options.barsize) {
        while (lastdone < options.barsize-2) {
            putchar('#');
            lastdone++;
        }
        putchar('\n');
    }
    render(term, font, gif, MAX(rd, 1));
    close_gif(gif);
    free(term);
    return 0;
no_gif:
    free(term);
no_termsize:
    if (options.font) free(font);
no_font:
    close(fd);
no_fd:
    fclose(ft);
no_ft:
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movw $0x0, -0x40(%rbp)
movl 0x8fe9(%rip), %eax      # 0xe840
incl %eax
movq %rsp, %rcx
movq %rcx, -0x50(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x298(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl $0x0, -0x264(%rbp)
movq 0x8f70(%rip), %rdi      # 0xe800
leaq 0x1ccc(%rip), %rsi      # 0x7563
callq 0x11b0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x58cb
movq 0x474a(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x8f48(%rip), %rdx      # 0xe800
leaq 0x1f35(%rip), %rsi      # 0x77f4
movb $0x0, %al
callq 0x1140
jmp 0x5fc0
movq 0x8f36(%rip), %rdi      # 0xe808
xorl %esi, %esi
movb $0x0, %al
callq 0x11a0
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x5908
movq 0x470d(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x8f13(%rip), %rdx      # 0xe808
leaq 0x1f1b(%rip), %rsi      # 0x7817
movb $0x0, %al
callq 0x1140
jmp 0x5fb7
cmpq $0x0, 0x8f18(%rip)      # 0xe828
jne 0x591f
leaq 0x8eb7(%rip), %rax      # 0xe7d0
movq %rax, -0x28(%rbp)
jmp 0x595c
movq 0x8f02(%rip), %rdi      # 0xe828
callq 0x45e0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x595a
movq 0x46bb(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x8ee1(%rip), %rdx      # 0xe828
leaq 0x1eed(%rip), %rsi      # 0x783b
movb $0x0, %al
callq 0x1140
jmp 0x5faf
jmp 0x595c
jmp 0x595e
movl -0x14(%rbp), %edi
leaq -0x1d(%rbp), %rsi
movl $0x1, %edx
callq 0x10f0
cmpq $0x0, %rax
jg 0x5977
jmp 0x59ab
cmpl $0x1ff, -0x264(%rbp)    # imm = 0x1FF
jge 0x59a0
movb -0x1d(%rbp), %cl
movl -0x264(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x264(%rbp)
cltq
movb %cl, -0x260(%rbp,%rax)
jmp 0x59a2
movzbl -0x1d(%rbp), %eax
cmpl $0xa, %eax
jne 0x595e
cmpl $0x10, -0x264(%rbp)
jle 0x5aa5
cmpl $0x0, 0x8e71(%rip)      # 0xe830
je 0x59ce
cmpl $0x0, 0x8e6c(%rip)      # 0xe834
jne 0x5aa5
movl $0x0, -0x27c(%rbp)
movl $0x0, -0x280(%rbp)
movslq -0x264(%rbp), %rax
movb $0x0, -0x260(%rbp,%rax)
leaq -0x260(%rbp), %rdi
leaq 0x1e5c(%rip), %rsi      # 0x785b
callq 0x1220
movq %rax, -0x288(%rbp)
cmpq $0x0, -0x288(%rbp)
je 0x5a2b
movq -0x288(%rbp), %rdi
addq $0x9, %rdi
callq 0x11e0
movl %eax, -0x27c(%rbp)
leaq -0x260(%rbp), %rdi
leaq 0x1e2c(%rip), %rsi      # 0x7865
callq 0x1220
movq %rax, -0x288(%rbp)
cmpq $0x0, -0x288(%rbp)
je 0x5a65
movq -0x288(%rbp), %rdi
addq $0x7, %rdi
callq 0x11e0
movl %eax, -0x280(%rbp)
cmpl $0x0, -0x280(%rbp)
jle 0x5aa3
cmpl $0x0, -0x27c(%rbp)
jle 0x5aa3
cmpl $0x0, 0x8db6(%rip)      # 0xe834
jg 0x5a8c
movl -0x27c(%rbp), %eax
movl %eax, 0x8da8(%rip)      # 0xe834
cmpl $0x0, 0x8d9d(%rip)      # 0xe830
jg 0x5aa1
movl -0x280(%rbp), %eax
movl %eax, 0x8d8f(%rip)      # 0xe830
jmp 0x5aa3
jmp 0x5aa5
cmpl $0x0, 0x8d98(%rip)      # 0xe844
je 0x5aee
cmpl $0x0, 0x8d7b(%rip)      # 0xe830
je 0x5ac0
cmpl $0x0, 0x8d76(%rip)      # 0xe834
jne 0x5aee
cmpl $0x0, 0x8d69(%rip)      # 0xe830
jg 0x5ad6
movzwl 0x8d78(%rip), %eax      # 0xe848
movl %eax, 0x8d5a(%rip)      # 0xe830
cmpl $0x0, 0x8d57(%rip)      # 0xe834
jg 0x5aec
movzwl 0x8d64(%rip), %eax      # 0xe84a
movl %eax, 0x8d48(%rip)      # 0xe834
jmp 0x5aee
cmpl $0x0, 0x8d3f(%rip)      # 0xe834
jle 0x5b00
cmpl $0x0, 0x8d32(%rip)      # 0xe830
jg 0x5b1d
movq 0x44f1(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x1d5c(%rip), %rsi      # 0x786d
movb $0x0, %al
callq 0x1140
jmp 0x5f9a
movl 0x8d0d(%rip), %edi      # 0xe830
movl 0x8d0b(%rip), %esi      # 0xe834
callq 0x17c0
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
imull %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x278(%rbp), %rax
movl (%rax), %eax
movq -0x28(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
imull %ecx, %eax
movl %eax, -0x30(%rbp)
movq 0x8ca5(%rip), %rdi      # 0xe810
movl -0x2c(%rbp), %eax
movw %ax, %dx
movl -0x30(%rbp), %eax
movq -0x278(%rbp), %rcx
addq $0x16c, %rcx            # imm = 0x16C
movl 0x8c97(%rip), %r8d      # 0xe820
movzwl %dx, %esi
movzwl %ax, %edx
callq 0x4890
movq %rax, -0x270(%rbp)
cmpq $0x0, -0x270(%rbp)
jne 0x5bc9
movq 0x444c(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x8c5a(%rip), %rdx      # 0xe810
leaq 0x1cd3(%rip), %rsi      # 0x7890
movb $0x0, %al
callq 0x1140
jmp 0x5f8e
cmpl $0x0, 0x8c70(%rip)      # 0xe840
je 0x5c85
movq -0x298(%rbp), %rax
movb $0x5b, (%rax)
movl 0x8c5a(%rip), %ecx      # 0xe840
subl $0x1, %ecx
movslq %ecx, %rcx
movb $0x5d, (%rax,%rcx)
movslq 0x8c49(%rip), %rcx      # 0xe840
movb $0x0, (%rax,%rcx)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl 0x8c35(%rip), %ecx      # 0xe840
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x5c2c
movq -0x298(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5c02
movq -0x298(%rbp), %rsi
xorps %xmm0, %xmm0
movss %xmm0, -0x44(%rbp)
leaq 0x1c6f(%rip), %rdi      # 0x78b1
movb $0x0, %al
callq 0x10a0
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1c5b(%rip), %rsi      # 0x78b6
leaq -0x18(%rbp), %rdx
leaq -0x1c(%rbp), %rcx
movb $0x0, %al
callq 0x1060
cmpl $0x2, %eax
jne 0x5c7c
jmp 0x5c71
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5c50
movq -0x10(%rbp), %rdi
callq 0x10b0
movl $0x0, -0x34(%rbp)
movw $0x0, -0x3e(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1c11(%rip), %rsi      # 0x78b6
leaq -0x18(%rbp), %rdx
leaq -0x1c(%rbp), %rcx
movb $0x0, %al
callq 0x1060
cmpl $0x2, %eax
jne 0x5e9f
cmpl $0x0, 0x8b7c(%rip)      # 0xe840
je 0x5d29
movl -0x34(%rbp), %eax
movl 0x8b71(%rip), %ecx      # 0xe840
subl $0x1, %ecx
imull %ecx, %eax
cltd
idivl -0x38(%rbp)
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x48(%rbp), %xmm0
ucomiss -0x44(%rbp), %xmm0
jbe 0x5d27
jmp 0x5cef
movss -0x48(%rbp), %xmm0
ucomiss -0x44(%rbp), %xmm0
jbe 0x5d18
movl $0x23, %edi
callq 0x1040
movss 0x1a7c(%rip), %xmm0     # 0x7788
addss -0x44(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
jmp 0x5cef
movq 0x42a9(%rip), %rax      # 0x9fc8
movq (%rax), %rdi
callq 0x1190
jmp 0x5d29
movss -0x18(%rbp), %xmm1
movss 0x8ae2(%rip), %xmm0     # 0xe818
ucomiss %xmm1, %xmm0
jbe 0x5d4a
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x29c(%rbp)
jmp 0x5d5a
movss 0x8ac6(%rip), %xmm0     # 0xe818
movss %xmm0, -0x29c(%rbp)
movss -0x29c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1a2a(%rip), %xmm0     # 0x7798
mulsd %xmm0, %xmm1
movss 0x8aa2(%rip), %xmm0     # 0xe81c
cvtss2sd %xmm0, %xmm0
divsd %xmm0, %xmm1
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x19e7(%rip), %xmm1     # 0x7790
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jge 0x5dd9
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x19c7(%rip), %xmm1     # 0x7790
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2a0(%rbp)
jmp 0x5de6
movl $0xffff, %eax           # imm = 0xFFFF
movl %eax, -0x2a0(%rbp)
jmp 0x5de6
movl -0x2a0(%rbp), %eax
movw %ax, -0x3e(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x5e22
movzwl -0x3e(%rbp), %eax
cmpl $0x6, %eax
jl 0x5e22
movq -0x278(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x270(%rbp), %rdx
movzwl -0x3e(%rbp), %ecx
callq 0x5730
xorps %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x5e3e
movw -0x3e(%rbp), %ax
movw %ax, -0x40(%rbp)
movw $0x0, -0x3e(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
jmp 0x5e40
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x1c(%rbp)
cmpl $0x0, %eax
je 0x5e73
movl -0x14(%rbp), %edi
leaq -0x1d(%rbp), %rsi
movl $0x1, %edx
callq 0x10f0
movq -0x278(%rbp), %rdi
movzbl -0x1d(%rbp), %esi
callq 0x1a30
jmp 0x5e40
cmpl $0x0, 0x89be(%rip)      # 0xe838
jne 0x5e91
movq -0x278(%rbp), %rax
movzwl 0x18(%rax), %ecx
andl $0xfffffbff, %ecx       # imm = 0xFFFFFBFF
movw %cx, 0x18(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5c9a
movzwl -0x40(%rbp), %ecx
movzwl -0x3e(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x3e(%rbp)
cmpl $0x0, 0x898c(%rip)      # 0xe840
je 0x5ef7
jmp 0x5eb8
movss -0x44(%rbp), %xmm1
movl 0x897d(%rip), %eax      # 0xe840
subl $0x2, %eax
cvtsi2ss %eax, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5eed
movl $0x23, %edi
callq 0x1040
movss 0x18a7(%rip), %xmm0     # 0x7788
addss -0x44(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
jmp 0x5eb8
movl $0xa, %edi
callq 0x1040
movq -0x278(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq -0x270(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movzwl -0x3e(%rbp), %eax
cmpl $0x1, %eax
jle 0x5f33
movzwl -0x3e(%rbp), %eax
movl %eax, -0x2bc(%rbp)
jmp 0x5f40
movl $0x1, %eax
movl %eax, -0x2bc(%rbp)
jmp 0x5f40
movq -0x2a8(%rbp), %rdx
movq -0x2b0(%rbp), %rsi
movq -0x2b8(%rbp), %rdi
movl -0x2bc(%rbp), %eax
movzwl %ax, %ecx
callq 0x5730
movq -0x270(%rbp), %rdi
callq 0x5140
movq -0x278(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl $0x1, -0x28c(%rbp)
jmp 0x5fd1
movq -0x278(%rbp), %rdi
callq 0x1030
cmpq $0x0, 0x8886(%rip)      # 0xe828
je 0x5fad
movq -0x28(%rbp), %rdi
callq 0x1030
jmp 0x5faf
movl -0x14(%rbp), %edi
callq 0x10e0
movq -0x10(%rbp), %rdi
callq 0x1090
movl $0x1, -0x4(%rbp)
movl $0x1, -0x28c(%rbp)
movq -0x50(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq