// File: /workspace/github_cpp_makefile_star2_O2/Lut99[P]RayTracer/src/lib/RenderObject.cpp
// Function: RayTracer::RenderObject::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>)
RenderObject* RenderObject::from_json(json json_obj) {
    // Check if the object has an object type
    if (!json_obj.is_object()) {
        throw InvalidObjectFormat("RenderObject", json::object().type_name(), json_obj.type_name());
    }

    // Check for the type field
    if (json_obj["type"].is_null()) {
        throw MissingFieldException("RenderObject", "type");
    }

    // Parse the raw type
    RenderObjectType type;
    try {
        type = (RenderObjectType) json_obj["type"].get<unsigned long>();
    } catch (nlohmann::detail::type_error&) {
        throw InvalidFieldFormat("RenderObject", "type", "unsigned long", json_obj["type"].type_name());
    }
    // If the animation field is defined, parse it as such
    RenderAnimation* animation = nullptr;
    if (!json_obj["animation"].is_null()) {
        animation = RenderAnimation::from_json(json_obj["animation"]);
    }

    // Parse the rest of the object based on the type field
    RenderObject* to_return;
    if (type == sphere) {
        to_return = (RenderObject*) Sphere::from_json(json_obj);
    } else if (type == render_object_collection) {
        to_return = (RenderObject*) RenderObjectCollection::from_json(json_obj);
    } else {
        throw UnknownSubtypeException("RenderObject", type);
    }

    // If needed, add the animation
    if (animation != nullptr) {
        to_return->set_animation(animation);
    }

    // Return
    return to_return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %r14
cmpb $0x1, (%rdi)
jne 0x802ac
leaq 0x11307(%rip), %rsi     # 0x914cf
movq %r14, %rdi
callq 0x56e34
cmpb $0x0, (%rax)
je 0x8035c
leaq 0x112ef(%rip), %rsi     # 0x914cf
movq %r14, %rdi
callq 0x56e34
movq %rax, %rdi
callq 0x80780
movq %rax, %rbx
leaq 0xba10(%rip), %rsi      # 0x8bc0a
movq %r14, %rdi
callq 0x56e34
cmpb $0x0, (%rax)
je 0x8023d
leaq 0xb9fc(%rip), %rsi      # 0x8bc0a
movq %r14, %rdi
callq 0x56e34
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x56f56
movq %r15, %rdi
callq 0x875f2
movq %rax, %r15
leaq 0x18(%rsp), %rdi
callq 0x56fca
jmp 0x80240
xorl %r15d, %r15d
cmpl $0x1, %ebx
je 0x80267
testl %ebx, %ebx
jne 0x803d1
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x56f56
movq %rbx, %rdi
callq 0x81188
jmp 0x8027f
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x56f56
movq %rbx, %rdi
callq 0x81ea2
movq %rax, %r14
movq %rbx, %rdi
callq 0x56fca
testq %r15, %r15
je 0x8029b
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x48(%rax)
movq %r14, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x88, %edi
callq 0x52220
movq %rax, %r15
leaq 0x12308(%rip), %rsi     # 0x925c8
leaq 0x168(%rsp), %rdi
leaq 0x5(%rsp), %rdx
callq 0x56548
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x8067c
leaq 0x8(%rsp), %rdi
callq 0x6f406
leaq 0x148(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %rax, %rsi
callq 0x56548
movq %r14, %rdi
callq 0x6f406
leaq 0x128(%rsp), %rdi
leaq 0x6(%rsp), %rdx
movq %rax, %rsi
callq 0x56548
movb $0x1, %bpl
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
leaq 0x128(%rsp), %rcx
movq %r15, %rdi
callq 0x7f052
xorl %ebp, %ebp
leaq 0x31170(%rip), %rsi     # 0xb14b8
leaq -0x11a9(%rip), %rdx     # 0x7f1a6
movq %r15, %rdi
callq 0x52760
jmp 0x805c5
pushq $0x68
popq %rdi
callq 0x52220
movq %rax, %r14
leaq 0x1225a(%rip), %rsi     # 0x925c8
leaq 0x108(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x56548
leaq 0x11148(%rip), %rsi     # 0x914cf
leaq 0xe8(%rsp), %rdi
leaq 0x5(%rsp), %rdx
callq 0x56548
movb $0x1, %bpl
leaq 0x108(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
movq %r14, %rdi
callq 0x80690
xorl %ebp, %ebp
leaq 0x3124b(%rip), %rsi     # 0xb1608
leaq 0x39c(%rip), %rdx       # 0x80760
movq %r14, %rdi
callq 0x52760
jmp 0x805c5
pushq $0x50
popq %rdi
callq 0x52220
movq %rax, %r14
leaq 0x121e5(%rip), %rsi     # 0x925c8
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x56548
movl %ebx, %edx
movb $0x1, %bpl
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x809b2
xorl %ebp, %ebp
leaq 0x3122b(%rip), %rsi     # 0xb1638
leaq -0x10ee(%rip), %rdx     # 0x7f326
movq %r14, %rdi
callq 0x52760
jmp 0x805c5
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x52888
jmp 0x80439
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x148(%rsp), %rdi
callq 0x52888
jmp 0x8044e
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0x56fca
jmp 0x8049b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x80486
jmp 0x804c6
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x52888
jmp 0x8047e
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x108(%rsp), %rdi
callq 0x52888
testb %bpl, %bpl
jne 0x804c9
jmp 0x8062a
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x168(%rsp), %rdi
callq 0x52888
testb %bpl, %bpl
jne 0x804d1
jmp 0x8062a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x804e6
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x804e6
movq %rax, %rbx
movq %r14, %rdi
jmp 0x804d4
movq %rax, %rbx
movq %r15, %rdi
callq 0x52350
jmp 0x8062a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x56fca
jmp 0x8062a
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x8062a
movq %rbx, %rdi
callq 0x521b0
movl $0xa8, %edi
callq 0x52220
movq %rax, %r15
leaq 0x120b0(%rip), %rsi     # 0x925c8
leaq 0xc8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x56548
leaq 0x10f9e(%rip), %rsi     # 0x914cf
leaq 0xa8(%rsp), %rdi
leaq 0x5(%rsp), %rdx
callq 0x56548
leaq 0x1208b(%rip), %rsi     # 0x925d5
leaq 0x88(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x56548
leaq 0x10f6c(%rip), %rsi     # 0x914cf
movq %r14, %rdi
callq 0x56e34
movq %rax, %rdi
callq 0x6f406
leaq 0x68(%rsp), %rdi
leaq 0x6(%rsp), %rdx
movq %rax, %rsi
callq 0x56548
movb $0x1, %bpl
leaq 0xc8(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
leaq 0x88(%rsp), %rcx
leaq 0x68(%rsp), %r8
movq %r15, %rdi
callq 0x8079c
xorl %ebp, %ebp
leaq 0x3106a(%rip), %rsi     # 0xb1620
leaq 0x3d1(%rip), %rdx       # 0x8098e
movq %r15, %rdi
callq 0x52760
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x52888
jmp 0x805dc
jmp 0x805d6
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x88(%rsp), %rdi
callq 0x52888
jmp 0x805f1
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xa8(%rsp), %rdi
callq 0x52888
jmp 0x80606
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xc8(%rsp), %rdi
callq 0x52888
testb %bpl, %bpl
jne 0x8061d
jmp 0x80625
movq %rax, %rbx
movq %r15, %rdi
callq 0x52350
callq 0x52720
movq %rbx, %rdi
callq 0x527a0
movq %rax, %rdi
callq 0x56ca4