// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/sparkline.c
// Function: sparklineRenderRange
sds sparklineRenderRange(sds output, struct sequence *seq, int rows, int offset, int len, int flags) {
    int j;
    double relmax = seq->max - seq->min;
    int steps = charset_len*rows;
    int row = 0;
    char *chars = zmalloc(len);
    int loop = 1;
    int opt_fill = flags & SPARKLINE_FILL;
    int opt_log = flags & SPARKLINE_LOG_SCALE;

    if (opt_log) {
        relmax = log(relmax+1);
    } else if (relmax == 0) {
        relmax = 1;
    }

    while(loop) {
        loop = 0;
        memset(chars,' ',len);
        for (j = 0; j < len; j++) {
            struct sample *s = &seq->samples[j+offset];
            double relval = s->value - seq->min;
            int step;

            if (opt_log) relval = log(relval+1);
            step = (int) (relval*steps)/relmax;
            if (step < 0) step = 0;
            if (step >= steps) step = steps-1;

            if (row < rows) {
                /* Print the character needed to create the sparkline */
                int charidx = step-((rows-row-1)*charset_len);
                loop = 1;
                if (charidx >= 0 && charidx < charset_len) {
                    chars[j] = opt_fill ? charset_fill[charidx] :
                                          charset[charidx];
                } else if(opt_fill && charidx >= charset_len) {
                    chars[j] = '|';
                }
            } else {
                /* Labels spacing */
                if (seq->labels && row-rows < label_margin_top) {
                    loop = 1;
                    break;
                }
                /* Print the label if needed. */
                if (s->label) {
                    int label_len = strlen(s->label);
                    int label_char = row - rows - label_margin_top;

                    if (label_len > label_char) {
                        loop = 1;
                        chars[j] = s->label[label_char];
                    }
                }
            }
        }
        if (loop) {
            row++;
            output = sdscatlen(output,chars,len);
            output = sdscatlen(output,"\n",1);
        }
    }
    zfree(chars);
    return output;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x10(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x10(%rbp), %rax
subsd 0x10(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movl 0xd4eda(%rip), %eax     # 0x177748
imull -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movslq -0x1c(%rbp), %rdi
callq 0x3acd0
movq %rax, -0x40(%rbp)
movl $0x1, -0x44(%rbp)
movl -0x20(%rbp), %eax
andl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x20(%rbp), %eax
andl $0x2, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0xa28c1
movsd 0x94bb8(%rip), %xmm0    # 0x137468
addsd -0x30(%rbp), %xmm0
callq 0x264a0
movsd %xmm0, -0x30(%rbp)
jmp 0xa28e0
movsd -0x30(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xa28de
jp 0xa28de
movsd 0x94b8f(%rip), %xmm0    # 0x137468
movsd %xmm0, -0x30(%rbp)
jmp 0xa28e0
jmp 0xa28e2
cmpl $0x0, -0x44(%rbp)
je 0xa2b0c
movl $0x0, -0x44(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x1c(%rbp), %rdx
movl $0x20, %esi
callq 0x26110
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0xa2aca
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x24(%rbp), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movsd (%rax), %xmm0
movq -0x10(%rbp), %rax
subsd 0x10(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0xa2967
movsd 0x94b10(%rip), %xmm0    # 0x137468
addsd -0x60(%rbp), %xmm0
callq 0x264a0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
divsd -0x30(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jge 0xa2996
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0xa29a7
movl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xa2a42
movl -0x64(%rbp), %eax
movl -0x14(%rbp), %ecx
subl -0x38(%rbp), %ecx
subl $0x1, %ecx
imull 0xd4d82(%rip), %ecx     # 0x177748
subl %ecx, %eax
movl %eax, -0x68(%rbp)
movl $0x1, -0x44(%rbp)
cmpl $0x0, -0x68(%rbp)
jl 0xa2a21
movl -0x68(%rbp), %eax
cmpl 0xd4d67(%rip), %eax     # 0x177748
jge 0xa2a21
cmpl $0x0, -0x48(%rbp)
je 0xa29fd
movslq -0x68(%rbp), %rcx
leaq 0xd4d58(%rip), %rax     # 0x17774c
movsbl (%rax,%rcx), %eax
movl %eax, -0x74(%rbp)
jmp 0xa2a0f
movslq -0x68(%rbp), %rcx
leaq 0xd4d48(%rip), %rax     # 0x177750
movsbl (%rax,%rcx), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movb %al, %dl
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0xa2a40
cmpl $0x0, -0x48(%rbp)
je 0xa2a3e
movl -0x68(%rbp), %eax
cmpl 0xd4d18(%rip), %eax     # 0x177748
jl 0xa2a3e
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb $0x7c, (%rax,%rcx)
jmp 0xa2a40
jmp 0xa2aba
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0xa2a63
movl -0x38(%rbp), %eax
subl -0x14(%rbp), %eax
cmpl 0xd4cfc(%rip), %eax     # 0x177754
jge 0xa2a63
movl $0x1, -0x44(%rbp)
jmp 0xa2aca
movq -0x58(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xa2ab8
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x264f0
movl %eax, -0x6c(%rbp)
movl -0x38(%rbp), %eax
subl -0x14(%rbp), %eax
subl 0xd4cca(%rip), %eax     # 0x177754
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x70(%rbp), %eax
jle 0xa2ab6
movl $0x1, -0x44(%rbp)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x70(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0xa2ab8
jmp 0xa2aba
jmp 0xa2abc
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xa290c
cmpl $0x0, -0x44(%rbp)
je 0xa2b07
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq -0x1c(%rbp), %rdx
callq 0x39040
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x97340(%rip), %rsi     # 0x139e39
movl $0x1, %edx
callq 0x39040
movq %rax, -0x8(%rbp)
jmp 0xa28e2
movq -0x40(%rbp), %rdi
callq 0x3afa0
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)