// File: Lut99[P]RayTracer/src/lib/objects/Sphere.cpp
// Function: RayTracer::Sphere::from_json(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>)
Sphere* Sphere::from_json(json json_obj) {
    // Check if the object has an object type
    if (!json_obj.is_object()) {
        throw InvalidObjectFormat("Sphere", json::object().type_name(), json_obj.type_name());
    }

    // Check for the required fields
    if (json_obj["center"].is_null()) {
        throw MissingFieldException("Sphere", "center");
    }
    if (json_obj["radius"].is_null()) {
        throw MissingFieldException("Sphere", "radius");
    }
    if (json_obj["material"].is_null()) {
        throw MissingFieldException("Sphere", "material");
    }

    // Parse them
    Vec3 center = Vec3::from_json(json_obj["center"]);
    double radius;
    try {
        radius = json_obj["radius"].get<double>();
    } catch (nlohmann::detail::type_error&) {
        throw InvalidFieldFormat("Sphere", "radius", "double", json_obj["radius"].type_name());
    }
    Material* mat = Material::from_json(json_obj["material"]);

    return new Sphere(center, radius, mat);
}

// Assembly:
subq $0x388, %rsp            # imm = 0x388
movq %rdi, 0xe8(%rsp)
movq %rdi, 0x380(%rsp)
callq 0xd9b20
testb $0x1, %al
jne 0x15b979
movb $0x1, 0x2de(%rsp)
movl $0x88, %edi
callq 0xd02b0
movq %rax, 0xd8(%rsp)
leaq 0x35f(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0xd0a20
movq 0xe0(%rsp), %rdx
leaq 0x1c672(%rip), %rsi     # 0x177de4
leaq 0x360(%rsp), %rdi
callq 0xd8b80
jmp 0x15b781
leaq 0x308(%rsp), %rdi
callq 0x155e60
movq 0x308(%rsp), %rsi
movq 0x310(%rsp), %rdx
leaq 0x318(%rsp), %rdi
callq 0x15a2a0
jmp 0x15b7ad
leaq 0x318(%rsp), %rdi
callq 0x1302d0
movq %rax, 0xc8(%rsp)
leaq 0x307(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0xd0a20
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
leaq 0x328(%rsp), %rdi
callq 0xd8b80
jmp 0x15b7f6
movq 0xe8(%rsp), %rdi
callq 0x1302d0
movq %rax, 0xb8(%rsp)
leaq 0x2df(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0xd0a20
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
leaq 0x2e0(%rsp), %rdi
callq 0xd8b80
jmp 0x15b83f
movq 0xd8(%rsp), %rdi
leaq 0x360(%rsp), %rsi
leaq 0x328(%rsp), %rdx
leaq 0x2e0(%rsp), %rcx
callq 0x156180
jmp 0x15b866
movq 0xd8(%rsp), %rdi
movb $0x0, 0x2de(%rsp)
leaq 0x4fbf3(%rip), %rsi     # 0x1ab470
leaq -0x54f4(%rip), %rdx     # 0x156390
callq 0xd09b0
jmp 0x15c216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15b94e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15b941
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15b927
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15b90d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0xd0b38
leaq 0x2df(%rsp), %rdi
callq 0xd0630
leaq 0x328(%rsp), %rdi
callq 0xd0b38
leaq 0x307(%rsp), %rdi
callq 0xd0630
leaq 0x318(%rsp), %rdi
callq 0xd9f30
leaq 0x360(%rsp), %rdi
callq 0xd0b38
leaq 0x35f(%rsp), %rdi
callq 0xd0630
testb $0x1, 0x2de(%rsp)
jne 0x15b967
jmp 0x15b974
movq 0xd8(%rsp), %rdi
callq 0xd0430
jmp 0x15c201
movq 0xe8(%rsp), %rdi
leaq 0x1c445(%rip), %rsi     # 0x177dcd
callq 0xd9b40
movq %rax, %rdi
callq 0xd9da0
testb $0x1, %al
jne 0x15b99e
jmp 0x15baf7
movb $0x1, 0x28e(%rsp)
movl $0x68, %edi
callq 0xd02b0
movq %rax, 0xa8(%rsp)
leaq 0x2b7(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0xd0a20
movq 0xb0(%rsp), %rdx
leaq 0x1c408(%rip), %rsi     # 0x177de4
leaq 0x2b8(%rsp), %rdi
callq 0xd8b80
jmp 0x15b9eb
leaq 0x28f(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xd0a20
movq 0xa0(%rsp), %rdx
leaq 0x1c3be(%rip), %rsi     # 0x177dcd
leaq 0x290(%rsp), %rdi
callq 0xd8b80
jmp 0x15ba1e
movq 0xa8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
leaq 0x290(%rsp), %rdx
callq 0x15a2f0
jmp 0x15ba3d
movq 0xa8(%rsp), %rdi
movb $0x0, 0x28e(%rsp)
leaq 0x4fb6c(%rip), %rsi     # 0x1ab5c0
leaq -0x162b(%rip), %rdx     # 0x15a430
callq 0xd09b0
jmp 0x15c216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15bacc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15bab2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
leaq 0x290(%rsp), %rdi
callq 0xd0b38
leaq 0x28f(%rsp), %rdi
callq 0xd0630
leaq 0x2b8(%rsp), %rdi
callq 0xd0b38
leaq 0x2b7(%rsp), %rdi
callq 0xd0630
testb $0x1, 0x28e(%rsp)
jne 0x15bae5
jmp 0x15baf2
movq 0xa8(%rsp), %rdi
callq 0xd0430
jmp 0x15c201
movq 0xe8(%rsp), %rdi
leaq 0x1c2ce(%rip), %rsi     # 0x177dd4
callq 0xd9b40
movq %rax, %rdi
callq 0xd9da0
testb $0x1, %al
jne 0x15bb1c
jmp 0x15bc75
movb $0x1, 0x23e(%rsp)
movl $0x68, %edi
callq 0xd02b0
movq %rax, 0x90(%rsp)
leaq 0x267(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0xd0a20
movq 0x98(%rsp), %rdx
leaq 0x1c28a(%rip), %rsi     # 0x177de4
leaq 0x268(%rsp), %rdi
callq 0xd8b80
jmp 0x15bb69
leaq 0x23f(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0xd0a20
movq 0x88(%rsp), %rdx
leaq 0x1c247(%rip), %rsi     # 0x177dd4
leaq 0x240(%rsp), %rdi
callq 0xd8b80
jmp 0x15bb9c
movq 0x90(%rsp), %rdi
leaq 0x268(%rsp), %rsi
leaq 0x240(%rsp), %rdx
callq 0x15a2f0
jmp 0x15bbbb
movq 0x90(%rsp), %rdi
movb $0x0, 0x23e(%rsp)
leaq 0x4f9ee(%rip), %rsi     # 0x1ab5c0
leaq -0x17a9(%rip), %rdx     # 0x15a430
callq 0xd09b0
jmp 0x15c216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15bc4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15bc30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
leaq 0x240(%rsp), %rdi
callq 0xd0b38
leaq 0x23f(%rsp), %rdi
callq 0xd0630
leaq 0x268(%rsp), %rdi
callq 0xd0b38
leaq 0x267(%rsp), %rdi
callq 0xd0630
testb $0x1, 0x23e(%rsp)
jne 0x15bc63
jmp 0x15bc70
movq 0x90(%rsp), %rdi
callq 0xd0430
jmp 0x15c201
movq 0xe8(%rsp), %rdi
leaq 0x1c157(%rip), %rsi     # 0x177ddb
callq 0xd9b40
movq %rax, %rdi
callq 0xd9da0
testb $0x1, %al
jne 0x15bc9a
jmp 0x15bde1
movb $0x1, 0x1ee(%rsp)
movl $0x68, %edi
callq 0xd02b0
movq %rax, 0x78(%rsp)
leaq 0x217(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0xd0a20
movq 0x80(%rsp), %rdx
leaq 0x1c10f(%rip), %rsi     # 0x177de4
leaq 0x218(%rsp), %rdi
callq 0xd8b80
jmp 0x15bce4
leaq 0x1ef(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0xd0a20
movq 0x70(%rsp), %rdx
leaq 0x1c0d9(%rip), %rsi     # 0x177ddb
leaq 0x1f0(%rsp), %rdi
callq 0xd8b80
jmp 0x15bd11
movq 0x78(%rsp), %rdi
leaq 0x218(%rsp), %rsi
leaq 0x1f0(%rsp), %rdx
callq 0x15a2f0
jmp 0x15bd2d
movq 0x78(%rsp), %rdi
movb $0x0, 0x1ee(%rsp)
leaq 0x4f87f(%rip), %rsi     # 0x1ab5c0
leaq -0x1918(%rip), %rdx     # 0x15a430
callq 0xd09b0
jmp 0x15c216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15bdb9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15bd9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0xd0b38
leaq 0x1ef(%rsp), %rdi
callq 0xd0630
leaq 0x218(%rsp), %rdi
callq 0xd0b38
leaq 0x217(%rsp), %rdi
callq 0xd0630
testb $0x1, 0x1ee(%rsp)
jne 0x15bdd2
jmp 0x15bddc
movq 0x78(%rsp), %rdi
callq 0xd0430
jmp 0x15c201
movq 0xe8(%rsp), %rdi
leaq 0x1bfdd(%rip), %rsi     # 0x177dcd
callq 0xd9b40
movq %rax, %rsi
leaq 0x1b8(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xd9dc0
movq 0x68(%rsp), %rsi
leaq 0x1c8(%rsp), %rdi
callq 0x155110
jmp 0x15be1e
leaq 0x1b8(%rsp), %rdi
callq 0xd9f30
movq 0xe8(%rsp), %rdi
leaq 0x1bf9a(%rip), %rsi     # 0x177dd4
callq 0xd9b40
movq %rax, 0x60(%rsp)
jmp 0x15be46
movq 0x60(%rsp), %rdi
callq 0x1565a0
movsd %xmm0, 0x58(%rsp)
jmp 0x15be58
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x1b0(%rsp)
jmp 0x15c125
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0xd9f30
jmp 0x15c201
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
movl 0x34c(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x15c201
movq 0x350(%rsp), %rdi
callq 0xd0210
movq %rax, 0x1a8(%rsp)
movb $0x1, 0x10e(%rsp)
movl $0xa8, %edi
callq 0xd02b0
movq %rax, 0x48(%rsp)
leaq 0x187(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xd0a20
movq 0x50(%rsp), %rdx
leaq 0x1bee0(%rip), %rsi     # 0x177de4
leaq 0x188(%rsp), %rdi
callq 0xd8b80
jmp 0x15bf13
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xd0a20
movq 0x40(%rsp), %rdx
leaq 0x1bea3(%rip), %rsi     # 0x177dd4
leaq 0x160(%rsp), %rdi
callq 0xd8b80
jmp 0x15bf40
leaq 0x137(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xd0a20
movq 0x38(%rsp), %rdx
leaq 0x1ba13(%rip), %rsi     # 0x177971
leaq 0x138(%rsp), %rdi
callq 0xd8b80
jmp 0x15bf6d
movq 0xe8(%rsp), %rdi
leaq 0x1be58(%rip), %rsi     # 0x177dd4
callq 0xd9b40
movq %rax, 0x30(%rsp)
jmp 0x15bf88
movq 0x30(%rsp), %rdi
callq 0x1302d0
movq %rax, 0x20(%rsp)
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xd0a20
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x110(%rsp), %rdi
callq 0xd8b80
jmp 0x15bfc2
movq 0x48(%rsp), %rdi
leaq 0x188(%rsp), %rsi
leaq 0x160(%rsp), %rdx
leaq 0x138(%rsp), %rcx
leaq 0x110(%rsp), %r8
callq 0x15a4a0
jmp 0x15bfee
movq 0x48(%rsp), %rdi
movb $0x0, 0x10e(%rsp)
leaq 0x4f5d6(%rip), %rsi     # 0x1ab5d8
leaq -0x1869(%rip), %rdx     # 0x15a7a0
callq 0xd09b0
jmp 0x15c216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15c0f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15c0dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15c0c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15c0b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
jmp 0x15c0a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xd0b38
leaq 0x10f(%rsp), %rdi
callq 0xd0630
leaq 0x138(%rsp), %rdi
callq 0xd0b38
leaq 0x137(%rsp), %rdi
callq 0xd0630
leaq 0x160(%rsp), %rdi
callq 0xd0b38
leaq 0x15f(%rsp), %rdi
callq 0xd0630
leaq 0x188(%rsp), %rdi
callq 0xd0b38
leaq 0x187(%rsp), %rdi
callq 0xd0630
testb $0x1, 0x10e(%rsp)
jne 0x15c10f
jmp 0x15c119
movq 0x48(%rsp), %rdi
callq 0xd0430
callq 0xd0940
jmp 0x15c120
jmp 0x15c201
movq 0xe8(%rsp), %rdi
leaq 0x1bca7(%rip), %rsi     # 0x177ddb
callq 0xd9b40
movq %rax, %rsi
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xd9dc0
movq 0x10(%rsp), %rdi
callq 0x1657d0
movq %rax, 0x18(%rsp)
jmp 0x15c15f
leaq 0xf0(%rsp), %rdi
callq 0xd9f30
movq 0x18(%rsp), %rax
movq %rax, 0x100(%rsp)
movl $0x90, %edi
callq 0xd05d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movsd 0x1b0(%rsp), %xmm0
movq 0x100(%rsp), %rdx
leaq 0x1c8(%rsp), %rsi
callq 0x15acf0
jmp 0x15c1ae
movq 0x8(%rsp), %rax
addq $0x388, %rsp            # imm = 0x388
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0xd9f30
jmp 0x15c201
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x350(%rsp)
movl %eax, 0x34c(%rsp)
movl $0x90, %esi
callq 0xd05e0
movq 0x350(%rsp), %rdi
callq 0xd0a10
movq %rax, %rdi
callq 0xd9890
nopw %cs:(%rax,%rax)