// File: /workspace/github_c_makefile_star2_O0/FredTheDino[P]Fog/src/rain/editor_main.cpp
// Function: sprite_editor_update()
void sprite_editor_update() {
    Vec2 point;
    // Input
    {
        // Rename?
        if (fog_input_pressed((u32) In::EDIT_RENAME, Player::ANY)) {
            read_with_default("sprite rename", nullptr,
                    global_editor.sprites[global_editor.current_sprite].name,
                    MAX_TEXT_LENGTH);
        }

        const u32 num_sprites = global_editor.sprites.size();
        if (fog_input_pressed((u32) In::EDIT_PREV_SPRITE, Player::ANY) && num_sprites) {
            global_editor.current_sprite -= 1;
            global_editor.current_sprite += num_sprites;
            global_editor.current_sprite %= num_sprites;
        }
        if (fog_input_pressed((u32) In::EDIT_NEXT_SPRITE, Player::ANY) && num_sprites) {
            global_editor.current_sprite += 1;
            global_editor.current_sprite += num_sprites;
            global_editor.current_sprite %= num_sprites;
        }

        f32 delta = MIN(fog_logic_delta(), 0.2);
        f32 move_x = fog_input_value((u32) In::EDIT_MOVE_RIGHT_LEFT, Player::ANY);
        f32 move_y = fog_input_value((u32) In::EDIT_MOVE_UP_DOWN, Player::ANY);

        f32 zoom;
        if (fog_input_using_controller())
            zoom = (1.0 + fog_input_value((u32) In::EDIT_ZOOM_IN_OUT, Player::ANY) * delta);
        else
            zoom = (1.0 + (fog_input_mouse_scroll().y * 5) * delta);
        fog_renderer_fetch_camera(0)->zoom *= zoom;
        f32 current_zoom = fog_renderer_fetch_camera(0)->zoom;
        const f32 speed = delta / current_zoom;
        Vec2 cursor;
        if (fog_input_using_controller())
            cursor = global_editor.cursor;
        else
            cursor = fog_input_world_mouse_position(0);
        global_editor.worst_best_distance = global_editor.orig_worst_best_distance / current_zoom;

        if (fog_input_pressed((u32) In::EDIT_SNAP_SMALLER, Player::ANY)) {
            global_editor.snapping_scale *= global_editor.snapping_scale_step;
        }
        if (fog_input_pressed((u32) In::EDIT_SNAP_LARGER, Player::ANY)) {
            global_editor.snapping_scale /= global_editor.snapping_scale_step;
        }
        global_editor.snapping_scale = CLAMP(1.0 / 512.0, 1.0, global_editor.snapping_scale);

        if (fog_input_down((u32) In::TWEAK_STEP, Player::ANY)) {
            const f32 snap = global_editor.snapping_scale;
            static float step_timer = 0.0;
            step_timer += delta;
            if (step_timer > 0.1) {
                if (ABS(move_x) > 0.3)
                    cursor.x += SIGN(move_x) * snap * 1.1;
                if (ABS(move_y) > 0.3)
                    cursor.y += SIGN(move_y) * snap * 1.1;
                step_timer = 0.0;
            }
            precise_snap(&cursor.x, snap, snap);
            precise_snap(&cursor.y, snap, snap);
        } else {
            cursor += fog_V2(move_x, move_y) * speed;
        }
        cursor = fog_V2(CLAMP(-0.1, 1.1, cursor.x), CLAMP(-0.1, 1.1, cursor.y));
        global_editor.cursor = cursor;
        // Like a return value... but not...
        point = cursor;
    }

    if (fog_input_pressed((u32) In::EDIT_ADD_SPRITE, Player::ANY)) {
        create_new_sprite();
    }

    // Drawing logic
    {
        f32 current_zoom = fog_renderer_fetch_camera(0)->zoom;
        const f32 snap = global_editor.snapping_scale;
        const f32 line_width = 0.03 / current_zoom;
        const Vec4 dim_color = fog_V4(1, 0, 1, 0.05);
        const Vec4 vis_color = fog_V4(1, 0, 1, 0.2);
        Vec4 color = fog_input_down((u32) In::TWEAK_STEP, Player::ANY) ? vis_color : dim_color;
        for (u32 i = 0; i <= 1.0 / snap; i++) {
            Vec2 start, end;
            start = fog_V2(i * snap, 0.0);
            end = fog_V2(i * snap, 1.0);
            fog_renderer_push_line(5, start, end, color, line_width);
            start = fog_V2(0.0, i * snap);
            end = fog_V2(1.0, i * snap);
            fog_renderer_push_line(5, start, end, color, line_width);
        }
        const Vec4 cursor_color = fog_V4(0.0, 1.0, 0.0, 1.0);
        fog_renderer_push_point(10, point, cursor_color, 0.05 / current_zoom);
    }

    // Camera Movement
    {
        Camera *camera = fog_renderer_fetch_camera(0);
        f32 dist = fog_distance_v2(camera->position, point);
        f32 threshold = 0.5 / camera->zoom;
        if (dist > threshold) {
            f32 speed = 10 * (dist - threshold) * camera->zoom * fog_logic_delta();
            camera->position += (point - camera->position) * speed;
        }
    }

    // TODO(ed): Select sprite
    // TODO(ed): Allow multiple sprites to be editable at once
    // TODO(ed): Tweak values for things like, hue of the overlay
    // and such, so any sprite can be rendered underneath

    // Sprite select
    EditableSprite *sprite = &global_editor.sprites[global_editor.current_sprite];
    {
        AssetID next = sprite->sheet;
        if (fog_input_pressed((u32) In::EDIT_NEXT_SPRITE_SHEET, Player::ANY)) {
            next = find_next_sheet(next, 1);
        }
        if (fog_input_pressed((u32) In::EDIT_PREV_SPRITE_SHEET, Player::ANY)) {
            next = find_next_sheet(next, -1);
        }
        if (next != -1)
            sprite->sheet = next;
    }

    // Logic
    if (fog_input_down((u32) In::EDIT_SELECT, Player::ANY) || fog_input_mouse_down(0)) {
        s32 best_index = -1;
        f32 best_dist = global_editor.worst_best_distance;
        std::vector<Vec2> *points = &sprite->points;
        u32 num_points = points->size();
        for (u32 i = 0; i < num_points; i++) {
            f32 dist = fog_length_v2(point - (*points)[i]);
            if (dist < best_dist) {
                best_index = i;
                best_dist = dist;
            }
        }
        if (best_index >= 0) {
            (*points)[best_index] = point;
        }
    }

    if (fog_input_pressed((u32) In::EDIT_REMOVE, Player::ANY) || fog_input_mouse_pressed(3)) {
        s32 best_index = -1;
        f32 best_dist = global_editor.worst_best_distance;
        std::vector<Vec2> *points = &sprite->points;
        u32 num_points = points->size();
        for (u32 i = 0; i < num_points; i++) {
            f32 dist = fog_length_v2(point - (*points)[i]);
            if (dist < best_dist) {
                best_index = i;
                best_dist = dist;
            }
        }
        if (best_index >= 0) {
            points->erase(points->begin() + best_index);
        }
    }

    if (fog_input_pressed((u32) In::EDIT_PLACE, Player::ANY) || fog_input_mouse_pressed(2)) {
        s32 best_index = 0;
        f32 best_dist = 1000;
        std::vector<Vec2> *points = &sprite->points;
        u32 num_points = points->size();
        for (u32 i = 0; i < num_points; i++) {
            Vec2 prev = (*points)[i];
            Vec2 next = (*points)[(i + 1) % num_points];
            f32 new_path = fog_length_v2(prev - point) + fog_length_v2(next - point);
            f32 change = new_path;
            if (change < best_dist) {
                best_index = (i + 1) % num_points;
                best_dist = change;
            }
        }
        points->insert(points->begin() + best_index, point);
    }

    if (fog_input_pressed((u32) In::EDIT_SAVE, Player::ANY)) {
        FILE *file = fopen(path, "w");
        for (u32 i = 0; i < global_editor.sprites.size(); i++) {
            write_sprite_to_file(global_editor.sprites[i], file);
        }
        fclose(file);
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3a0, %rsp            # imm = 0x3A0
movl $0x4, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x3a52
movl 0x66394(%rip), %eax     # 0x69db8
movl %eax, %esi
leaq 0x6638b(%rip), %rdi     # 0x69db8
addq $0x8, %rdi
callq 0x57f0
movq %rax, %rdx
addq $0x20, %rdx
leaq 0x41756(%rip), %rdi     # 0x4519a
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %ecx
callq 0x2880
leaq 0x6635f(%rip), %rdi     # 0x69db8
addq $0x8, %rdi
callq 0x5590
movl %eax, -0xc(%rbp)
movl $0x6, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x3aaf
cmpl $0x0, -0xc(%rbp)
je 0x3aaf
movl 0x66334(%rip), %eax     # 0x69db8
subl $0x1, %eax
movl %eax, 0x6632b(%rip)     # 0x69db8
movl -0xc(%rbp), %eax
addl 0x66322(%rip), %eax     # 0x69db8
movl %eax, 0x6631c(%rip)     # 0x69db8
movl -0xc(%rbp), %ecx
movl 0x66313(%rip), %eax     # 0x69db8
xorl %edx, %edx
divl %ecx
movl %edx, 0x66309(%rip)     # 0x69db8
movl $0x5, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x3af9
cmpl $0x0, -0xc(%rbp)
je 0x3af9
movl 0x662ea(%rip), %eax     # 0x69db8
addl $0x1, %eax
movl %eax, 0x662e1(%rip)     # 0x69db8
movl -0xc(%rbp), %eax
addl 0x662d8(%rip), %eax     # 0x69db8
movl %eax, 0x662d2(%rip)     # 0x69db8
movl -0xc(%rbp), %ecx
movl 0x662c9(%rip), %eax     # 0x69db8
xorl %edx, %edx
divl %ecx
movl %edx, 0x662bf(%rip)     # 0x69db8
callq 0x37140
cvtss2sd %xmm0, %xmm1
movsd 0x4154e(%rip), %xmm0    # 0x45058
ucomisd %xmm1, %xmm0
jbe 0x3b23
callq 0x37140
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x2e0(%rbp)
jmp 0x3b35
movsd 0x4152d(%rip), %xmm0    # 0x45058
movsd %xmm0, -0x2e0(%rbp)
jmp 0x3b35
movsd -0x2e0(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x10(%rbp)
movl $0xd, %edi
movl $0xf, %esi
callq 0x38560
movss %xmm0, -0x14(%rbp)
movl $0xe, %edi
movl $0xf, %esi
callq 0x38560
movss %xmm0, -0x18(%rbp)
callq 0x38420
cmpb $0x0, %al
je 0x3ba3
movl $0xf, %esi
movl %esi, %edi
callq 0x38560
mulss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x414cc(%rip), %xmm0    # 0x45060
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
jmp 0x3bd8
callq 0x386c0
movlpd %xmm0, -0x24(%rbp)
movss 0x4145f(%rip), %xmm0    # 0x45014
mulss -0x20(%rbp), %xmm0
mulss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x41495(%rip), %xmm0    # 0x45060
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x2e4(%rbp)
xorl %edi, %edi
callq 0x389e0
movss -0x2e4(%rbp), %xmm0
mulss 0x10(%rax), %xmm0
movss %xmm0, 0x10(%rax)
xorl %edi, %edi
callq 0x389e0
movss 0x10(%rax), %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x10(%rbp), %xmm0
divss -0x28(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
callq 0x38420
cmpb $0x0, %al
je 0x3c34
movq 0x661aa(%rip), %rax     # 0x69dd8
movq %rax, -0x34(%rbp)
jmp 0x3c48
xorl %edi, %edi
callq 0x38620
movlpd %xmm0, -0x3c(%rbp)
movq -0x3c(%rbp), %rax
movq %rax, -0x34(%rbp)
movss 0x66190(%rip), %xmm0    # 0x69de0
divss -0x28(%rbp), %xmm0
movss %xmm0, 0x66187(%rip)    # 0x69de4
movl $0x9, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x3c88
movss 0x66174(%rip), %xmm0    # 0x69dec
mulss 0x66168(%rip), %xmm0    # 0x69de8
movss %xmm0, 0x66160(%rip)    # 0x69de8
movl $0xa, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x3cb7
movss 0x66149(%rip), %xmm1    # 0x69dec
movss 0x6613d(%rip), %xmm0    # 0x69de8
divss %xmm1, %xmm0
movss %xmm0, 0x66131(%rip)    # 0x69de8
movss 0x66129(%rip), %xmm0    # 0x69de8
cvtss2sd %xmm0, %xmm0
movsd 0x41395(%rip), %xmm1    # 0x45060
ucomisd %xmm1, %xmm0
jbe 0x3ce3
movsd 0x41387(%rip), %xmm0    # 0x45060
movsd %xmm0, -0x2f0(%rbp)
jmp 0x3cf7
movss 0x660fd(%rip), %xmm0    # 0x69de8
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x2f0(%rbp)
movsd -0x2f0(%rbp), %xmm1
movsd 0x41361(%rip), %xmm0    # 0x45068
ucomisd %xmm1, %xmm0
jbe 0x3d1f
movsd 0x41353(%rip), %xmm0    # 0x45068
movsd %xmm0, -0x2f8(%rbp)
jmp 0x3d6f
movss 0x660c1(%rip), %xmm0    # 0x69de8
cvtss2sd %xmm0, %xmm0
movsd 0x4132d(%rip), %xmm1    # 0x45060
ucomisd %xmm1, %xmm0
jbe 0x3d4b
movsd 0x4131f(%rip), %xmm0    # 0x45060
movsd %xmm0, -0x300(%rbp)
jmp 0x3d5f
movss 0x66095(%rip), %xmm0    # 0x69de8
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x300(%rbp)
movsd -0x300(%rbp), %xmm0
movsd %xmm0, -0x2f8(%rbp)
movsd -0x2f8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x66065(%rip)    # 0x69de8
movl $0x10, %edi
movl $0xf, %esi
callq 0x38540
cmpb $0x0, %al
je 0x3fa1
movss 0x66046(%rip), %xmm0    # 0x69de8
movss %xmm0, -0x40(%rbp)
movss -0x10(%rbp), %xmm0
addss 0x66044(%rip), %xmm0    # 0x69df8
movss %xmm0, 0x6603c(%rip)    # 0x69df8
movss 0x66034(%rip), %xmm0    # 0x69df8
cvtss2sd %xmm0, %xmm0
movsd 0x412a0(%rip), %xmm1    # 0x45070
ucomisd %xmm1, %xmm0
jbe 0x3f75
movss -0x14(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3df6
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x304(%rbp)
jmp 0x3e2c
movss -0x14(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x41264(%rip), %xmm1    # 0x45078
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movzbl %al, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x304(%rbp)
movss -0x304(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3e40
jp 0x3e40
jmp 0x3ea2
movss -0x14(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3e5f
movsd 0x4120b(%rip), %xmm0    # 0x45060
movsd %xmm0, -0x310(%rbp)
jmp 0x3e84
movss 0x411b1(%rip), %xmm0    # 0x45018
mulss -0x40(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x41208(%rip), %xmm1    # 0x45080
mulsd %xmm1, %xmm0
movsd %xmm0, -0x310(%rbp)
movsd -0x310(%rbp), %xmm1
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3ebe
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x314(%rbp)
jmp 0x3ef4
movss -0x18(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x4119c(%rip), %xmm1    # 0x45078
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movzbl %al, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x314(%rbp)
movss -0x314(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3f08
jp 0x3f08
jmp 0x3f6a
movss -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3f27
movsd 0x41143(%rip), %xmm0    # 0x45060
movsd %xmm0, -0x320(%rbp)
jmp 0x3f4c
movss 0x410e9(%rip), %xmm0    # 0x45018
mulss -0x40(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x41140(%rip), %xmm1    # 0x45080
mulsd %xmm1, %xmm0
movsd %xmm0, -0x320(%rbp)
movsd -0x320(%rbp), %xmm1
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, 0x65e83(%rip)    # 0x69df8
leaq -0x34(%rbp), %rdi
movss -0x40(%rbp), %xmm0
movss -0x40(%rbp), %xmm1
callq 0x2c50
leaq -0x34(%rbp), %rdi
addq $0x4, %rdi
movss -0x40(%rbp), %xmm0
movss -0x40(%rbp), %xmm1
callq 0x2c50
jmp 0x3fd6
movss -0x14(%rbp), %xmm0
movss -0x18(%rbp), %xmm1
callq 0x372e0
movlpd %xmm0, -0x50(%rbp)
movss -0x2c(%rbp), %xmm0
leaq -0x50(%rbp), %rdi
callq 0x5810
movlpd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
leaq -0x34(%rbp), %rdi
callq 0x5410
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x41099(%rip), %xmm1    # 0x45080
ucomisd %xmm1, %xmm0
jbe 0x3fff
movsd 0x4108b(%rip), %xmm0    # 0x45080
movsd %xmm0, -0x328(%rbp)
jmp 0x4010
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x328(%rbp)
movsd -0x328(%rbp), %xmm1
movsd 0x41068(%rip), %xmm0    # 0x45088
ucomisd %xmm1, %xmm0
jbe 0x4038
movsd 0x4105a(%rip), %xmm0    # 0x45088
movsd %xmm0, -0x330(%rbp)
jmp 0x4082
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x41037(%rip), %xmm1    # 0x45080
ucomisd %xmm1, %xmm0
jbe 0x4061
movsd 0x41029(%rip), %xmm0    # 0x45080
movsd %xmm0, -0x338(%rbp)
jmp 0x4072
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x338(%rbp)
movsd -0x338(%rbp), %xmm0
movsd %xmm0, -0x330(%rbp)
movsd -0x330(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x33c(%rbp)
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x40fd9(%rip), %xmm1    # 0x45080
ucomisd %xmm1, %xmm0
jbe 0x40bf
movsd 0x40fcb(%rip), %xmm0    # 0x45080
movsd %xmm0, -0x348(%rbp)
jmp 0x40d0
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x348(%rbp)
movsd -0x348(%rbp), %xmm1
movsd 0x40fa8(%rip), %xmm0    # 0x45088
ucomisd %xmm1, %xmm0
jbe 0x40f8
movsd 0x40f9a(%rip), %xmm0    # 0x45088
movsd %xmm0, -0x350(%rbp)
jmp 0x4142
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x40f77(%rip), %xmm1    # 0x45080
ucomisd %xmm1, %xmm0
jbe 0x4121
movsd 0x40f69(%rip), %xmm0    # 0x45080
movsd %xmm0, -0x358(%rbp)
jmp 0x4132
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x358(%rbp)
movsd -0x358(%rbp), %xmm0
movsd %xmm0, -0x350(%rbp)
movss -0x33c(%rbp), %xmm0
movsd -0x350(%rbp), %xmm1
cvtsd2ss %xmm1, %xmm1
callq 0x372e0
movlpd %xmm0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x34(%rbp)
movq -0x34(%rbp), %rax
movq %rax, 0x65c65(%rip)     # 0x69dd8
movq -0x34(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0xc, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x4193
callq 0x2ce0
xorl %edi, %edi
callq 0x389e0
movss 0x10(%rax), %xmm0
movss %xmm0, -0x5c(%rbp)
movss 0x65c3c(%rip), %xmm0    # 0x69de8
movss %xmm0, -0x60(%rbp)
movss -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x40ece(%rip), %xmm0    # 0x45090
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x64(%rbp)
xorps %xmm1, %xmm1
movss %xmm1, -0x35c(%rbp)
movss 0x40e26(%rip), %xmm2    # 0x45008
movss %xmm2, -0x360(%rbp)
movss 0x40e2a(%rip), %xmm3    # 0x4501c
movaps %xmm2, %xmm0
callq 0x37390
movss -0x360(%rbp), %xmm2
movaps %xmm0, %xmm3
movaps %xmm1, %xmm0
movss -0x35c(%rbp), %xmm1
movlpd %xmm3, -0x74(%rbp)
movlpd %xmm0, -0x6c(%rbp)
movss 0x40dea(%rip), %xmm3    # 0x4500c
movaps %xmm2, %xmm0
callq 0x37390
movlpd %xmm0, -0x84(%rbp)
movlpd %xmm1, -0x7c(%rbp)
movl $0x10, %edi
movl $0xf, %esi
callq 0x38540
cmpb $0x0, %al
je 0x425a
leaq -0x84(%rbp), %rax
movq %rax, -0x368(%rbp)
jmp 0x4267
leaq -0x74(%rbp), %rax
movq %rax, -0x368(%rbp)
jmp 0x4267
movq -0x368(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x94(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x8c(%rbp)
movl $0x0, -0x98(%rbp)
movl -0x98(%rbp), %eax
cvtsi2sd %rax, %xmm1
movss -0x60(%rbp), %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x40db7(%rip), %xmm0    # 0x45060
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x4467
movl -0x98(%rbp), %eax
cvtsi2ss %rax, %xmm0
movss -0x60(%rbp), %xmm1
mulss %xmm1, %xmm0
xorps %xmm1, %xmm1
movss %xmm1, -0x370(%rbp)
callq 0x372e0
movlpd %xmm0, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x98(%rbp), %eax
cvtsi2ss %rax, %xmm0
movss -0x60(%rbp), %xmm1
mulss %xmm1, %xmm0
movss 0x40cfb(%rip), %xmm1    # 0x45008
movss %xmm1, -0x36c(%rbp)
callq 0x372e0
movlpd %xmm0, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movups -0x94(%rbp), %xmm0
movaps %xmm0, -0xe0(%rbp)
movss -0x64(%rbp), %xmm4
movsd -0xc0(%rbp), %xmm0
movsd -0xc8(%rbp), %xmm1
movsd -0xe0(%rbp), %xmm2
movsd -0xd8(%rbp), %xmm3
movl $0x5, %edi
callq 0x38ed0
movss -0x370(%rbp), %xmm0
movl -0x98(%rbp), %eax
cvtsi2ss %rax, %xmm1
movss -0x60(%rbp), %xmm2
mulss %xmm2, %xmm1
callq 0x372e0
movaps %xmm0, %xmm1
movss -0x36c(%rbp), %xmm0
movlpd %xmm1, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x98(%rbp), %eax
cvtsi2ss %rax, %xmm1
movss -0x60(%rbp), %xmm2
mulss %xmm2, %xmm1
callq 0x372e0
movlpd %xmm0, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x100(%rbp)
movups -0x94(%rbp), %xmm0
movaps %xmm0, -0x110(%rbp)
movss -0x64(%rbp), %xmm4
movsd -0xf8(%rbp), %xmm0
movsd -0x100(%rbp), %xmm1
movsd -0x110(%rbp), %xmm2
movsd -0x108(%rbp), %xmm3
movl $0x5, %edi
callq 0x38ed0
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x428d
xorps %xmm2, %xmm2
movss 0x40b96(%rip), %xmm3    # 0x45008
movaps %xmm2, %xmm0
movaps %xmm3, %xmm1
callq 0x37390
movlpd %xmm0, -0x120(%rbp)
movlpd %xmm1, -0x118(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
movups -0x120(%rbp), %xmm0
movaps %xmm0, -0x140(%rbp)
movss -0x5c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x40be1(%rip), %xmm0    # 0x45098
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm3
movsd -0x128(%rbp), %xmm0
movsd -0x140(%rbp), %xmm1
movsd -0x138(%rbp), %xmm2
movl $0xa, %edi
callq 0x38f40
xorl %edi, %edi
callq 0x389e0
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x158(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x160(%rbp)
movsd -0x158(%rbp), %xmm0
movsd -0x160(%rbp), %xmm1
callq 0x37550
movss %xmm0, -0x14c(%rbp)
movq -0x148(%rbp), %rax
movss 0x10(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x40b10(%rip), %xmm0    # 0x45050
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x164(%rbp)
movss -0x14c(%rbp), %xmm0
ucomiss -0x164(%rbp), %xmm0
jbe 0x4613
movss -0x14c(%rbp), %xmm0
movss -0x164(%rbp), %xmm1
subss %xmm1, %xmm0
movss 0x40a9f(%rip), %xmm1    # 0x45020
mulss %xmm1, %xmm0
movq -0x148(%rbp), %rax
movss 0x10(%rax), %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0x374(%rbp)
callq 0x37140
movaps %xmm0, %xmm1
movss -0x374(%rbp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x168(%rbp)
movq -0x148(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x180(%rbp)
movsd -0x180(%rbp), %xmm0
leaq -0x8(%rbp), %rdi
callq 0x5850
movlpd %xmm0, -0x178(%rbp)
movss -0x168(%rbp), %xmm0
leaq -0x178(%rbp), %rdi
callq 0x5810
movlpd %xmm0, -0x170(%rbp)
movq -0x148(%rbp), %rdi
movsd -0x170(%rbp), %xmm0
callq 0x5410
movl 0x6579f(%rip), %eax     # 0x69db8
movl %eax, %esi
leaq 0x65796(%rip), %rdi     # 0x69db8
addq $0x8, %rdi
callq 0x57f0
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x190(%rbp)
movl $0x7, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x466f
movq -0x190(%rbp), %rdi
movl $0x1, %esi
callq 0x2ba0
movq %rax, -0x190(%rbp)
movl $0x8, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x469a
movq -0x190(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2ba0
movq %rax, -0x190(%rbp)
cmpq $-0x1, -0x190(%rbp)
je 0x46b6
movq -0x190(%rbp), %rcx
movq -0x188(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x2, %edi
movl $0xf, %esi
callq 0x38540
cmpb $0x0, %al
jne 0x46d8
xorl %edi, %edi
callq 0x38740
cmpb $0x0, %al
je 0x47e6
movl $0xffffffff, -0x194(%rbp) # imm = 0xFFFFFFFF
movss 0x656fa(%rip), %xmm0    # 0x69de4
movss %xmm0, -0x198(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rdi
callq 0x53d0
movl %eax, -0x1a4(%rbp)
movl $0x0, -0x1a8(%rbp)
movl -0x1a8(%rbp), %eax
cmpl -0x1a4(%rbp), %eax
jae 0x47c1
movq -0x1a0(%rbp), %rdi
movl -0x1a8(%rbp), %eax
movl %eax, %esi
callq 0x53f0
movq (%rax), %rax
movq %rax, -0x1c0(%rbp)
movsd -0x1c0(%rbp), %xmm0
leaq -0x8(%rbp), %rdi
callq 0x5850
movlpd %xmm0, -0x1b4(%rbp)
movsd -0x1b4(%rbp), %xmm0
callq 0x37520
movss %xmm0, -0x1ac(%rbp)
movss -0x1ac(%rbp), %xmm1
movss -0x198(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x47ab
movl -0x1a8(%rbp), %eax
movl %eax, -0x194(%rbp)
movss -0x1ac(%rbp), %xmm0
movss %xmm0, -0x198(%rbp)
jmp 0x47ad
movl -0x1a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a8(%rbp)
jmp 0x471c
cmpl $0x0, -0x194(%rbp)
jl 0x47e4
movq -0x1a0(%rbp), %rdi
movslq -0x194(%rbp), %rsi
callq 0x53f0
movq -0x8(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x47e6
movl $0x3, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
jne 0x480b
movl $0x3, %edi
callq 0x38700
cmpb $0x0, %al
je 0x4967
movl $0xffffffff, -0x1c4(%rbp) # imm = 0xFFFFFFFF
movss 0x655c7(%rip), %xmm0    # 0x69de4
movss %xmm0, -0x1c8(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rdi
callq 0x53d0
movl %eax, -0x1d4(%rbp)
movl $0x0, -0x1d8(%rbp)
movl -0x1d8(%rbp), %eax
cmpl -0x1d4(%rbp), %eax
jae 0x48f4
movq -0x1d0(%rbp), %rdi
movl -0x1d8(%rbp), %eax
movl %eax, %esi
callq 0x53f0
movq (%rax), %rax
movq %rax, -0x1f0(%rbp)
movsd -0x1f0(%rbp), %xmm0
leaq -0x8(%rbp), %rdi
callq 0x5850
movlpd %xmm0, -0x1e4(%rbp)
movsd -0x1e4(%rbp), %xmm0
callq 0x37520
movss %xmm0, -0x1dc(%rbp)
movss -0x1dc(%rbp), %xmm1
movss -0x1c8(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x48de
movl -0x1d8(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movss -0x1dc(%rbp), %xmm0
movss %xmm0, -0x1c8(%rbp)
jmp 0x48e0
movl -0x1d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d8(%rbp)
jmp 0x484f
cmpl $0x0, -0x1c4(%rbp)
jl 0x4965
movq -0x1d0(%rbp), %rax
movq %rax, -0x380(%rbp)
movq -0x1d0(%rbp), %rdi
callq 0x5900
movq %rax, -0x208(%rbp)
movslq -0x1c4(%rbp), %rsi
leaq -0x208(%rbp), %rdi
callq 0x5930
movq %rax, -0x200(%rbp)
leaq -0x1f8(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x5970
movq -0x380(%rbp), %rdi
movq -0x1f8(%rbp), %rsi
callq 0x5890
movq %rax, -0x210(%rbp)
jmp 0x4967
movl $0x1, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
jne 0x498c
movl $0x2, %edi
callq 0x38700
cmpb $0x0, %al
je 0x4b7f
movl $0x0, -0x214(%rbp)
movss 0x40686(%rip), %xmm0    # 0x45024
movss %xmm0, -0x218(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x220(%rbp), %rdi
callq 0x53d0
movl %eax, -0x224(%rbp)
movl $0x0, -0x228(%rbp)
movl -0x228(%rbp), %eax
cmpl -0x224(%rbp), %eax
jae 0x4b13
movq -0x220(%rbp), %rdi
movl -0x228(%rbp), %eax
movl %eax, %esi
callq 0x53f0
movq (%rax), %rax
movq %rax, -0x230(%rbp)
movq -0x220(%rbp), %rdi
movl -0x228(%rbp), %eax
incl %eax
movl -0x224(%rbp), %ecx
xorl %edx, %edx
divl %ecx
movl %edx, %esi
callq 0x53f0
movq (%rax), %rax
movq %rax, -0x238(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x250(%rbp)
movsd -0x250(%rbp), %xmm0
leaq -0x230(%rbp), %rdi
callq 0x5850
movlpd %xmm0, -0x244(%rbp)
movsd -0x244(%rbp), %xmm0
callq 0x37520
movss %xmm0, -0x384(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x260(%rbp)
movsd -0x260(%rbp), %xmm0
leaq -0x238(%rbp), %rdi
callq 0x5850
movlpd %xmm0, -0x258(%rbp)
movsd -0x258(%rbp), %xmm0
callq 0x37520
movaps %xmm0, %xmm1
movss -0x384(%rbp), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x23c(%rbp)
movss -0x23c(%rbp), %xmm0
movss %xmm0, -0x264(%rbp)
movss -0x264(%rbp), %xmm1
movss -0x218(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x4afd
movl -0x228(%rbp), %eax
addl $0x1, %eax
xorl %edx, %edx
divl -0x224(%rbp)
movl %edx, -0x214(%rbp)
movss -0x264(%rbp), %xmm0
movss %xmm0, -0x218(%rbp)
jmp 0x4aff
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0x49d0
movq -0x220(%rbp), %rax
movq %rax, -0x390(%rbp)
movq -0x220(%rbp), %rdi
callq 0x5900
movq %rax, -0x280(%rbp)
movslq -0x214(%rbp), %rsi
leaq -0x280(%rbp), %rdi
callq 0x5930
movq %rax, -0x278(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x5970
movq -0x390(%rbp), %rdi
movq -0x270(%rbp), %rsi
leaq -0x8(%rbp), %rdx
callq 0x59b0
movq %rax, -0x288(%rbp)
movl $0xb, %edi
movl $0xf, %esi
callq 0x38500
cmpb $0x0, %al
je 0x4c71
movq 0x65253(%rip), %rdi     # 0x69df0
leaq 0x4c71a(%rip), %rsi     # 0x512be
callq 0x2520
movq %rax, -0x290(%rbp)
movl $0x0, -0x294(%rbp)
movl -0x294(%rbp), %eax
movq %rax, -0x398(%rbp)
leaq 0x651ea(%rip), %rdi     # 0x69db8
addq $0x8, %rdi
callq 0x5590
movq %rax, %rcx
movq -0x398(%rbp), %rax
cmpq %rcx, %rax
jae 0x4c65
movl -0x294(%rbp), %eax
movl %eax, %esi
leaq 0x651cb(%rip), %rdi     # 0x69dc0
callq 0x57f0
movq %rax, %rsi
leaq -0x2c8(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x5bb0
movq -0x3a0(%rbp), %rdi
movq -0x290(%rbp), %rsi
callq 0x29f0
jmp 0x4c25
leaq -0x2c8(%rbp), %rdi
callq 0x5630
movl -0x294(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x294(%rbp)
jmp 0x4bba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2d0(%rbp)
movl %eax, -0x2d4(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x5630
jmp 0x4c7a
movq -0x290(%rbp), %rdi
callq 0x2270
addq $0x3a0, %rsp            # imm = 0x3A0
popq %rbp
retq
movq -0x2d0(%rbp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)