// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %r15
cmpb $0x1, (%rdi)
jne 0x7d9d6
leaq 0xcb1d(%rip), %rsi      # 0x8a40f
movq %r15, %rdi
callq 0x416d6
cmpb $0x0, (%rax)
je 0x7da40
leaq 0xcb05(%rip), %rsi      # 0x8a40f
movq %r15, %rdi
callq 0x416d6
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x7680c
movq 0x8(%rsp), %rbx
testl %ebx, %ebx
je 0x7d98e
cmpl $0x1, %ebx
je 0x7d962
cmpl $0x2, %ebx
jne 0x7dad4
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x41894
movq %rbx, %rdi
callq 0x7f47a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x48a06
leaq 0x20(%rsp), %rdi
jmp 0x7d9b8
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x41894
movq %rbx, %rdi
callq 0x7e7dc
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x48a06
leaq 0x30(%rsp), %rdi
jmp 0x7d9b8
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x41894
movq %rbx, %rdi
callq 0x7e108
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x48a06
leaq 0x40(%rsp), %rdi
movzbl -0x8(%rdi), %esi
callq 0x48aa8
movq %rbx, %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 0xdf38(%rip), %rsi      # 0x8b92f
leaq 0xdf39(%rip), %rdx      # 0x8b937
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 0x7db31
leaq 0x26dd9(%rip), %rcx     # 0xa4810
movq (%rcx,%rax,8), %rbx
jmp 0x7db38
movl $0x68, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x118(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xdecf(%rip), %rsi      # 0x8b92f
leaq 0xded0(%rip), %rdx      # 0x8b937
leaq 0x108(%rsp), %rdi
callq 0x44728
leaq 0xf8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc987(%rip), %rsi      # 0x8a40f
leaq 0xc984(%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 0x267e0(%rip), %rsi     # 0xa42a0
leaq -0x7bd9(%rip), %rdx     # 0x75eee
movq %r14, %rdi
callq 0x3a750
jmp 0x7de29
movl $0x50, %edi
callq 0x3a210
movq %rax, %r14
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xde3e(%rip), %rsi      # 0x8b92f
leaq 0xde3f(%rip), %rdx      # 0x8b937
leaq 0x68(%rsp), %rdi
callq 0x44728
movl %ebx, %edx
movb $0x1, %bpl
leaq 0x68(%rsp), %rsi
movq %r14, %rdi
callq 0x76472
xorl %ebp, %ebp
leaq 0x267b3(%rip), %rsi     # 0xa42d0
leaq -0x98a0(%rip), %rdx     # 0x74284
movq %r14, %rdi
callq 0x3a750
jmp 0x7de29
leaq 0x96c6(%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 0x7db77
leaq 0x26c9f(%rip), %rcx     # 0xa4810
movq (%rcx,%rax,8), %rbx
jmp 0x7db7e
leaq 0x9680(%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 0x26536(%rip), %rsi     # 0xa4108
leaq -0x9e39(%rip), %rdx     # 0x73da0
movq %r14, %rdi
callq 0x3a750
jmp 0x7de29
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x7dc0e
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7dc0e
movq %rax, %rbx
movb $0x1, %bpl
movq 0x148(%rsp), %rdi
cmpq %r13, %rdi
je 0x7dc33
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7dc33
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0x4191c
jmp 0x7dca1
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x7dcee
movq 0x78(%rsp), %rsi
jmp 0x7dcb6
jmp 0x7dce8
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7dc84
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7dc84
movq %rax, %rbx
movb $0x1, %bpl
movq 0x108(%rsp), %rdi
cmpq %r15, %rdi
je 0x7dcee
movq 0x118(%rsp), %rsi
jmp 0x7dcb6
movq %rax, %rbx
movb $0x1, %bpl
movq 0x168(%rsp), %rdi
cmpq %r12, %rdi
je 0x7dcee
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7dcee
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x7dcdc
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x7dcdc
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x4191c
jmp 0x7ded3
jmp 0x7dce8
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x7ded3
movq %r14, %rdi
callq 0x3a330
jmp 0x7ded3
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x7ded3
movq %rbx, %rdi
callq 0x3a1c0
movl $0xa8, %edi
callq 0x3a210
movq %rax, %r14
leaq 0xd8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xdbf6(%rip), %rsi      # 0x8b92f
leaq 0xdbf7(%rip), %rdx      # 0x8b937
leaq 0xc8(%rsp), %rdi
callq 0x44728
leaq 0xb8(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xc6af(%rip), %rsi      # 0x8a40f
leaq 0xc6ac(%rip), %rdx      # 0x8a413
leaq 0xa8(%rsp), %rdi
callq 0x44728
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd581(%rip), %rsi      # 0x8b305
leaq 0xd587(%rip), %rdx      # 0x8b312
leaq 0x48(%rsp), %rdi
callq 0x44728
leaq 0xc673(%rip), %rsi      # 0x8a40f
movq %r15, %rdi
callq 0x416d6
movzbl (%rax), %eax
cmpq $0x8, %rax
ja 0x7ddba
leaq 0x26a5c(%rip), %rcx     # 0xa4810
movq (%rcx,%rax,8), %rbx
jmp 0x7ddc1
leaq 0x943d(%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 0x2649e(%rip), %rsi     # 0xa42b8
leaq -0x7a59(%rip), %rdx     # 0x763c8
movq %r14, %rdi
callq 0x3a750
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x7de53
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7de53
jmp 0x7de4d
movq %rax, %rbx
movb $0x1, %bpl
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x7de77
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7de77
movq %rax, %rbx
movb $0x1, %bpl
movq 0xa8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7de9c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7de9c
movq %rax, %rbx
movb $0x1, %bpl
movq 0xc8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7dec1
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7dec1
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x7dece
movq %r14, %rdi
callq 0x3a330
callq 0x3a710
movq %rbx, %rdi
callq 0x3a780
movq %rax, %rdi
callq 0x414b1
nop