// File: /workspace/github_cpp_makefile_star2_O1/Lut99[P]RayTracer/src/lib/Camera.cpp
// Function: RayTracer::Camera::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>)
Camera* Camera::from_json(nlohmann::json json_obj) {
    // Check if it is an object
    if (!json_obj.is_object()) {
        throw InvalidObjectFormat("Camera", json::object().type_name(), json_obj.type_name());
    }

    // Next, check if the required fields are present
    if (json_obj["lookat"].is_null()) {
        throw MissingFieldException("Camera", "lookat");
    }
    if (json_obj["lookfrom"].is_null()) {
        throw MissingFieldException("Camera", "lookfrom");
    }
    if (json_obj["up"].is_null()) {
        throw MissingFieldException("Camera", "up");
    }
    if (json_obj["vfov"].is_null()) {
        throw MissingFieldException("Camera", "vfov");
    }
    if (json_obj["aperture"].is_null()) {
        throw MissingFieldException("Camera", "aperture");
    }

    // Parse the objects
    Vec3 lookat = Vec3::from_json(json_obj["lookat"]);
    Vec3 lookfrom = Vec3::from_json(json_obj["lookfrom"]);
    Vec3 up = Vec3::from_json(json_obj["up"]);
    double vfov, aperture;
    try {
        vfov = json_obj["vfov"].get<double>();
        aperture = json_obj["aperture"].get<double>();
    } catch (nlohmann::detail::type_error&) {
        throw InvalidFieldFormat("Camera", "vfov or aperture", "double", json_obj[0].type_name());
    }
    // Only parse the animation if it is present
    CameraMovement* animation = nullptr;
    if (!json_obj["animation"].is_null()) {
        animation = CameraMovement::from_json(json_obj["animation"]);
    }
    
    // Put everything in the camera
    Camera* to_return = new Camera(lookfrom, lookat, up, vfov, aperture);
    if (animation != nullptr) {
        to_return->set_animation(animation);
    }

    // Return it
    return to_return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x338, %rsp            # imm = 0x338
movq %rdi, %r14
cmpb $0x1, (%rdi)
jne 0x7a5f4
leaq 0x113b6(%rip), %rsi     # 0x8b708
movq %r14, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x7a65e
leaq 0x113a5(%rip), %rsi     # 0x8b70f
movq %r14, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x7a6f2
leaq 0x11396(%rip), %rsi     # 0x8b718
movq %r14, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x7a786
leaq 0xa676(%rip), %rsi      # 0x84a10
movq %r14, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x7a81a
leaq 0x11378(%rip), %rsi     # 0x8b72a
movq %r14, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x7a8ae
leaq 0x1133e(%rip), %rsi     # 0x8b708
movq %r14, %rdi
callq 0x416d6
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x41894
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x73118
leaq 0x48(%rsp), %rdi
callq 0x48a06
leaq 0x50(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x48aa8
leaq 0x11301(%rip), %rsi     # 0x8b70f
movq %r14, %rdi
callq 0x416d6
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x41894
leaq 0x2b8(%rsp), %rdi
movq %rbx, %rsi
callq 0x73118
leaq 0x38(%rsp), %rdi
callq 0x48a06
leaq 0x40(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x48aa8
leaq 0x112c3(%rip), %rsi     # 0x8b718
movq %r14, %rdi
callq 0x416d6
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x41894
leaq 0x298(%rsp), %rdi
movq %rbx, %rsi
callq 0x73118
leaq 0x28(%rsp), %rdi
callq 0x48a06
leaq 0x30(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x48aa8
leaq 0xa574(%rip), %rsi      # 0x84a10
movq %r14, %rdi
callq 0x416d6
movq %rsp, %rsi
movq %rax, %rdi
callq 0x753fb
movsd (%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x11269(%rip), %rsi     # 0x8b72a
movq %r14, %rdi
callq 0x416d6
movq %rsp, %rsi
movq %rax, %rdi
callq 0x753fb
movsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xa724(%rip), %rsi      # 0x84c0a
movq %r14, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x7a537
leaq 0xa710(%rip), %rsi      # 0x84c0a
movq %r14, %rdi
callq 0x416d6
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x41894
movq %rbx, %rdi
callq 0x80234
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x48a06
leaq 0x20(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x48aa8
jmp 0x7a539
xorl %ebx, %ebx
movl $0x178, %edi            # imm = 0x178
callq 0x3a460
movq %rax, %r14
leaq 0x29b33(%rip), %rax     # 0xa4080
addq $0x10, %rax
leaq 0x318(%rsp), %rsi
movq %rax, (%rsi)
movups 0x2c0(%rsp), %xmm0
movups %xmm0, 0x8(%rsi)
movq 0x2d0(%rsp), %rcx
movq %rcx, 0x18(%rsi)
leaq 0x2f8(%rsp), %rdx
movq %rax, (%rdx)
movups 0x80(%rsp), %xmm0
movups %xmm0, 0x8(%rdx)
movq 0x90(%rsp), %rcx
movq %rcx, 0x18(%rdx)
leaq 0x2d8(%rsp), %rcx
movq %rax, (%rcx)
movups 0x2a0(%rsp), %xmm0
movups %xmm0, 0x8(%rcx)
movq 0x2b0(%rsp), %rax
movq %rax, 0x18(%rcx)
movq %r14, %rdi
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x79cc6
testq %rbx, %rbx
je 0x7a5df
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *0x10(%rax)
movq %r14, %rax
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x88, %edi
callq 0x3a210
movq %rax, %r15
leaq 0x288(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x11106(%rip), %rsi     # 0x8b71b
leaq 0x11105(%rip), %rdx     # 0x8b721
leaq 0x278(%rsp), %rdi
callq 0x44728
leaq 0x78(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x747bc
movzbl 0x78(%rsp), %eax
cmpq $0x8, %rax
ja 0x7a942
leaq 0x29f63(%rip), %rcx     # 0xa45b8
movq (%rcx,%rax,8), %rbx
jmp 0x7a949
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x228(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1109d(%rip), %rsi     # 0x8b71b
leaq 0x1109c(%rip), %rdx     # 0x8b721
leaq 0x218(%rsp), %rdi
callq 0x44728
leaq 0x208(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x11062(%rip), %rsi     # 0x8b708
leaq 0x11061(%rip), %rdx     # 0x8b70e
leaq 0x1f8(%rsp), %rdi
callq 0x44728
movb $0x1, %bpl
leaq 0x218(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
movq %r14, %rdi
callq 0x75d5a
xorl %ebp, %ebp
leaq 0x29bc2(%rip), %rsi     # 0xa42a0
leaq -0x47f7(%rip), %rdx     # 0x75eee
movq %r14, %rdi
callq 0x3a750
jmp 0x7ad71
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x1e8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x11009(%rip), %rsi     # 0x8b71b
leaq 0x11008(%rip), %rdx     # 0x8b721
leaq 0x1d8(%rsp), %rdi
callq 0x44728
leaq 0x1c8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10fd5(%rip), %rsi     # 0x8b70f
leaq 0x10fd6(%rip), %rdx     # 0x8b717
leaq 0x1b8(%rsp), %rdi
callq 0x44728
movb $0x1, %bpl
leaq 0x1d8(%rsp), %rsi
leaq 0x1b8(%rsp), %rdx
movq %r14, %rdi
callq 0x75d5a
xorl %ebp, %ebp
leaq 0x29b2e(%rip), %rsi     # 0xa42a0
leaq -0x488b(%rip), %rdx     # 0x75eee
movq %r14, %rdi
callq 0x3a750
jmp 0x7ad71
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x1a8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10f75(%rip), %rsi     # 0x8b71b
leaq 0x10f74(%rip), %rdx     # 0x8b721
leaq 0x198(%rsp), %rdi
callq 0x44728
leaq 0x188(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10f4a(%rip), %rsi     # 0x8b718
leaq 0x10f45(%rip), %rdx     # 0x8b71a
leaq 0x178(%rsp), %rdi
callq 0x44728
movb $0x1, %bpl
leaq 0x198(%rsp), %rsi
leaq 0x178(%rsp), %rdx
movq %r14, %rdi
callq 0x75d5a
xorl %ebp, %ebp
leaq 0x29a9a(%rip), %rsi     # 0xa42a0
leaq -0x491f(%rip), %rdx     # 0x75eee
movq %r14, %rdi
callq 0x3a750
jmp 0x7ad71
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x168(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10ee1(%rip), %rsi     # 0x8b71b
leaq 0x10ee0(%rip), %rdx     # 0x8b721
leaq 0x158(%rsp), %rdi
callq 0x44728
leaq 0x148(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xa1ae(%rip), %rsi      # 0x84a10
leaq 0xa1ab(%rip), %rdx      # 0x84a14
leaq 0x138(%rsp), %rdi
callq 0x44728
movb $0x1, %bpl
leaq 0x158(%rsp), %rsi
leaq 0x138(%rsp), %rdx
movq %r14, %rdi
callq 0x75d5a
xorl %ebp, %ebp
leaq 0x29a06(%rip), %rsi     # 0xa42a0
leaq -0x49b3(%rip), %rdx     # 0x75eee
movq %r14, %rdi
callq 0x3a750
jmp 0x7ad71
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x128(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10e4d(%rip), %rsi     # 0x8b71b
leaq 0x10e4c(%rip), %rdx     # 0x8b721
leaq 0x118(%rsp), %rdi
callq 0x44728
leaq 0x108(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10e34(%rip), %rsi     # 0x8b72a
leaq 0x10e35(%rip), %rdx     # 0x8b732
leaq 0xf8(%rsp), %rdi
callq 0x44728
movb $0x1, %bpl
leaq 0x118(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
movq %r14, %rdi
callq 0x75d5a
xorl %ebp, %ebp
leaq 0x29972(%rip), %rsi     # 0xa42a0
leaq -0x4a47(%rip), %rdx     # 0x75eee
movq %r14, %rdi
callq 0x3a750
jmp 0x7ad71
leaq 0xc8b5(%rip), %rbx      # 0x871fe
leaq 0x268(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x258(%rsp), %rdi
movq %rbx, %rsi
callq 0x44728
movzbl (%r14), %eax
cmpq $0x8, %rax
ja 0x7a988
leaq 0x29c36(%rip), %rcx     # 0xa45b8
movq (%rcx,%rax,8), %rbx
jmp 0x7a98f
leaq 0xc86f(%rip), %rbx      # 0x871fe
leaq 0x248(%rsp), %r14
movq %r14, -0x10(%r14)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x238(%rsp), %rdi
movq %rbx, %rsi
callq 0x44728
movb $0x1, %bpl
leaq 0x278(%rsp), %rsi
leaq 0x258(%rsp), %rdx
leaq 0x238(%rsp), %rcx
movq %r15, %rdi
callq 0x73acc
xorl %ebp, %ebp
leaq 0x29725(%rip), %rsi     # 0xa4108
leaq -0x6c4a(%rip), %rdx     # 0x73da0
movq %r15, %rdi
callq 0x3a750
jmp 0x7ad71
movq %rax, %rbx
movq 0x238(%rsp), %rdi
cmpq %r14, %rdi
je 0x7aa1f
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7aa1f
movq %rax, %rbx
movb $0x1, %bpl
movq 0x258(%rsp), %rdi
cmpq %r13, %rdi
je 0x7aa44
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7aa44
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x78(%rsp), %rdi
callq 0x4191c
jmp 0x7abb5
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7aa7b
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7aa7b
movq %rax, %rbx
movb $0x1, %bpl
movq 0x118(%rsp), %rdi
cmpq %r15, %rdi
je 0x7abe2
movq 0x128(%rsp), %rsi
jmp 0x7aba5
movq %rax, %rbx
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x7aac1
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7aac1
movq %rax, %rbx
movb $0x1, %bpl
movq 0x158(%rsp), %rdi
cmpq %r15, %rdi
je 0x7abe2
movq 0x168(%rsp), %rsi
jmp 0x7aba5
movq %rax, %rbx
movq 0x178(%rsp), %rdi
cmpq %r12, %rdi
je 0x7ab07
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7ab07
movq %rax, %rbx
movb $0x1, %bpl
movq 0x198(%rsp), %rdi
cmpq %r15, %rdi
je 0x7abe2
movq 0x1a8(%rsp), %rsi
jmp 0x7aba5
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7ab4d
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7ab4d
movq %rax, %rbx
movb $0x1, %bpl
movq 0x1d8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7abe2
movq 0x1e8(%rsp), %rsi
jmp 0x7aba5
movq %rax, %rbx
movq 0x1f8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7ab90
movq 0x208(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7ab90
movq %rax, %rbx
movb $0x1, %bpl
movq 0x218(%rsp), %rdi
cmpq %r15, %rdi
je 0x7abe2
movq 0x228(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7abe2
movq %rax, %rbx
movb $0x1, %bpl
movq 0x278(%rsp), %rdi
cmpq %r12, %rdi
je 0x7abfe
movq 0x288(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7abfe
jmp 0x7abdc
jmp 0x7abdc
jmp 0x7abdc
jmp 0x7abdc
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x7ae1b
movq %r14, %rdi
callq 0x3a330
jmp 0x7ae1b
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x7ae1b
movq %r15, %rdi
jmp 0x7abee
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x7ac47
movq %rax, %rbx
movl $0x178, %esi            # imm = 0x178
movq %r14, %rdi
callq 0x3a470
jmp 0x7ae1b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x7ac47
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x7ac47
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4191c
jmp 0x7ae1b
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x7ae1b
movq %rbx, %rdi
callq 0x3a1c0
movl $0xa8, %edi
callq 0x3a210
movq %rax, %r15
leaq 0xe8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10a95(%rip), %rsi     # 0x8b71b
leaq 0x10a94(%rip), %rdx     # 0x8b721
leaq 0xd8(%rsp), %rdi
callq 0x44728
leaq 0xc8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x10a75(%rip), %rsi     # 0x8b722
leaq 0x10a7e(%rip), %rdx     # 0x8b732
leaq 0xb8(%rsp), %rdi
callq 0x44728
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x10490(%rip), %rsi     # 0x8b161
leaq 0x1048f(%rip), %rdx     # 0x8b167
leaq 0x58(%rsp), %rdi
callq 0x44728
movq %r14, %rdi
xorl %esi, %esi
callq 0x738fa
movzbl (%rax), %eax
cmpq $0x8, %rax
ja 0x7ad02
leaq 0x298bc(%rip), %rcx     # 0xa45b8
movq (%rcx,%rax,8), %rbx
jmp 0x7ad09
leaq 0xc4f5(%rip), %rbx      # 0x871fe
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x44728
movb $0x1, %bpl
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
leaq 0x58(%rsp), %rcx
leaq 0x98(%rsp), %r8
movq %r15, %rdi
callq 0x75f58
xorl %ebp, %ebp
leaq 0x29556(%rip), %rsi     # 0xa42b8
leaq -0x49a1(%rip), %rdx     # 0x763c8
movq %r15, %rdi
callq 0x3a750
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x7ad9b
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7ad9b
jmp 0x7ad95
movq %rax, %rbx
movb $0x1, %bpl
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7adbf
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7adbf
movq %rax, %rbx
movb $0x1, %bpl
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7ade4
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7ade4
movq %rax, %rbx
movb $0x1, %bpl
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7ae09
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7ae09
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x7ae16
movq %r15, %rdi
callq 0x3a330
callq 0x3a710
movq %rbx, %rdi
callq 0x3a780
movq %rax, %rdi
callq 0x414b1
nop