// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %r15
cmpb $0x1, (%rdi)
jne 0x7584e
leaq 0x14ce1(%rip), %rsi     # 0x8a40f
movq %r15, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x758b8
leaq 0x14cc9(%rip), %rsi     # 0x8a40f
movq %r15, %rdi
callq 0x416d6
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x7680c
movq 0x8(%rsp), %r12
leaq 0xf4a3(%rip), %rsi      # 0x84c0a
movq %r15, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x757b8
leaq 0xf48f(%rip), %rsi      # 0x84c0a
movq %r15, %rdi
callq 0x416d6
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x41894
movq %rbx, %rdi
callq 0x7fbfc
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x48a06
leaq 0x40(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x48aa8
jmp 0x757ba
xorl %ebx, %ebx
cmpl $0x1, %r12d
je 0x757f5
testl %r12d, %r12d
jne 0x7594c
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x41894
movq %r14, %rdi
callq 0x77024
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x48a06
leaq 0x30(%rsp), %rdi
jmp 0x7581f
leaq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x41894
movq %r14, %rdi
callq 0x781ac
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x48a06
leaq 0x20(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x48aa8
testq %rbx, %rbx
je 0x75839
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x48(%rax)
movq %r14, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x88, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x178(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15a89(%rip), %rsi     # 0x8b2f8
leaq 0x15a8e(%rip), %rdx     # 0x8b304
leaq 0x168(%rsp), %rdi
callq 0x44728
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x747bc
movzbl 0x8(%rsp), %eax
cmpq $0x8, %rax
ja 0x759aa
leaq 0x2e9a9(%rip), %rcx     # 0xa4258
movq (%rcx,%rax,8), %rbx
jmp 0x759b1
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x118(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x15a20(%rip), %rsi     # 0x8b2f8
leaq 0x15a25(%rip), %rdx     # 0x8b304
leaq 0x108(%rsp), %rdi
callq 0x44728
leaq 0xf8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x14b0f(%rip), %rsi     # 0x8a40f
leaq 0x14b0c(%rip), %rdx     # 0x8a413
leaq 0xe8(%rsp), %rdi
callq 0x44728
movb $0x1, %bpl
leaq 0x108(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
movq %r14, %rdi
callq 0x75d5a
xorl %ebp, %ebp
leaq 0x2e968(%rip), %rsi     # 0xa42a0
leaq 0x5af(%rip), %rdx       # 0x75eee
movq %r14, %rdi
callq 0x3a750
jmp 0x75c9f
movl $0x50, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1598f(%rip), %rsi     # 0x8b2f8
leaq 0x15994(%rip), %rdx     # 0x8b304
leaq 0x68(%rsp), %rdi
callq 0x44728
movl %r12d, %edx
movb $0x1, %bpl
leaq 0x68(%rsp), %rsi
movq %r14, %rdi
callq 0x76472
xorl %ebp, %ebp
leaq 0x2e93a(%rip), %rsi     # 0xa42d0
leaq -0x1719(%rip), %rdx     # 0x74284
movq %r14, %rdi
callq 0x3a750
jmp 0x75c9f
leaq 0x1184d(%rip), %rbx     # 0x871fe
leaq 0x158(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x148(%rsp), %rdi
movq %rbx, %rsi
callq 0x44728
movzbl (%r15), %eax
cmpq $0x8, %rax
ja 0x759f0
leaq 0x2e86e(%rip), %rcx     # 0xa4258
movq (%rcx,%rax,8), %rbx
jmp 0x759f7
leaq 0x11807(%rip), %rbx     # 0x871fe
leaq 0x138(%rsp), %r15
movq %r15, -0x10(%r15)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x128(%rsp), %rdi
movq %rbx, %rsi
callq 0x44728
movb $0x1, %bpl
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
leaq 0x128(%rsp), %rcx
movq %r14, %rdi
callq 0x73acc
xorl %ebp, %ebp
leaq 0x2e6bd(%rip), %rsi     # 0xa4108
leaq -0x1cb2(%rip), %rdx     # 0x73da0
movq %r14, %rdi
callq 0x3a750
jmp 0x75c9f
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x75a87
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75a87
movq %rax, %rbx
movb $0x1, %bpl
movq 0x148(%rsp), %rdi
cmpq %r13, %rdi
je 0x75aac
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75aac
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0x4191c
jmp 0x75b17
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x75b52
movq 0x78(%rsp), %rsi
jmp 0x75b2c
jmp 0x75b4c
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r12, %rdi
je 0x75afa
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75afa
movq %rax, %rbx
movb $0x1, %bpl
movq 0x108(%rsp), %rdi
cmpq %r15, %rdi
je 0x75b52
movq 0x118(%rsp), %rsi
jmp 0x75b2c
movq %rax, %rbx
movb $0x1, %bpl
movq 0x168(%rsp), %rdi
cmpq %r12, %rdi
je 0x75b52
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75b52
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x75b70
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x75b70
jmp 0x75b4c
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x75d49
movq %r14, %rdi
callq 0x3a330
jmp 0x75d49
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4191c
jmp 0x75d49
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x75d49
movq %rbx, %rdi
callq 0x3a1c0
movl $0xa8, %edi
callq 0x3a210
movq %rax, %r14
leaq 0xd8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15749(%rip), %rsi     # 0x8b2f8
leaq 0x1574e(%rip), %rdx     # 0x8b304
leaq 0xc8(%rsp), %rdi
callq 0x44728
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x14839(%rip), %rsi     # 0x8a40f
leaq 0x14836(%rip), %rdx     # 0x8a413
leaq 0xa8(%rsp), %rdi
callq 0x44728
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1570b(%rip), %rsi     # 0x8b305
leaq 0x15711(%rip), %rdx     # 0x8b312
leaq 0x48(%rsp), %rdi
callq 0x44728
leaq 0x147fd(%rip), %rsi     # 0x8a40f
movq %r15, %rdi
callq 0x416d6
movzbl (%rax), %eax
cmpq $0x8, %rax
ja 0x75c30
leaq 0x2e62e(%rip), %rcx     # 0xa4258
movq (%rcx,%rax,8), %rbx
jmp 0x75c37
leaq 0x115c7(%rip), %rbx     # 0x871fe
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
callq 0x44728
movb $0x1, %bpl
leaq 0xc8(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
leaq 0x48(%rsp), %rcx
leaq 0x88(%rsp), %r8
movq %r14, %rdi
callq 0x75f58
xorl %ebp, %ebp
leaq 0x2e628(%rip), %rsi     # 0xa42b8
leaq 0x731(%rip), %rdx       # 0x763c8
movq %r14, %rdi
callq 0x3a750
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x75cc9
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75cc9
jmp 0x75cc3
movq %rax, %rbx
movb $0x1, %bpl
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x75ced
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75ced
movq %rax, %rbx
movb $0x1, %bpl
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x75d12
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75d12
movq %rax, %rbx
movb $0x1, %bpl
movq 0xc8(%rsp), %rdi
cmpq %r12, %rdi
je 0x75d37
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x75d37
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x75d44
movq %r14, %rdi
callq 0x3a330
callq 0x3a710
movq %rbx, %rdi
callq 0x3a780
movq %rax, %rdi
callq 0x414b1
nop