// File: /workspace/github_cpp_makefile_star2_O3/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 0x79bfb
leaq 0x10dd2(%rip), %rsi     # 0x8a728
movq %r14, %rdi
callq 0x41392
cmpb $0x0, (%rax)
je 0x79c6b
leaq 0x10dc1(%rip), %rsi     # 0x8a72f
movq %r14, %rdi
callq 0x41392
cmpb $0x0, (%rax)
je 0x79cff
leaq 0x10db2(%rip), %rsi     # 0x8a738
movq %r14, %rdi
callq 0x41392
cmpb $0x0, (%rax)
je 0x79d93
leaq 0xa072(%rip), %rsi      # 0x83a10
movq %r14, %rdi
callq 0x41392
cmpb $0x0, (%rax)
je 0x79e27
leaq 0x10d94(%rip), %rsi     # 0x8a74a
movq %r14, %rdi
callq 0x41392
cmpb $0x0, (%rax)
je 0x79ebb
leaq 0x10d5a(%rip), %rsi     # 0x8a728
movq %r14, %rdi
callq 0x41392
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4155c
leaq 0x158(%rsp), %rdi
movq %rbx, %rsi
callq 0x725c2
leaq 0x48(%rsp), %rdi
callq 0x4861e
leaq 0x50(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x486c0
leaq 0x10d1a(%rip), %rsi     # 0x8a72f
movq %r14, %rdi
callq 0x41392
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4155c
leaq 0x2b8(%rsp), %rdi
movq %rbx, %rsi
callq 0x725c2
leaq 0x38(%rsp), %rdi
callq 0x4861e
leaq 0x40(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x486c0
leaq 0x10cdc(%rip), %rsi     # 0x8a738
movq %r14, %rdi
callq 0x41392
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4155c
leaq 0x298(%rsp), %rdi
movq %rbx, %rsi
callq 0x725c2
leaq 0x28(%rsp), %rdi
callq 0x4861e
leaq 0x30(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x486c0
leaq 0x9f6d(%rip), %rsi      # 0x83a10
movq %r14, %rdi
callq 0x41392
movq %rsp, %rsi
movq %rax, %rdi
callq 0x748f1
movsd (%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x10c82(%rip), %rsi     # 0x8a74a
movq %r14, %rdi
callq 0x41392
movq %rsp, %rsi
movq %rax, %rdi
callq 0x748f1
movsd (%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xa11d(%rip), %rsi      # 0x83c0a
movq %r14, %rdi
callq 0x41392
cmpb $0x0, (%rax)
je 0x79b3e
leaq 0xa109(%rip), %rsi      # 0x83c0a
movq %r14, %rdi
callq 0x41392
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4155c
movq %rbx, %rdi
callq 0x7fa38
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4861e
leaq 0x20(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x486c0
jmp 0x79b40
xorl %ebx, %ebx
movl $0x178, %edi            # imm = 0x178
callq 0x3a470
movq %rax, %r14
leaq 0x2955c(%rip), %rax     # 0xa30b0
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 0x160(%rsp), %xmm0
movups %xmm0, 0x8(%rdx)
movq 0x170(%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 0x792fa
testq %rbx, %rbx
je 0x79be6
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 0x128(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10b1f(%rip), %rsi     # 0x8a73b
leaq 0x10b1e(%rip), %rdx     # 0x8a741
leaq 0x118(%rsp), %rdi
callq 0x44390
leaq 0x158(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x73c9e
movzbl 0x158(%rsp), %eax
cmpq $0x8, %rax
ja 0x79f49
leaq 0x29986(%rip), %rcx     # 0xa35e8
movq (%rcx,%rax,8), %rbx
jmp 0x79f50
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x108(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10ab0(%rip), %rsi     # 0x8a73b
leaq 0x10aaf(%rip), %rdx     # 0x8a741
leaq 0xf8(%rsp), %rdi
callq 0x44390
leaq 0x248(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10a75(%rip), %rsi     # 0x8a728
leaq 0x10a74(%rip), %rdx     # 0x8a72e
leaq 0x238(%rsp), %rdi
callq 0x44390
movb $0x1, %bpl
leaq 0xf8(%rsp), %rsi
leaq 0x238(%rsp), %rdx
movq %r14, %rdi
callq 0x75298
xorl %ebp, %ebp
leaq 0x295e5(%rip), %rsi     # 0xa32d0
leaq -0x48c6(%rip), %rdx     # 0x7542c
movq %r14, %rdi
callq 0x3a760
jmp 0x7a400
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10a1c(%rip), %rsi     # 0x8a73b
leaq 0x10a1b(%rip), %rdx     # 0x8a741
leaq 0xd8(%rsp), %rdi
callq 0x44390
leaq 0x228(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x109e8(%rip), %rsi     # 0x8a72f
leaq 0x109e9(%rip), %rdx     # 0x8a737
leaq 0x218(%rsp), %rdi
callq 0x44390
movb $0x1, %bpl
leaq 0xd8(%rsp), %rsi
leaq 0x218(%rsp), %rdx
movq %r14, %rdi
callq 0x75298
xorl %ebp, %ebp
leaq 0x29551(%rip), %rsi     # 0xa32d0
leaq -0x495a(%rip), %rdx     # 0x7542c
movq %r14, %rdi
callq 0x3a760
jmp 0x7a400
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10988(%rip), %rsi     # 0x8a73b
leaq 0x10987(%rip), %rdx     # 0x8a741
leaq 0xb8(%rsp), %rdi
callq 0x44390
leaq 0x208(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1095d(%rip), %rsi     # 0x8a738
leaq 0x10958(%rip), %rdx     # 0x8a73a
leaq 0x1f8(%rsp), %rdi
callq 0x44390
movb $0x1, %bpl
leaq 0xb8(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
movq %r14, %rdi
callq 0x75298
xorl %ebp, %ebp
leaq 0x294bd(%rip), %rsi     # 0xa32d0
leaq -0x49ee(%rip), %rdx     # 0x7542c
movq %r14, %rdi
callq 0x3a760
jmp 0x7a400
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x108f4(%rip), %rsi     # 0x8a73b
leaq 0x108f3(%rip), %rdx     # 0x8a741
leaq 0x98(%rsp), %rdi
callq 0x44390
leaq 0x1e8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x9ba1(%rip), %rsi      # 0x83a10
leaq 0x9b9e(%rip), %rdx      # 0x83a14
leaq 0x1d8(%rsp), %rdi
callq 0x44390
movb $0x1, %bpl
leaq 0x98(%rsp), %rsi
leaq 0x1d8(%rsp), %rdx
movq %r14, %rdi
callq 0x75298
xorl %ebp, %ebp
leaq 0x29429(%rip), %rsi     # 0xa32d0
leaq -0x4a82(%rip), %rdx     # 0x7542c
movq %r14, %rdi
callq 0x3a760
jmp 0x7a400
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x10860(%rip), %rsi     # 0x8a73b
leaq 0x1085f(%rip), %rdx     # 0x8a741
leaq 0x78(%rsp), %rdi
callq 0x44390
leaq 0x1c8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1084a(%rip), %rsi     # 0x8a74a
leaq 0x1084b(%rip), %rdx     # 0x8a752
leaq 0x1b8(%rsp), %rdi
callq 0x44390
movb $0x1, %bpl
leaq 0x78(%rsp), %rsi
leaq 0x1b8(%rsp), %rdx
movq %r14, %rdi
callq 0x75298
xorl %ebp, %ebp
leaq 0x2939b(%rip), %rsi     # 0xa32d0
leaq -0x4b10(%rip), %rdx     # 0x7542c
movq %r14, %rdi
callq 0x3a760
jmp 0x7a400
leaq 0xc2ab(%rip), %rbx      # 0x861fb
leaq 0x288(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x278(%rsp), %rdi
movq %rbx, %rsi
callq 0x44390
movzbl (%r14), %eax
cmpq $0x8, %rax
ja 0x79f8f
leaq 0x2965f(%rip), %rcx     # 0xa35e8
movq (%rcx,%rax,8), %rbx
jmp 0x79f96
leaq 0xc265(%rip), %rbx      # 0x861fb
leaq 0x268(%rsp), %r14
movq %r14, -0x10(%r14)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x258(%rsp), %rdi
movq %rbx, %rsi
callq 0x44390
movb $0x1, %bpl
leaq 0x118(%rsp), %rsi
leaq 0x278(%rsp), %rdx
leaq 0x258(%rsp), %rcx
movq %r15, %rdi
callq 0x72fb0
xorl %ebp, %ebp
leaq 0x2914e(%rip), %rsi     # 0xa3138
leaq -0x6d6d(%rip), %rdx     # 0x73284
movq %r15, %rdi
callq 0x3a760
jmp 0x7a400
movq %rax, %rbx
movq 0x258(%rsp), %rdi
cmpq %r14, %rdi
je 0x7a026
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x7a026
movq %rax, %rbx
movb $0x1, %bpl
movq 0x278(%rsp), %rdi
cmpq %r13, %rdi
je 0x7a04b
movq 0x288(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x7a04b
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x158(%rsp), %rdi
callq 0x415d4
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a075
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3a480
testb %bpl, %bpl
jne 0x7a295
jmp 0x7a4be
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a0a3
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x3a480
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a22c
movq 0x88(%rsp), %rsi
jmp 0x7a224
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a285
movq 0x88(%rsp), %rsi
jmp 0x7a24e
movq %rax, %rbx
movq 0x1d8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a0fc
movq 0x1e8(%rsp), %rsi
incq %rsi
callq 0x3a480
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a22c
movq 0xa8(%rsp), %rsi
jmp 0x7a224
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a285
movq 0xa8(%rsp), %rsi
jmp 0x7a24e
movq %rax, %rbx
movq 0x1f8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a15b
movq 0x208(%rsp), %rsi
incq %rsi
callq 0x3a480
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a22c
movq 0xc8(%rsp), %rsi
jmp 0x7a224
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a285
movq 0xc8(%rsp), %rsi
jmp 0x7a24e
movq %rax, %rbx
movq 0x218(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a1ba
movq 0x228(%rsp), %rsi
incq %rsi
callq 0x3a480
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a22c
movq 0xe8(%rsp), %rsi
jmp 0x7a224
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a285
movq 0xe8(%rsp), %rsi
jmp 0x7a24e
movq %rax, %rbx
movq 0x238(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a20f
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x3a480
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a22c
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3a480
testb %bpl, %bpl
jne 0x7a285
jmp 0x7a4be
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7a285
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x7a285
movq %rax, %rbx
movq 0x118(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a295
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x7a295
jmp 0x7a282
jmp 0x7a282
jmp 0x7a282
jmp 0x7a282
movq %rax, %rbx
movq %r14, %rdi
callq 0x3a340
jmp 0x7a4be
movq %rax, %rbx
movq %r15, %rdi
jmp 0x7a288
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x7a2d5
movq %rax, %rbx
movl $0x178, %esi            # imm = 0x178
movq %r14, %rdi
callq 0x3a480
jmp 0x7a4be
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x7a2d5
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x7a2d5
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x415d4
jmp 0x7a4be
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x7a4be
movq %rbx, %rdi
callq 0x3a1c0
movl $0xa8, %edi
callq 0x3a210
movq %rax, %r15
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1042a(%rip), %rsi     # 0x8a73b
leaq 0x10429(%rip), %rdx     # 0x8a741
leaq 0x58(%rsp), %rdi
callq 0x44390
leaq 0x1a8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1040d(%rip), %rsi     # 0x8a742
leaq 0x10416(%rip), %rdx     # 0x8a752
leaq 0x198(%rsp), %rdi
callq 0x44390
leaq 0x188(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0xfe25(%rip), %rsi      # 0x8a181
leaq 0xfe24(%rip), %rdx      # 0x8a187
leaq 0x178(%rsp), %rdi
callq 0x44390
movq %r14, %rdi
xorl %esi, %esi
callq 0x72dc4
movzbl (%rax), %eax
cmpq $0x8, %rax
ja 0x7a390
leaq 0x2925e(%rip), %rcx     # 0xa35e8
movq (%rcx,%rax,8), %rbx
jmp 0x7a397
leaq 0xbe64(%rip), %rbx      # 0x861fb
leaq 0x148(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rbx, %rdi
callq 0x3a1f0
leaq (%rax,%rbx), %rdx
leaq 0x138(%rsp), %rdi
movq %rbx, %rsi
callq 0x44390
movb $0x1, %r14b
leaq 0x58(%rsp), %rsi
leaq 0x198(%rsp), %rdx
leaq 0x178(%rsp), %rcx
leaq 0x138(%rsp), %r8
movq %r15, %rdi
callq 0x75496
xorl %r14d, %r14d
leaq 0x28ef7(%rip), %rsi     # 0xa32e8
leaq -0x4af2(%rip), %rdx     # 0x75906
movq %r15, %rdi
callq 0x3a760
movq %rax, %rbx
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x7a432
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x7a432
jmp 0x7a42c
movq %rax, %rbx
movb $0x1, %r14b
movq 0x178(%rsp), %rdi
cmpq %rbp, %rdi
je 0x7a457
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x7a457
movq %rax, %rbx
movb $0x1, %r14b
movq 0x198(%rsp), %rdi
cmpq %r13, %rdi
je 0x7a474
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x3a480
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a48b
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3a480
testb %r14b, %r14b
jne 0x7a4b1
jmp 0x7a4b9
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x7a4b1
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x7a4b1
movq %rax, %rbx
movq %r15, %rdi
callq 0x3a340
callq 0x3a720
movq %rbx, %rdi
callq 0x3a790
movq %rax, %rdi
callq 0x4116b