// File: IsaacLaw12[P]RayTracer/./src/SceneObject.cpp
// Function: SceneObject::load_material(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void SceneObject::load_material(std::string material_file){
    std::ifstream in(material_file);
    if (!in){
        std::cerr << "Could not open material file " << material_file << std::endl;
        return;
    }
    std::string obj_line;
    std::string line_type = "";

    double k1, k2, k3;
    while (std::getline(in, obj_line)){
        std::stringstream obj_read(obj_line);
        obj_read >> line_type;

        if (line_type[0] == 'K' && line_type[1] == 'a'){
            obj_read >> k1 >> k2 >> k3;
            ambient_color(0, 0) = k1;
            ambient_color(1, 1) = k2;
            ambient_color(2, 2) = k3;
        }

        if (line_type[0] == 'K' && line_type[1] == 'd'){
            obj_read >> k1 >> k2 >> k3;
            diffuse_color(0, 0) = k1;
            diffuse_color(1, 1) = k2;
            diffuse_color(2, 2) = k3;
        }

        if (line_type[0] == 'K' && line_type[1] == 's'){
            obj_read >> k1 >> k2 >> k3;
            specular_color(0, 0) = k1;
            specular_color(1, 1) = k2;
            specular_color(2, 2) = k3;
        }

        if (line_type[0] == 'K' && line_type[1] == 'o'){
            obj_read >> k1 >> k2 >> k3;
            refract_color(0, 0) = k1;
            refract_color(1, 1) = k2;
            refract_color(2, 2) = k3;
        }

        if (line_type[0] == 'e'){
            if (line_type[1] == 't'){
                if (line_type[2] == 'a'){
                    obj_read >> k1;
                    eta = k1;
                }
            }
        }

        if (line_type[0] == 'N' && line_type[1] == 's'){
            obj_read >> phong;
        }

    }

}

// Assembly:
subq $0x5b8, %rsp            # imm = 0x5B8
movq %rsi, 0x190(%rsp)
movq %rdi, 0x5b0(%rsp)
movq %rsi, 0x5a8(%rsp)
movq 0x5b0(%rsp), %rax
movq %rax, 0x198(%rsp)
leaq 0x3a0(%rsp), %rdi
movl $0x8, %edx
callq 0x4530
movq 0x3a0(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x3a0(%rsp,%rax), %rdi
callq 0x4150
movb %al, 0x1a7(%rsp)
jmp 0x43293
movb 0x1a7(%rsp), %al
testb $0x1, %al
jne 0x432a0
jmp 0x4331b
movq 0x57d49(%rip), %rdi     # 0x9aff0
leaq 0x28d4a(%rip), %rsi     # 0x6bff8
callq 0x4360
movq %rax, 0x188(%rsp)
jmp 0x432bd
movq 0x190(%rsp), %rsi
movq 0x188(%rsp), %rdi
callq 0x4340
movq %rax, 0x180(%rsp)
jmp 0x432dc
movq 0x180(%rsp), %rdi
movq 0x57ca5(%rip), %rsi     # 0x9af90
callq 0x43a0
jmp 0x432f2
movl $0x1, 0x390(%rsp)
jmp 0x43bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x43bed
leaq 0x370(%rsp), %rdi
callq 0x4490
leaq 0x34f(%rsp), %rdi
movq %rdi, 0x178(%rsp)
callq 0x45f0
movq 0x178(%rsp), %rdx
leaq 0x1eab2(%rip), %rsi     # 0x61dfe
leaq 0x350(%rsp), %rdi
callq 0x11e60
jmp 0x4335b
leaq 0x34f(%rsp), %rdi
callq 0x43c0
leaq 0x3a0(%rsp), %rdi
leaq 0x370(%rsp), %rsi
callq 0x4090
movq %rax, 0x170(%rsp)
jmp 0x43387
movq 0x170(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4440
movb %al, 0x16f(%rsp)
jmp 0x433a7
movb 0x16f(%rsp), %al
testb $0x1, %al
jne 0x433b7
jmp 0x43b99
movl $0x10, %edi
movl $0x8, %esi
callq 0x11e40
movl %eax, 0x168(%rsp)
jmp 0x433cf
movl 0x168(%rsp), %edx
leaq 0x1a8(%rsp), %rdi
leaq 0x370(%rsp), %rsi
callq 0x4520
jmp 0x433ed
leaq 0x1a8(%rsp), %rdi
leaq 0x350(%rsp), %rsi
callq 0x4450
jmp 0x43404
xorl %eax, %eax
movl %eax, %esi
leaq 0x350(%rsp), %rdi
callq 0x4680
movq %rax, 0x160(%rsp)
jmp 0x4341f
movq 0x160(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x4b, %eax
jne 0x435fc
leaq 0x350(%rsp), %rdi
movl $0x1, %esi
callq 0x4680
movq %rax, 0x158(%rsp)
jmp 0x4344f
movq 0x158(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jne 0x435fc
leaq 0x1a8(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0x42e0
movq %rax, 0x150(%rsp)
jmp 0x43482
movq 0x150(%rsp), %rdi
leaq 0x338(%rsp), %rsi
callq 0x42e0
movq %rax, 0x148(%rsp)
jmp 0x434a1
movq 0x148(%rsp), %rdi
leaq 0x330(%rsp), %rsi
callq 0x42e0
jmp 0x434b8
movq 0x198(%rsp), %rdi
movsd 0x340(%rsp), %xmm0
movsd %xmm0, 0x138(%rsp)
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x140(%rsp)
jmp 0x434ec
movq 0x198(%rsp), %rdi
movq 0x140(%rsp), %rax
movsd 0x138(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x338(%rsp), %xmm0
movsd %xmm0, 0x128(%rsp)
addq $0x20, %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x130(%rsp)
jmp 0x43536
movq 0x198(%rsp), %rdi
movq 0x130(%rsp), %rax
movsd 0x128(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x330(%rsp), %xmm0
movsd %xmm0, 0x118(%rsp)
addq $0x20, %rdi
movl $0x2, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x120(%rsp)
jmp 0x43580
movq 0x120(%rsp), %rax
movsd 0x118(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0x435fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x34f(%rsp), %rdi
callq 0x43c0
jmp 0x43be0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x43bd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x4290
jmp 0x43bd3
xorl %eax, %eax
movl %eax, %esi
leaq 0x350(%rsp), %rdi
callq 0x4680
movq %rax, 0x110(%rsp)
jmp 0x43617
movq 0x110(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x4b, %eax
jne 0x4378d
leaq 0x350(%rsp), %rdi
movl $0x1, %esi
callq 0x4680
movq %rax, 0x108(%rsp)
jmp 0x43647
movq 0x108(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x64, %eax
jne 0x4378d
leaq 0x1a8(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0x42e0
movq %rax, 0x100(%rsp)
jmp 0x4367a
movq 0x100(%rsp), %rdi
leaq 0x338(%rsp), %rsi
callq 0x42e0
movq %rax, 0xf8(%rsp)
jmp 0x43699
movq 0xf8(%rsp), %rdi
leaq 0x330(%rsp), %rsi
callq 0x42e0
jmp 0x436b0
movq 0x198(%rsp), %rdi
movsd 0x340(%rsp), %xmm0
movsd %xmm0, 0xe8(%rsp)
addq $0x68, %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0xf0(%rsp)
jmp 0x436e4
movq 0x198(%rsp), %rdi
movq 0xf0(%rsp), %rax
movsd 0xe8(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x338(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
addq $0x68, %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0xe0(%rsp)
jmp 0x4372e
movq 0x198(%rsp), %rdi
movq 0xe0(%rsp), %rax
movsd 0xd8(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x330(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
addq $0x68, %rdi
movl $0x2, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0xd0(%rsp)
jmp 0x43778
movq 0xd0(%rsp), %rax
movsd 0xc8(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
movl %eax, %esi
leaq 0x350(%rsp), %rdi
callq 0x4680
movq %rax, 0xc0(%rsp)
jmp 0x437a8
movq 0xc0(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x4b, %eax
jne 0x43921
leaq 0x350(%rsp), %rdi
movl $0x1, %esi
callq 0x4680
movq %rax, 0xb8(%rsp)
jmp 0x437d8
movq 0xb8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x73, %eax
jne 0x43921
leaq 0x1a8(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0x42e0
movq %rax, 0xb0(%rsp)
jmp 0x4380b
movq 0xb0(%rsp), %rdi
leaq 0x338(%rsp), %rsi
callq 0x42e0
movq %rax, 0xa8(%rsp)
jmp 0x4382a
movq 0xa8(%rsp), %rdi
leaq 0x330(%rsp), %rsi
callq 0x42e0
jmp 0x43841
movq 0x198(%rsp), %rdi
movsd 0x340(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
addq $0xb0, %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0xa0(%rsp)
jmp 0x43878
movq 0x198(%rsp), %rdi
movq 0xa0(%rsp), %rax
movsd 0x98(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x338(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
addq $0xb0, %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x90(%rsp)
jmp 0x438c5
movq 0x198(%rsp), %rdi
movq 0x90(%rsp), %rax
movsd 0x88(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x330(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
addq $0xb0, %rdi
movl $0x2, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x80(%rsp)
jmp 0x4390f
movq 0x80(%rsp), %rax
movsd 0x78(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
movl %eax, %esi
leaq 0x350(%rsp), %rdi
callq 0x4680
movq %rax, 0x70(%rsp)
jmp 0x43939
movq 0x70(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x4b, %eax
jne 0x43a7f
leaq 0x350(%rsp), %rdi
movl $0x1, %esi
callq 0x4680
movq %rax, 0x68(%rsp)
jmp 0x43963
movq 0x68(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x6f, %eax
jne 0x43a7f
leaq 0x1a8(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0x42e0
movq %rax, 0x60(%rsp)
jmp 0x43990
movq 0x60(%rsp), %rdi
leaq 0x338(%rsp), %rsi
callq 0x42e0
movq %rax, 0x58(%rsp)
jmp 0x439a9
movq 0x58(%rsp), %rdi
leaq 0x330(%rsp), %rsi
callq 0x42e0
jmp 0x439bd
movq 0x198(%rsp), %rdi
movsd 0x340(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
addq $0x140, %rdi            # imm = 0x140
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x50(%rsp)
jmp 0x439ee
movq 0x198(%rsp), %rdi
movq 0x50(%rsp), %rax
movsd 0x48(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x338(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
addq $0x140, %rdi            # imm = 0x140
movl $0x1, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x40(%rsp)
jmp 0x43a2f
movq 0x198(%rsp), %rdi
movq 0x40(%rsp), %rax
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x330(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
addq $0x140, %rdi            # imm = 0x140
movl $0x2, %edx
movq %rdx, %rsi
callq 0x1eaf0
movq %rax, 0x30(%rsp)
jmp 0x43a70
movq 0x30(%rsp), %rax
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
movl %eax, %esi
leaq 0x350(%rsp), %rdi
callq 0x4680
movq %rax, 0x20(%rsp)
jmp 0x43a97
movq 0x20(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x65, %eax
jne 0x43b21
leaq 0x350(%rsp), %rdi
movl $0x1, %esi
callq 0x4680
movq %rax, 0x18(%rsp)
jmp 0x43abd
movq 0x18(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x74, %eax
jne 0x43b1f
leaq 0x350(%rsp), %rdi
movl $0x2, %esi
callq 0x4680
movq %rax, 0x10(%rsp)
jmp 0x43ae3
movq 0x10(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jne 0x43b1d
leaq 0x1a8(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0x42e0
jmp 0x43b07
movq 0x198(%rsp), %rax
movsd 0x340(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
jmp 0x43b1f
jmp 0x43b21
xorl %eax, %eax
movl %eax, %esi
leaq 0x350(%rsp), %rdi
callq 0x4680
movq %rax, 0x8(%rsp)
jmp 0x43b39
movq 0x8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x4e, %eax
jne 0x43b87
leaq 0x350(%rsp), %rdi
movl $0x1, %esi
callq 0x4680
movq %rax, (%rsp)
jmp 0x43b5e
movq (%rsp), %rax
movsbl (%rax), %eax
cmpl $0x73, %eax
jne 0x43b87
movq 0x198(%rsp), %rsi
addq $0x8, %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x42e0
jmp 0x43b85
jmp 0x43b87
leaq 0x1a8(%rsp), %rdi
callq 0x4290
jmp 0x43368
leaq 0x350(%rsp), %rdi
callq 0x4200
leaq 0x370(%rsp), %rdi
callq 0x4200
movl $0x0, 0x390(%rsp)
leaq 0x3a0(%rsp), %rdi
callq 0x40c0
addq $0x5b8, %rsp            # imm = 0x5B8
retq
leaq 0x350(%rsp), %rdi
callq 0x4200
leaq 0x370(%rsp), %rdi
callq 0x4200
leaq 0x3a0(%rsp), %rdi
callq 0x40c0
movq 0x398(%rsp), %rdi
callq 0x45e0
nopw (%rax,%rax)