// File: alan0201tw[P]RayTracer/src/util.cpp
// Function: triangle_test()
std::shared_ptr<hitable> triangle_test()
{
    std::vector<std::shared_ptr<hitable>> list;
    list.reserve(3000);

    std::shared_ptr<texture> red_texture = std::make_shared<constant_texture>(vec3(0.65f, 0.05f, 0.05f));
    std::shared_ptr<texture> white_texture = std::make_shared<constant_texture>(vec3(0.73f, 0.73f, 0.73f));
    std::shared_ptr<texture> white1_texture = std::make_shared<constant_texture>(vec3(1.0f, 1.0f, 1.0f));
    std::shared_ptr<texture> green_texture = std::make_shared<constant_texture>(vec3(0.12f, 0.45f, 0.15f));
    std::shared_ptr<texture> light_texture = std::make_shared<constant_texture>(vec3(15.0f, 15.0f, 15.0f));

    auto red_material = std::make_shared<lambertian>(red_texture);
    auto white_material = std::make_shared<lambertian>(white_texture);
    //auto metal_material = std::make_shared<metal>(vec3(1,1,1), 0.0f);
    // auto bunny_material = std::make_shared<lambertian>(white1_texture);
    auto bunny_material = std::make_shared<metal>(vec3(1,1,1), 0.0f);
    auto green_material = std::make_shared<lambertian>(green_texture);
    auto light = std::make_shared<diffuse_light>(light_texture);

    list.push_back(std::make_shared<flip_normals>(std::make_shared<yz_rect>(0, 555, 0, 555, 555, green_material)));
    list.push_back(std::make_shared<yz_rect>(0, 555, 0, 555, 0, red_material));
    list.push_back(std::make_shared<xz_rect>(213, 343, 227, 332, 554, light));
    list.push_back(std::make_shared<flip_normals>(std::make_shared<xz_rect>(0, 555, 0, 555, 555, white_material)));
    list.push_back(std::make_shared<xz_rect>(0, 555, 0, 555, 0, white_material));
    list.push_back(std::make_shared<flip_normals>(std::make_shared<xy_rect>(0, 555, 0, 555, 555, white_material)));

    tinyobj::attrib_t attrib;
    std::vector<tinyobj::shape_t> shapes;
    std::vector<tinyobj::material_t> materials;
    std::string warn;
    std::string err;

    tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, "./resources/bunny_full.obj");
    if (!warn.empty())
    {
        std::cout << warn << std::endl;
    }
    if (!err.empty())
    {
        std::cerr << err << std::endl;
    }

    std::vector<std::shared_ptr<hitable>> bunny_list;
    // Loop over shapes
    for (size_t s = 0; s < shapes.size(); s++)
    {
        // Loop over faces(polygon)
        size_t index_offset = 0;
        for (size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++)
        {
            size_t fv = shapes[s].mesh.num_face_vertices[f];

            vec3 vertices[3];
            // Loop over vertices in the face.
            for (size_t v = 0; v < fv; v++)
            {
                // access to vertex
                tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v];
                tinyobj::real_t vx = attrib.vertices[3 * idx.vertex_index+0];
                tinyobj::real_t vy = attrib.vertices[3 * idx.vertex_index+1];
                tinyobj::real_t vz = attrib.vertices[3 * idx.vertex_index+2];
                // tinyobj::real_t nx = attrib.normals[3*idx.normal_index+0];
                // tinyobj::real_t ny = attrib.normals[3*idx.normal_index+1];
                // tinyobj::real_t nz = attrib.normals[3*idx.normal_index+2];
                // tinyobj::real_t tx = attrib.texcoords[2*idx.texcoord_index+0];
                // tinyobj::real_t ty = attrib.texcoords[2*idx.texcoord_index+1];
                vertices[v] = vec3(vx, vy, vz) * 150.0f;
            }
            
            bunny_list.push_back(std::make_shared<triangle>(
                vertices[0], vertices[1], vertices[2], bunny_material));

            index_offset += fv;

            // per-face material
            shapes[s].mesh.material_ids[f];
        }
    }

    //list.push_back(std::make_shared<bvh_node>(bunny_list, 0, 1));
    list.push_back( std::make_shared<translate>(
        std::make_shared<rotate_y>( 
            std::make_shared<bvh_node>(bunny_list, 0, 1),     
        180.0f ), vec3(235, 10, 278)
        ));

    // list.push_back(std::make_shared<xz_rect>(213, 343, 227, 332, 554, light));
    //list.push_back(std::make_shared<xy_rect>(253, 303, 10, 60, 50, light));
    //list.push_back(std::make_shared<sphere>(vec3(275, 150, 0), 50, light));
    //list.push_back(std::make_shared<sphere>(vec3(275, 50, 0), 30, light));

    // int ns = 100;
    // for(int j = 0; j < ns; j++)
    // {
    //     float tmp_x = 400.0f * drand48() - 100;
    //     float tmp_y = 400.0f * drand48() + 270;
    //     float tmp_z = 400.0f * drand48() + 395;
    //     vec3 random_pos = vec3(tmp_x, tmp_y, tmp_z);
    //     vec3 random_v0v1 = random_in_unit_sphere() * 35.0f;
    //     vec3 random_v0v2 = random_in_unit_sphere() * 35.0f;

    //     list.push_back(std::make_shared<triangle>(
    //         random_pos, random_pos + random_v0v1, random_pos + random_v0v2, white_material));
    // }

    return std::make_shared<bvh_node>(list, 0.0f, 1.0f);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x650, %rsp            # imm = 0x650
movq %rdi, -0x558(%rbp)
movq %rdi, %rax
movq %rax, -0x550(%rbp)
movq %rdi, -0x8(%rbp)
leaq -0x20(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x8b80
movq -0x548(%rbp), %rdi
movl $0xbb8, %esi            # imm = 0xBB8
callq 0x8ba0
jmp 0x29743
leaq -0x5c(%rbp), %rdi
movss 0x54db1(%rip), %xmm0    # 0x7e500
movss 0x54dad(%rip), %xmm2    # 0x7e504
movaps %xmm2, %xmm1
callq 0xf9b0
jmp 0x29761
leaq -0x50(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x2cc80
jmp 0x29770
leaq -0x40(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rsi, -0x560(%rbp)
callq 0x2cf80
movq -0x560(%rbp), %rdi
callq 0x2cd40
leaq -0x8c(%rbp), %rdi
movss 0x54d69(%rip), %xmm2    # 0x7e508
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xf9b0
jmp 0x297ac
leaq -0x80(%rbp), %rdi
leaq -0x8c(%rbp), %rsi
callq 0x2cc80
jmp 0x297be
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq %rsi, -0x568(%rbp)
callq 0x2cf80
movq -0x568(%rbp), %rdi
callq 0x2cd40
leaq -0xbc(%rbp), %rdi
movss 0x54a0f(%rip), %xmm2    # 0x7e1fc
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xf9b0
jmp 0x297fa
leaq -0xb0(%rbp), %rdi
leaq -0xbc(%rbp), %rsi
callq 0x2cc80
jmp 0x2980f
leaq -0xa0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movq %rsi, -0x570(%rbp)
callq 0x2cf80
movq -0x570(%rbp), %rdi
callq 0x2cd40
leaq -0xec(%rbp), %rdi
movss 0x54cc8(%rip), %xmm0    # 0x7e50c
movss 0x54cc4(%rip), %xmm1    # 0x7e510
movss 0x54cc0(%rip), %xmm2    # 0x7e514
callq 0xf9b0
jmp 0x2985b
leaq -0xe0(%rbp), %rdi
leaq -0xec(%rbp), %rsi
callq 0x2cc80
jmp 0x29870
leaq -0xd0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
movq %rsi, -0x578(%rbp)
callq 0x2cf80
movq -0x578(%rbp), %rdi
callq 0x2cd40
leaq -0x11c(%rbp), %rdi
movss 0x54c73(%rip), %xmm2    # 0x7e518
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xf9b0
jmp 0x298b2
leaq -0x110(%rbp), %rdi
leaq -0x11c(%rbp), %rsi
callq 0x2cc80
jmp 0x298c7
leaq -0x100(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movq %rsi, -0x580(%rbp)
callq 0x2cf80
movq -0x580(%rbp), %rdi
callq 0x2cd40
leaq -0x130(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x2cea0
jmp 0x298ff
leaq -0x140(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2cea0
jmp 0x29911
leaq -0x15c(%rbp), %rdi
movss 0x548dc(%rip), %xmm2    # 0x7e1fc
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xf9b0
jmp 0x2992d
movl $0x0, -0x160(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x15c(%rbp), %rsi
leaq -0x160(%rbp), %rdx
callq 0x2e000
jmp 0x29953
leaq -0x170(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x2cea0
jmp 0x29968
leaq -0x180(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x2d3d0
jmp 0x2997d
movl $0x0, -0x1b4(%rbp)
movl $0x22b, -0x1b8(%rbp)    # imm = 0x22B
movl $0x0, -0x1bc(%rbp)
movl $0x22b, -0x1c0(%rbp)    # imm = 0x22B
movl $0x22b, -0x1c4(%rbp)    # imm = 0x22B
movq %rsp, %rax
leaq -0x170(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x1b0(%rbp), %rdi
leaq -0x1b4(%rbp), %rsi
leaq -0x1b8(%rbp), %rdx
leaq -0x1bc(%rbp), %rcx
leaq -0x1c0(%rbp), %r8
leaq -0x1c4(%rbp), %r9
callq 0x2d7f0
jmp 0x299ed
leaq -0x1a0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x9150
jmp 0x29a02
leaq -0x190(%rbp), %rdi
movq %rdi, -0x588(%rbp)
leaq -0x1a0(%rbp), %rsi
callq 0x8eb0
movq -0x588(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x8ca0
jmp 0x29a2e
leaq -0x190(%rbp), %rdi
callq 0x8e00
leaq -0x1a0(%rbp), %rdi
callq 0x8ee0
leaq -0x1b0(%rbp), %rdi
callq 0x9130
movl $0x0, -0x1ec(%rbp)
movl $0x22b, -0x1f0(%rbp)    # imm = 0x22B
movl $0x0, -0x1f4(%rbp)
movl $0x22b, -0x1f8(%rbp)    # imm = 0x22B
movl $0x0, -0x1fc(%rbp)
movq %rsp, %rax
leaq -0x130(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x1e8(%rbp), %rdi
leaq -0x1ec(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
leaq -0x1f4(%rbp), %rcx
leaq -0x1f8(%rbp), %r8
leaq -0x1fc(%rbp), %r9
callq 0x2d7f0
jmp 0x29ac2
leaq -0x1d8(%rbp), %rdi
movq %rdi, -0x590(%rbp)
leaq -0x1e8(%rbp), %rsi
callq 0x9100
movq -0x590(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x8ca0
jmp 0x29aee
leaq -0x1d8(%rbp), %rdi
callq 0x8e00
leaq -0x1e8(%rbp), %rdi
callq 0x9130
movl $0xd5, -0x224(%rbp)
movl $0x157, -0x228(%rbp)    # imm = 0x157
movl $0xe3, -0x22c(%rbp)
movl $0x14c, -0x230(%rbp)    # imm = 0x14C
movl $0x22a, -0x234(%rbp)    # imm = 0x22A
movq %rsp, %rax
leaq -0x180(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x220(%rbp), %rdi
leaq -0x224(%rbp), %rsi
leaq -0x228(%rbp), %rdx
leaq -0x22c(%rbp), %rcx
leaq -0x230(%rbp), %r8
leaq -0x234(%rbp), %r9
callq 0x2d890
jmp 0x29b76
leaq -0x210(%rbp), %rdi
movq %rdi, -0x598(%rbp)
leaq -0x220(%rbp), %rsi
callq 0x8fa0
movq -0x598(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x8ca0
jmp 0x29ba2
leaq -0x210(%rbp), %rdi
callq 0x8e00
leaq -0x220(%rbp), %rdi
callq 0x8fd0
movl $0x0, -0x26c(%rbp)
movl $0x22b, -0x270(%rbp)    # imm = 0x22B
movl $0x0, -0x274(%rbp)
movl $0x22b, -0x278(%rbp)    # imm = 0x22B
movl $0x22b, -0x27c(%rbp)    # imm = 0x22B
movq %rsp, %rax
leaq -0x140(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x268(%rbp), %rdi
leaq -0x26c(%rbp), %rsi
leaq -0x270(%rbp), %rdx
leaq -0x274(%rbp), %rcx
leaq -0x278(%rbp), %r8
leaq -0x27c(%rbp), %r9
callq 0x2d930
jmp 0x29c2a
leaq -0x258(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x8ff0
jmp 0x29c3f
leaq -0x248(%rbp), %rdi
movq %rdi, -0x5a0(%rbp)
leaq -0x258(%rbp), %rsi
callq 0x8eb0
movq -0x5a0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x8ca0
jmp 0x29c6b
leaq -0x248(%rbp), %rdi
callq 0x8e00
leaq -0x258(%rbp), %rdi
callq 0x8ee0
leaq -0x268(%rbp), %rdi
callq 0x8fd0
movl $0x0, -0x2a4(%rbp)
movl $0x22b, -0x2a8(%rbp)    # imm = 0x22B
movl $0x0, -0x2ac(%rbp)
movl $0x22b, -0x2b0(%rbp)    # imm = 0x22B
movl $0x0, -0x2b4(%rbp)
movq %rsp, %rax
leaq -0x140(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x2a0(%rbp), %rdi
leaq -0x2a4(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
leaq -0x2ac(%rbp), %rcx
leaq -0x2b0(%rbp), %r8
leaq -0x2b4(%rbp), %r9
callq 0x2d930
jmp 0x29cff
leaq -0x290(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
leaq -0x2a0(%rbp), %rsi
callq 0x8fa0
movq -0x5a8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x8ca0
jmp 0x29d2b
leaq -0x290(%rbp), %rdi
callq 0x8e00
leaq -0x2a0(%rbp), %rdi
callq 0x8fd0
movl $0x0, -0x2ec(%rbp)
movl $0x22b, -0x2f0(%rbp)    # imm = 0x22B
movl $0x0, -0x2f4(%rbp)
movl $0x22b, -0x2f8(%rbp)    # imm = 0x22B
movl $0x22b, -0x2fc(%rbp)    # imm = 0x22B
movq %rsp, %rax
leaq -0x140(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x2e8(%rbp), %rdi
leaq -0x2ec(%rbp), %rsi
leaq -0x2f0(%rbp), %rdx
leaq -0x2f4(%rbp), %rcx
leaq -0x2f8(%rbp), %r8
leaq -0x2fc(%rbp), %r9
callq 0x2d9d0
jmp 0x29db3
leaq -0x2d8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x8e40
jmp 0x29dc8
leaq -0x2c8(%rbp), %rdi
movq %rdi, -0x5b0(%rbp)
leaq -0x2d8(%rbp), %rsi
callq 0x8eb0
movq -0x5b0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x8ca0
jmp 0x29df4
leaq -0x2c8(%rbp), %rdi
callq 0x8e00
leaq -0x2d8(%rbp), %rdi
callq 0x8ee0
leaq -0x2e8(%rbp), %rdi
callq 0x8e20
leaq -0x390(%rbp), %rdi
callq 0x2e350
jmp 0x29e26
leaq -0x3a8(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x2e3b0
leaq -0x3c0(%rbp), %rdi
movq %rdi, -0x5c8(%rbp)
callq 0x2c620
leaq -0x3e0(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0x7690
leaq -0x400(%rbp), %rdi
movq %rdi, -0x5b8(%rbp)
callq 0x7690
movq -0x5d0(%rbp), %rsi
movq -0x5c8(%rbp), %rdx
movq -0x5c0(%rbp), %rcx
movq -0x5b8(%rbp), %r8
movq %rsp, %rax
movl $0x1, 0x10(%rax)
movl $0x1, 0x8(%rax)
movq $0x0, (%rax)
leaq 0x54c71(%rip), %r9      # 0x7eb1e
leaq -0x390(%rbp), %rdi
callq 0x1e4f0
jmp 0x29ebb
leaq -0x3e0(%rbp), %rdi
callq 0x77e0
testb $0x1, %al
jne 0x2a115
movq 0x860da(%rip), %rdi     # 0xaffb0
leaq -0x3e0(%rbp), %rsi
callq 0x7450
movq %rax, -0x5d8(%rbp)
jmp 0x29eeb
movq -0x5d8(%rbp), %rdi
movq 0x86077(%rip), %rsi     # 0xaff70
callq 0x7540
jmp 0x29f00
jmp 0x2a115
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a863
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a85a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a851
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a845
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a839
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a82d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a821
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a815
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a809
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a7fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a7f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x29ff2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x8e00
leaq -0x1a0(%rbp), %rdi
callq 0x8ee0
leaq -0x1b0(%rbp), %rdi
callq 0x9130
jmp 0x2a7f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x8e00
leaq -0x1e8(%rbp), %rdi
callq 0x9130
jmp 0x2a7f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x8e00
leaq -0x220(%rbp), %rdi
callq 0x8fd0
jmp 0x2a7f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a087
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x8e00
leaq -0x258(%rbp), %rdi
callq 0x8ee0
leaq -0x268(%rbp), %rdi
callq 0x8fd0
jmp 0x2a7f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x8e00
leaq -0x2a0(%rbp), %rdi
callq 0x8fd0
jmp 0x2a7f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a0f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x8e00
leaq -0x2d8(%rbp), %rdi
callq 0x8ee0
leaq -0x2e8(%rbp), %rdi
callq 0x8e20
jmp 0x2a7f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a7b5
leaq -0x400(%rbp), %rdi
callq 0x77e0
testb $0x1, %al
jne 0x2a158
movq 0x85eb4(%rip), %rdi     # 0xaffe0
leaq -0x400(%rbp), %rsi
callq 0x7450
movq %rax, -0x5e0(%rbp)
jmp 0x2a141
movq -0x5e0(%rbp), %rdi
movq 0x85e21(%rip), %rsi     # 0xaff70
callq 0x7540
jmp 0x2a156
jmp 0x2a158
leaq -0x418(%rbp), %rdi
callq 0x8b80
movq $0x0, -0x420(%rbp)
movq -0x420(%rbp), %rax
movq %rax, -0x5e8(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x2e3d0
movq %rax, %rcx
movq -0x5e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2a530
movq $0x0, -0x428(%rbp)
movq $0x0, -0x430(%rbp)
movq -0x430(%rbp), %rax
movq %rax, -0x5f0(%rbp)
movq -0x420(%rbp), %rsi
leaq -0x3a8(%rbp), %rdi
callq 0x2e400
movq %rax, %rdi
addq $0x20, %rdi
addq $0x18, %rdi
callq 0x2e420
movq %rax, %rcx
movq -0x5f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x2a517
movq -0x420(%rbp), %rsi
leaq -0x3a8(%rbp), %rdi
callq 0x2e400
movq %rax, %rdi
addq $0x20, %rdi
addq $0x18, %rdi
movq -0x430(%rbp), %rsi
callq 0x2e440
movzbl (%rax), %eax
movq %rax, -0x438(%rbp)
leaq -0x460(%rbp), %rax
movq %rax, %rcx
addq $0x24, %rcx
movq %rcx, -0x600(%rbp)
movq %rax, -0x5f8(%rbp)
movq -0x5f8(%rbp), %rdi
movq %rdi, -0x608(%rbp)
callq 0x10660
jmp 0x2a25b
movq -0x600(%rbp), %rcx
movq -0x608(%rbp), %rax
addq $0xc, %rax
cmpq %rcx, %rax
movq %rax, -0x5f8(%rbp)
jne 0x2a246
movq $0x0, -0x468(%rbp)
movq -0x468(%rbp), %rax
cmpq -0x438(%rbp), %rax
jae 0x2a427
movq -0x420(%rbp), %rsi
leaq -0x3a8(%rbp), %rdi
callq 0x2e400
movq %rax, %rdi
addq $0x20, %rdi
movq -0x428(%rbp), %rsi
movq -0x468(%rbp), %rax
addq %rax, %rsi
callq 0x2e460
movl 0x8(%rax), %ecx
movl %ecx, -0x470(%rbp)
movq (%rax), %rax
movq %rax, -0x478(%rbp)
movl -0x478(%rbp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movslq %eax, %rsi
leaq -0x390(%rbp), %rdi
movq %rdi, -0x610(%rbp)
callq 0x2c310
movq -0x610(%rbp), %rdi
movss (%rax), %xmm0
movss %xmm0, -0x47c(%rbp)
movl -0x478(%rbp), %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax,2), %eax
movslq %eax, %rsi
callq 0x2c310
movq -0x610(%rbp), %rdi
movss (%rax), %xmm0
movss %xmm0, -0x480(%rbp)
movl -0x478(%rbp), %ecx
movl %ecx, %eax
leal 0x2(%rax,%rax,2), %eax
movslq %eax, %rsi
callq 0x2c310
movss (%rax), %xmm0
movss %xmm0, -0x484(%rbp)
movss -0x47c(%rbp), %xmm0
movss -0x480(%rbp), %xmm1
movss -0x484(%rbp), %xmm2
leaq -0x49c(%rbp), %rdi
callq 0xf9b0
jmp 0x2a37c
leaq -0x49c(%rbp), %rdi
movss 0x541c5(%rip), %xmm0    # 0x7e550
callq 0x10120
movss %xmm1, -0x624(%rbp)
movaps %xmm0, -0x620(%rbp)
jmp 0x2a3a1
movss -0x624(%rbp), %xmm0
movaps -0x620(%rbp), %xmm1
movlpd %xmm1, -0x4b0(%rbp)
movss %xmm0, -0x4a8(%rbp)
movq -0x4b0(%rbp), %rax
movq %rax, -0x490(%rbp)
movl -0x4a8(%rbp), %eax
movl %eax, -0x488(%rbp)
leaq -0x460(%rbp), %rax
imulq $0xc, -0x468(%rbp), %rcx
addq %rcx, %rax
movq -0x490(%rbp), %rcx
movq %rcx, (%rax)
movl -0x488(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x468(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x468(%rbp)
jmp 0x2a284
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a7a9
leaq -0x454(%rbp), %rdx
leaq -0x448(%rbp), %rcx
leaq -0x4d0(%rbp), %rdi
leaq -0x460(%rbp), %rsi
leaq -0x150(%rbp), %r8
callq 0x2e480
jmp 0x2a451
leaq -0x4c0(%rbp), %rdi
movq %rdi, -0x630(%rbp)
leaq -0x4d0(%rbp), %rsi
callq 0x2e510
movq -0x630(%rbp), %rsi
leaq -0x418(%rbp), %rdi
callq 0x8ca0
jmp 0x2a480
leaq -0x4c0(%rbp), %rdi
callq 0x8e00
leaq -0x4d0(%rbp), %rdi
callq 0x2e540
movq -0x438(%rbp), %rax
addq -0x428(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x420(%rbp), %rsi
leaq -0x3a8(%rbp), %rdi
callq 0x2e400
movq %rax, %rdi
addq $0x20, %rdi
addq $0x30, %rdi
movq -0x430(%rbp), %rsi
callq 0x19360
movq -0x430(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x430(%rbp)
jmp 0x2a1b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x4c0(%rbp), %rdi
callq 0x8e00
leaq -0x4d0(%rbp), %rdi
callq 0x2e540
jmp 0x2a7a9
jmp 0x2a519
movq -0x420(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x420(%rbp)
jmp 0x2a16f
movl $0x0, -0x514(%rbp)
movl $0x1, -0x518(%rbp)
leaq -0x510(%rbp), %rdi
leaq -0x418(%rbp), %rsi
leaq -0x514(%rbp), %rdx
leaq -0x518(%rbp), %rcx
callq 0x2e560
jmp 0x2a567
movl $0x43340000, -0x51c(%rbp) # imm = 0x43340000
leaq -0x500(%rbp), %rdi
leaq -0x510(%rbp), %rsi
leaq -0x51c(%rbp), %rdx
callq 0x2e2d0
jmp 0x2a58d
leaq -0x528(%rbp), %rdi
movss 0x53fe4(%rip), %xmm0    # 0x7e580
movss 0x53c7c(%rip), %xmm1    # 0x7e220
movss 0x53fd8(%rip), %xmm2    # 0x7e584
callq 0xf9b0
jmp 0x2a5b3
leaq -0x4f0(%rbp), %rdi
leaq -0x500(%rbp), %rsi
leaq -0x528(%rbp), %rdx
callq 0x2da70
jmp 0x2a5cf
leaq -0x4e0(%rbp), %rdi
movq %rdi, -0x638(%rbp)
leaq -0x4f0(%rbp), %rsi
callq 0x2dbf0
movq -0x638(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x8ca0
jmp 0x2a5fb
leaq -0x4e0(%rbp), %rdi
callq 0x8e00
leaq -0x4f0(%rbp), %rdi
callq 0x2dc20
leaq -0x500(%rbp), %rdi
callq 0x2dc40
leaq -0x510(%rbp), %rdi
callq 0x13be0
movl $0x0, -0x53c(%rbp)
movl $0x3f800000, -0x540(%rbp) # imm = 0x3F800000
leaq -0x538(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x53c(%rbp), %rdx
leaq -0x540(%rbp), %rcx
callq 0x2d4e0
jmp 0x2a65f
movq -0x558(%rbp), %rdi
leaq -0x538(%rbp), %rsi
callq 0x2d560
leaq -0x538(%rbp), %rdi
callq 0x13be0
leaq -0x418(%rbp), %rdi
callq 0x92d0
leaq -0x400(%rbp), %rdi
callq 0x72e0
leaq -0x3e0(%rbp), %rdi
callq 0x72e0
leaq -0x3c0(%rbp), %rdi
callq 0x2ca00
leaq -0x3a8(%rbp), %rdi
callq 0x2e5e0
leaq -0x390(%rbp), %rdi
callq 0x2e640
leaq -0x180(%rbp), %rdi
callq 0x2d440
leaq -0x170(%rbp), %rdi
callq 0x2cf60
leaq -0x150(%rbp), %rdi
callq 0x2d1a0
leaq -0x140(%rbp), %rdi
callq 0x2cf60
leaq -0x130(%rbp), %rdi
callq 0x2cf60
leaq -0x100(%rbp), %rdi
callq 0x12a50
leaq -0xd0(%rbp), %rdi
callq 0x12a50
leaq -0xa0(%rbp), %rdi
callq 0x12a50
leaq -0x70(%rbp), %rdi
callq 0x12a50
leaq -0x40(%rbp), %rdi
callq 0x12a50
leaq -0x20(%rbp), %rdi
callq 0x92d0
movq -0x550(%rbp), %rax
addq $0x650, %rsp            # imm = 0x650
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a79d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x2a791
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x4e0(%rbp), %rdi
callq 0x8e00
leaq -0x4f0(%rbp), %rdi
callq 0x2dc20
leaq -0x500(%rbp), %rdi
callq 0x2dc40
leaq -0x510(%rbp), %rdi
callq 0x13be0
leaq -0x418(%rbp), %rdi
callq 0x92d0
leaq -0x400(%rbp), %rdi
callq 0x72e0
leaq -0x3e0(%rbp), %rdi
callq 0x72e0
leaq -0x3c0(%rbp), %rdi
callq 0x2ca00
leaq -0x3a8(%rbp), %rdi
callq 0x2e5e0
leaq -0x390(%rbp), %rdi
callq 0x2e640
leaq -0x180(%rbp), %rdi
callq 0x2d440
leaq -0x170(%rbp), %rdi
callq 0x2cf60
leaq -0x150(%rbp), %rdi
callq 0x2d1a0
leaq -0x140(%rbp), %rdi
callq 0x2cf60
leaq -0x130(%rbp), %rdi
callq 0x2cf60
leaq -0x100(%rbp), %rdi
callq 0x12a50
leaq -0xd0(%rbp), %rdi
callq 0x12a50
leaq -0xa0(%rbp), %rdi
callq 0x12a50
leaq -0x70(%rbp), %rdi
callq 0x12a50
leaq -0x40(%rbp), %rdi
callq 0x12a50
leaq -0x20(%rbp), %rdi
callq 0x92d0
movq -0x28(%rbp), %rdi
callq 0x7860
nopw %cs:(%rax,%rax)