// File: /workspace/github_c_makefile_star2_O0/JesseBuesking[P]omnomnum/omnomnum.c
// Function: normalize
void normalize(const char *data, size_t data_len, ParserState *state) {
    YYSTYPEList l = find_numbers(data, data_len, state);

    if (l.used == 0) {
        state->result = sdsnew(data);
    } else {
        state->result = sdsempty();

        unsigned int lastpos = 0;
        unsigned int i = 0;

        for (i = 0; i < l.used; ++i) {
            YYSTYPE y = l.values[i];

#if debug
            printf("begin: %d, end: %d, value: %lf, suffix: %d\n", y.begin, y.end, y.dbl, y.suffix);
#endif

            if (lastpos < y.begin) {
                // Copy the part of the string leading up to the number to
                // the final string.
                state->result = sdscatlen(
                        state->result,
                        data + lastpos,
                        y.begin - lastpos
                        );
                sdsclear(numberHolder);
            }
            lastpos = y.end;

            yystypeToString(&numberHolder, y, state->precision);
            state->result = sdscatsds(state->result, numberHolder);

            sdsclear(numberHolder);

            // in case the last string was exceptionally large, free up memory
            // TODO test this out
            if (sdslen(numberHolder) > 1) {
                sdsRemoveFreeSpace(numberHolder);
            }
        }

        // Copy what's left of the string to the final string.
        state->result = sdscatlen(
                state->result,
                data + l.values[l.used-1].end,
                data_len - l.values[l.used-1].end
                );
    }
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0x80(%rsp), %rcx
leaq 0x68(%rsp), %rdi
callq 0x9b50
cmpq $0x0, 0x70(%rsp)
jne 0x9dca
movq 0x90(%rsp), %rdi
callq 0x11da0
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x9f79
callq 0x11d80
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, 0x64(%rsp)
movl $0x0, 0x60(%rsp)
movl $0x0, 0x60(%rsp)
movl 0x60(%rsp), %eax
cmpq 0x70(%rsp), %rax
jae 0x9f13
movq 0x68(%rsp), %rsi
movl 0x60(%rsp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rsi
leaq 0x30(%rsp), %rdi
movl $0x30, %edx
callq 0x10d0
movl 0x64(%rsp), %eax
cmpl 0x54(%rsp), %eax
jae 0x9e75
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x90(%rsp), %rsi
movl 0x64(%rsp), %eax
addq %rax, %rsi
movl 0x54(%rsp), %eax
subl 0x64(%rsp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x12810
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x162a0(%rip), %rdi     # 0x20110
callq 0x11ff0
movl 0x58(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0x80(%rsp), %rax
movl (%rax), %esi
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups 0x50(%rsp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq 0x16265(%rip), %rdi     # 0x20110
callq 0x99c0
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x1624d(%rip), %rsi     # 0x20110
callq 0x12900
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x16232(%rip), %rdi     # 0x20110
callq 0x11ff0
movq 0x16226(%rip), %rdi     # 0x20110
callq 0x9f90
cmpq $0x1, %rax
jbe 0x9f01
movq 0x16214(%rip), %rdi     # 0x20110
callq 0x12390
jmp 0x9f03
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x9df6
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0x90(%rsp), %rsi
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq $0x1, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x28(%rax), %eax
addq %rax, %rsi
movq 0x88(%rsp), %rdx
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
subq $0x1, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x28(%rax), %eax
subq %rax, %rdx
callq 0x12810
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x8(%rax)
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)