// File: /workspace/github_cpp_makefile_star2_O2/Lut99[P]RayTracer/src/lib/Material.cpp
// Function: RayTracer::Material::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>)
Material* Material::from_json(json json_obj) {
    // Check if the object has an object type
    if (!json_obj.is_object()) {
        throw InvalidObjectFormat("Material", json::object().type_name(), json_obj.type_name());
    }

    // Check for the type field
    if (json_obj["type"].is_null()) {
        throw MissingFieldException("Material", "type");
    }

    // Parse the raw type
    MaterialType type;
    try {
        type = (MaterialType) json_obj["type"].get<unsigned long>();
    } catch (nlohmann::detail::type_error&) {
        throw InvalidFieldFormat("Material", "type", "unsigned long", json_obj["type"].type_name());
    }

    // Return the correct parser
    if (type == lambertian) {
        return (Material*) Lambertian::from_json(json_obj);
    } else if (type == metal) {
        return (Material*) Metal::from_json(json_obj);
    } else if (type == dielectric) {
        return (Material*) Dielectric::from_json(json_obj);
    } else {
        throw UnknownSubtypeException("Material", type);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %r15
cmpb $0x1, (%rdi)
jne 0x85c9f
leaq 0xb8d5(%rip), %rsi      # 0x914cf
movq %r15, %rdi
callq 0x56e34
cmpb $0x0, (%rax)
je 0x85d4f
leaq 0xb8bd(%rip), %rsi      # 0x914cf
movq %r15, %rdi
callq 0x56e34
movq %rax, %rdi
callq 0x80780
movq %rax, %rbx
testl %ebx, %ebx
je 0x85c6b
cmpl $0x1, %ebx
je 0x85c51
cmpl $0x2, %ebx
jne 0x85dc4
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x56f56
movq %rbx, %rdi
callq 0x870b8
jmp 0x85c83
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x56f56
movq %rbx, %rdi
callq 0x866fc
jmp 0x85c83
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x56f56
movq %rbx, %rdi
callq 0x861ee
movq %rax, %r14
movq %rbx, %rdi
callq 0x56fca
movq %r14, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x88, %edi
callq 0x52220
movq %rax, %r14
leaq 0xcfd5(%rip), %rsi      # 0x92c88
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 %r15, %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 %r14, %rdi
callq 0x7f052
xorl %ebp, %ebp
leaq 0x2b77d(%rip), %rsi     # 0xb14b8
leaq -0x6b9c(%rip), %rdx     # 0x7f1a6
movq %r14, %rdi
callq 0x52760
jmp 0x85fa5
pushq $0x68
popq %rdi
callq 0x52220
movq %rax, %r14
leaq 0xcf27(%rip), %rsi      # 0x92c88
leaq 0x108(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x56548
leaq 0xb755(%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 0x2b858(%rip), %rsi     # 0xb1608
leaq -0x5657(%rip), %rdx     # 0x80760
movq %r14, %rdi
callq 0x52760
jmp 0x85fa5
pushq $0x50
popq %rdi
callq 0x52220
movq %rax, %r14
leaq 0xceb2(%rip), %rsi      # 0x92c88
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 0x2b838(%rip), %rsi     # 0xb1638
leaq -0x6ae1(%rip), %rdx     # 0x7f326
movq %r14, %rdi
callq 0x52760
jmp 0x85fa5
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x52888
jmp 0x85e2c
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x148(%rsp), %rdi
callq 0x52888
jmp 0x85e41
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0x56fca
jmp 0x85e81
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x85e89
jmp 0x85ec0
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x52888
jmp 0x85e71
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x108(%rsp), %rdi
jmp 0x85e89
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x168(%rsp), %rdi
callq 0x52888
testb %bpl, %bpl
jne 0x85ec3
jmp 0x8600a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x85eb4
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x85eb4
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x56fca
jmp 0x8600a
jmp 0x85ec0
movq %rax, %rbx
movq %r14, %rdi
callq 0x52350
jmp 0x8600a
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x8600a
movq %rbx, %rdi
callq 0x521b0
movl $0xa8, %edi
callq 0x52220
movq %rax, %r14
leaq 0xcd90(%rip), %rsi      # 0x92c88
leaq 0xc8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x56548
leaq 0xb5be(%rip), %rsi      # 0x914cf
leaq 0xa8(%rsp), %rdi
leaq 0x5(%rsp), %rdx
callq 0x56548
leaq 0xc6ab(%rip), %rsi      # 0x925d5
leaq 0x88(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x56548
leaq 0xb58c(%rip), %rsi      # 0x914cf
movq %r15, %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 %r14, %rdi
callq 0x8079c
xorl %ebp, %ebp
leaq 0x2b68a(%rip), %rsi     # 0xb1620
leaq -0x560f(%rip), %rdx     # 0x8098e
movq %r14, %rdi
callq 0x52760
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x52888
jmp 0x85fbc
jmp 0x85fb6
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x88(%rsp), %rdi
callq 0x52888
jmp 0x85fd1
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xa8(%rsp), %rdi
callq 0x52888
jmp 0x85fe6
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xc8(%rsp), %rdi
callq 0x52888
testb %bpl, %bpl
jne 0x85ffd
jmp 0x86005
movq %rax, %rbx
movq %r14, %rdi
callq 0x52350
callq 0x52720
movq %rbx, %rdi
callq 0x527a0
movq %rax, %rdi
callq 0x56ca4