// File: /workspace/github_c_makefile_star2_O0/adelciotto[P]scg/examples/matrix.c
// Function: draw
static void draw(scg_image_t *draw_target, matrix_t *matrix) {
    scg_image_clear(draw_target, SCG_COLOR_BLACK);

    int num_code_strings = matrix->num_code_strings;

    for (int i = 0; i < num_code_strings; i++) {
        code_string_t *code_string = &matrix->code_strings[i];
        int num_chars = code_string->num_chars;
        float32_t speed = code_string->speed;

        for (int j = 0; j < num_chars; j++) {
            scg_pixel_t color = SCG_COLOR_GREEN;
            if (j == 0) {
                color = SCG_COLOR_WHITE;
            } else if (j <= 3) {
                color = SCG_COLOR_GRAY;
            } else {
                float32_t shade = 1.0f - (float32_t)j / (float32_t)num_chars;
                color = shade_pixel(color, shade);
            }

            float32_t shade = scg_max_float32(0.1f, speed / 45.0f);
            color = shade_pixel(color, shade);

            int char_i =
                abs(j - (int)(code_string->y / CODE_STRING_CHAR_SIZE)) %
                code_string->num_chars;
            int y = (int)(code_string->y - (CODE_STRING_CHAR_SIZE * j));
            scg_image_draw_wchar(draw_target, code_string->chars[char_i],
                                 (int)code_string->x, (int)y, color);

            if (rand() % 1000 < 5) {
                code_string->chars[j] = random_wchar();
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movb $0x0, -0x14(%rbp)
movb $0x0, -0x13(%rbp)
movb $0x0, -0x12(%rbp)
movb $-0x1, -0x11(%rbp)
movl -0x14(%rbp), %esi
callq 0x3120
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x6b9a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x178, %rcx, %rcx      # imm = 0x178
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x6b8a
movl 0x160c(%rip), %eax      # 0x8040
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x6a55
movb $-0x1, -0x3c(%rbp)
movb $-0x1, -0x3b(%rbp)
movb $-0x1, -0x3a(%rbp)
movb $-0x1, -0x39(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x6aaa
cmpl $0x3, -0x34(%rbp)
jg 0x6a73
movb $-0x80, -0x40(%rbp)
movb $-0x80, -0x3f(%rbp)
movb $-0x80, -0x3e(%rbp)
movb $-0x1, -0x3d(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x6aa8
cvtsi2ssl -0x34(%rbp), %xmm1
cvtsi2ssl -0x2c(%rbp), %xmm0
divss %xmm0, %xmm1
movss 0x157f(%rip), %xmm0     # 0x8008
subss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm0
movl -0x38(%rbp), %edi
callq 0x6f90
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x6aaa
movss -0x30(%rbp), %xmm1
movss 0x1585(%rip), %xmm0     # 0x803c
divss %xmm0, %xmm1
movss 0x1571(%rip), %xmm0     # 0x8034
callq 0x25b0
movss %xmm0, -0x4c(%rbp)
movss -0x4c(%rbp), %xmm0
movl -0x38(%rbp), %edi
callq 0x6f90
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
movss 0x4(%rcx), %xmm0
movss 0x1541(%rip), %xmm1     # 0x8038
divss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movq -0x28(%rbp), %rcx
cltd
idivl 0xc(%rcx)
movl %edx, -0x54(%rbp)
movq -0x28(%rbp), %rax
movss 0x4(%rax), %xmm0
movl -0x34(%rbp), %eax
shll $0x3, %eax
cvtsi2ss %eax, %xmm1
subss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl 0x10(%rax,%rcx,4), %esi
movq -0x28(%rbp), %rax
cvttss2si (%rax), %edx
movl -0x58(%rbp), %ecx
movl -0x38(%rbp), %r8d
callq 0x4280
callq 0x2080
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cmpl $0x5, %edx
jge 0x6b7a
callq 0x6f40
movl %eax, %edx
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, 0x10(%rax,%rcx,4)
jmp 0x6b7c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x6a22
jmp 0x6b8c
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x69dd
addq $0x60, %rsp
popq %rbp
retq