// File: rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::CombinedImageSamplerHandler::handle(spv::Op, unsigned int const*, unsigned int)
bool Compiler::CombinedImageSamplerHandler::handle(Op opcode, const uint32_t *args, uint32_t length)
{
	// We need to figure out where samplers and images are loaded from, so do only the bare bones compilation we need.
	bool is_fetch = false;

	switch (opcode)
	{
	case OpLoad:
	{
		if (length < 3)
			return false;

		uint32_t result_type = args[0];

		auto &type = compiler.get<SPIRType>(result_type);
		bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1;
		bool separate_sampler = type.basetype == SPIRType::Sampler;

		// If not separate image or sampler, don't bother.
		if (!separate_image && !separate_sampler)
			return true;

		uint32_t id = args[1];
		uint32_t ptr = args[2];
		compiler.set<SPIRExpression>(id, "", result_type, true);
		compiler.register_read(id, ptr, true);
		return true;
	}

	case OpInBoundsAccessChain:
	case OpAccessChain:
	{
		if (length < 3)
			return false;

		// Technically, it is possible to have arrays of textures and arrays of samplers and combine them, but this becomes essentially
		// impossible to implement, since we don't know which concrete sampler we are accessing.
		// One potential way is to create a combinatorial explosion where N textures and M samplers are combined into N * M sampler2Ds,
		// but this seems ridiculously complicated for a problem which is easy to work around.
		// Checking access chains like this assumes we don't have samplers or textures inside uniform structs, but this makes no sense.

		uint32_t result_type = args[0];

		auto &type = compiler.get<SPIRType>(result_type);
		bool separate_image = type.basetype == SPIRType::Image && type.image.sampled == 1;
		bool separate_sampler = type.basetype == SPIRType::Sampler;
		if (separate_sampler)
			SPIRV_CROSS_THROW(
			    "Attempting to use arrays or structs of separate samplers. This is not possible to statically "
			    "remap to plain GLSL.");

		if (separate_image)
		{
			uint32_t id = args[1];
			uint32_t ptr = args[2];
			compiler.set<SPIRExpression>(id, "", result_type, true);
			compiler.register_read(id, ptr, true);
		}
		return true;
	}

	case OpImageFetch:
	case OpImageQuerySizeLod:
	case OpImageQuerySize:
	case OpImageQueryLevels:
	case OpImageQuerySamples:
	{
		// If we are fetching from a plain OpTypeImage or querying LOD, we must pre-combine with our dummy sampler.
		auto *var = compiler.maybe_get_backing_variable(args[2]);
		if (!var)
			return true;

		auto &type = compiler.get<SPIRType>(var->basetype);
		if (type.basetype == SPIRType::Image && type.image.sampled == 1 && type.image.dim != DimBuffer)
		{
			if (compiler.dummy_sampler_id == 0)
				SPIRV_CROSS_THROW("texelFetch without sampler was found, but no dummy sampler has been created with "
				                  "build_dummy_sampler_for_combined_images().");

			// Do it outside.
			is_fetch = true;
			break;
		}

		return true;
	}

	case OpSampledImage:
		// Do it outside.
		break;

	default:
		return true;
	}

	// Registers sampler2D calls used in case they are parameters so
	// that their callees know which combined image samplers to propagate down the call stack.
	if (!functions.empty())
	{
		auto &callee = *functions.top();
		if (callee.do_combined_parameters)
		{
			uint32_t image_id = args[2];

			auto *image = compiler.maybe_get_backing_variable(image_id);
			if (image)
				image_id = image->self;

			uint32_t sampler_id = is_fetch ? compiler.dummy_sampler_id : args[3];
			auto *sampler = compiler.maybe_get_backing_variable(sampler_id);
			if (sampler)
				sampler_id = sampler->self;

			auto &combined_type = compiler.get<SPIRType>(args[0]);
			register_combined_image_sampler(callee, image_id, sampler_id, combined_type.image.depth);
		}
	}

	// For function calls, we need to remap IDs which are function parameters into global variables.
	// This information is statically known from the current place in the call stack.
	// Function parameters are not necessarily pointers, so if we don't have a backing variable, remapping will know
	// which backing variable the image/sample came from.
	uint32_t image_id = remap_parameter(args[2]);
	uint32_t sampler_id = is_fetch ? compiler.dummy_sampler_id : remap_parameter(args[3]);

	auto itr = find_if(begin(compiler.combined_image_samplers), end(compiler.combined_image_samplers),
	                   [image_id, sampler_id](const CombinedImageSampler &combined) {
		                   return combined.image_id == image_id && combined.sampler_id == sampler_id;
	                   });

	if (itr == end(compiler.combined_image_samplers))
	{
		uint32_t sampled_type;
		if (is_fetch)
		{
			// Have to invent the sampled image type.
			sampled_type = compiler.ir.increase_bound_by(1);
			auto &type = compiler.set<SPIRType>(sampled_type);
			type = compiler.expression_type(args[2]);
			type.self = sampled_type;
			type.basetype = SPIRType::SampledImage;
			type.image.depth = false;
		}
		else
		{
			sampled_type = args[0];
		}

		auto id = compiler.ir.increase_bound_by(2);
		auto type_id = id + 0;
		auto combined_id = id + 1;

		// Make a new type, pointer to OpTypeSampledImage, so we can make a variable of this type.
		// We will probably have this type lying around, but it doesn't hurt to make duplicates for internal purposes.
		auto &type = compiler.set<SPIRType>(type_id);
		auto &base = compiler.get<SPIRType>(sampled_type);
		type = base;
		type.pointer = true;
		type.storage = StorageClassUniformConstant;

		// Build new variable.
		compiler.set<SPIRVariable>(combined_id, type_id, StorageClassUniformConstant, 0);

		// Inherit RelaxedPrecision (and potentially other useful flags if deemed relevant).
		auto &new_flags = compiler.ir.meta[combined_id].decoration.decoration_flags;
		// Fetch inherits precision from the image, not sampler (there is no sampler).
		auto &old_flags = compiler.ir.meta[is_fetch ? image_id : sampler_id].decoration.decoration_flags;
		new_flags.reset();
		if (old_flags.get(DecorationRelaxedPrecision))
			new_flags.set(DecorationRelaxedPrecision);

		// Propagate the array type for the original image as well.
		auto *var = compiler.maybe_get_backing_variable(image_id);
		if (var)
		{
			auto &parent_type = compiler.get<SPIRType>(var->basetype);
			type.array = parent_type.array;
			type.array_size_literal = parent_type.array_size_literal;
		}

		compiler.combined_image_samplers.push_back({ combined_id, image_id, sampler_id });
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movb $0x0, -0x25(%rbp)
movl -0x14(%rbp), %eax
addl $-0x3d, %eax
movl %eax, %ecx
movq %rcx, -0x1b0(%rbp)
subl $0x2e, %eax
ja 0x27540
movq -0x1b0(%rbp), %rax
leaq 0x117e56(%rip), %rcx    # 0x13ef54
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x3, -0x24(%rbp)
jae 0x27116
movb $0x0, -0x1(%rbp)
jmp 0x27ab2
movq -0x1b8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, -0x2c(%rbp)
movq 0x8(%rax), %rdi
movl -0x2c(%rbp), %esi
callq 0xea90
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpl $0xd, 0xc(%rcx)
movb %al, -0x1b9(%rbp)
jne 0x2715c
movq -0x38(%rbp), %rax
cmpl $0x1, 0x8c(%rax)
sete %al
movb %al, -0x1b9(%rbp)
movb -0x1b9(%rbp), %al
andb $0x1, %al
movb %al, -0x39(%rbp)
movq -0x38(%rbp), %rax
cmpl $0xf, 0xc(%rax)
sete %al
andb $0x1, %al
movb %al, -0x3a(%rbp)
testb $0x1, -0x39(%rbp)
jne 0x2718c
testb $0x1, -0x3a(%rbp)
jne 0x2718c
movb $0x1, -0x1(%rbp)
jmp 0x27ab2
movq -0x1b8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, -0x40(%rbp)
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, -0x44(%rbp)
movq 0x8(%rax), %rdi
movl -0x40(%rbp), %esi
movb $0x1, -0x45(%rbp)
leaq 0x1176e5(%rip), %rdx    # 0x13e89e
leaq -0x2c(%rbp), %rcx
leaq -0x45(%rbp), %r8
callq 0x30ef0
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x40(%rbp), %esi
movl -0x44(%rbp), %edx
movl $0x1, %ecx
callq 0x1fb20
movb $0x1, -0x1(%rbp)
jmp 0x27ab2
cmpl $0x3, -0x24(%rbp)
jae 0x271f9
movb $0x0, -0x1(%rbp)
jmp 0x27ab2
movq -0x1b8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, -0x4c(%rbp)
movq 0x8(%rax), %rdi
movl -0x4c(%rbp), %esi
callq 0xea90
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rcx
xorl %eax, %eax
cmpl $0xd, 0xc(%rcx)
movb %al, -0x1ba(%rbp)
jne 0x2723f
movq -0x58(%rbp), %rax
cmpl $0x1, 0x8c(%rax)
sete %al
movb %al, -0x1ba(%rbp)
movb -0x1ba(%rbp), %al
andb $0x1, %al
movb %al, -0x59(%rbp)
movq -0x58(%rbp), %rax
cmpl $0xf, 0xc(%rax)
sete %al
andb $0x1, %al
movb %al, -0x5a(%rbp)
testb $0x1, -0x5a(%rbp)
je 0x27337
movb $0x1, -0x95(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1d0(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x7650
movq -0x1c8(%rbp), %rdx
leaq 0x1184d8(%rip), %rsi    # 0x13f775
leaq -0x80(%rbp), %rdi
callq 0x7520
jmp 0x272a8
movq -0x1d0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9c50
jmp 0x272ba
movq -0x1d0(%rbp), %rdi
movb $0x0, -0x95(%rbp)
leaq 0x186b09(%rip), %rsi    # 0x1addd8
leaq -0x1d646(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x27acc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2730f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x7708
leaq -0x81(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x95(%rbp)
jne 0x27326
jmp 0x27332
movq -0x1d0(%rbp), %rdi
callq 0x72c0
jmp 0x27ac0
testb $0x1, -0x59(%rbp)
je 0x273a7
movq -0x1b8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, -0x9c(%rbp)
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, -0xa0(%rbp)
movq 0x8(%rax), %rdi
movl -0x9c(%rbp), %esi
movb $0x1, -0xa1(%rbp)
leaq 0x117528(%rip), %rdx    # 0x13e89e
leaq -0x4c(%rbp), %rcx
leaq -0xa1(%rbp), %r8
callq 0x30ef0
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x9c(%rbp), %esi
movl -0xa0(%rbp), %edx
movl $0x1, %ecx
callq 0x1fb20
movb $0x1, -0x1(%rbp)
jmp 0x27ab2
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x1fa90
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x273e1
movb $0x1, -0x1(%rbp)
jmp 0x27ab2
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0xb0(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0x27535
movq -0xb8(%rbp), %rax
cmpl $0x1, 0x8c(%rax)
jne 0x27535
movq -0xb8(%rbp), %rax
cmpl $0x5, 0x84(%rax)
je 0x27535
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x0, 0x39c(%rax)
jne 0x2752f
movb $0x1, -0xda(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1e0(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x7650
movq -0x1d8(%rbp), %rdx
leaq 0x11835b(%rip), %rsi    # 0x13f7e7
leaq -0xd8(%rbp), %rdi
callq 0x7520
jmp 0x2749a
movq -0x1e0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x9c50
jmp 0x274af
movq -0x1e0(%rbp), %rdi
movb $0x0, -0xda(%rbp)
leaq 0x186914(%rip), %rsi    # 0x1addd8
leaq -0x1d83b(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x27acc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x27507
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x7708
leaq -0xd9(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xda(%rbp)
jne 0x2751e
jmp 0x2752a
movq -0x1e0(%rbp), %rdi
callq 0x72c0
jmp 0x27ac0
movb $0x1, -0x25(%rbp)
jmp 0x27549
movb $0x1, -0x1(%rbp)
jmp 0x27ab2
jmp 0x27549
movb $0x1, -0x1(%rbp)
jmp 0x27ab2
movq -0x1b8(%rbp), %rdi
addq $0x60, %rdi
callq 0x30a60
testb $0x1, %al
jne 0x27693
movq -0x1b8(%rbp), %rdi
addq $0x60, %rdi
callq 0x30a20
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
testb $0x1, 0xca(%rax)
je 0x27691
movq -0x1b8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, -0xec(%rbp)
movq 0x8(%rax), %rdi
movl -0xec(%rbp), %esi
callq 0x1fa90
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
je 0x275d3
movq -0xf8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xec(%rbp)
testb $0x1, -0x25(%rbp)
je 0x275f2
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x39c(%rax), %eax
movl %eax, -0x1e4(%rbp)
jmp 0x275ff
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x1e4(%rbp)
movq -0x1b8(%rbp), %rax
movl -0x1e4(%rbp), %ecx
movl %ecx, -0xfc(%rbp)
movq 0x8(%rax), %rdi
movl -0xfc(%rbp), %esi
callq 0x1fa90
movq %rax, -0x108(%rbp)
cmpq $0x0, -0x108(%rbp)
je 0x27642
movq -0x108(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xfc(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
callq 0xea90
movq -0x1b8(%rbp), %rdi
movq %rax, -0x110(%rbp)
movq -0xe8(%rbp), %rsi
movl -0xec(%rbp), %edx
movl -0xfc(%rbp), %ecx
movq -0x110(%rbp), %rax
movb 0x88(%rax), %al
andb $0x1, %al
movzbl %al, %r8d
callq 0x26740
jmp 0x27693
movq -0x1b8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x263d0
movl %eax, -0x114(%rbp)
testb $0x1, -0x25(%rbp)
je 0x276cb
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x39c(%rax), %eax
movl %eax, -0x1e8(%rbp)
jmp 0x276e4
movq -0x1b8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x263d0
movl %eax, -0x1e8(%rbp)
movq -0x1b8(%rbp), %rax
movl -0x1e8(%rbp), %ecx
movl %ecx, -0x118(%rbp)
movq 0x8(%rax), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
callq 0x30f70
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
movq %rcx, -0x128(%rbp)
movq 0x8(%rax), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
callq 0x30fa0
movq %rax, -0x130(%rbp)
movl -0x114(%rbp), %eax
movl %eax, -0x138(%rbp)
movl -0x118(%rbp), %eax
movl %eax, -0x134(%rbp)
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %rsi
movq -0x138(%rbp), %rdx
callq 0x27ad0
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
movq %rcx, -0x120(%rbp)
movq 0x8(%rax), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
callq 0x30fa0
movq %rax, -0x140(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x30fd0
testb $0x1, %al
jne 0x277a5
jmp 0x27aae
testb $0x1, -0x25(%rbp)
je 0x27844
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x55780
movl %eax, %ecx
movq -0x1b8(%rbp), %rax
movl %ecx, -0x144(%rbp)
movq 0x8(%rax), %rdi
movl -0x144(%rbp), %esi
callq 0x30cb0
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
movq %rcx, -0x150(%rbp)
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x1f760
movq %rax, %rsi
movq -0x150(%rbp), %rdi
callq 0x2f600
movl -0x144(%rbp), %ecx
movq -0x150(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x150(%rbp), %rax
movl $0xe, 0xc(%rax)
movq -0x150(%rbp), %rax
movb $0x0, 0x88(%rax)
jmp 0x27850
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x144(%rbp)
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x8, %rdi
movl $0x2, %esi
callq 0x55780
movl %eax, %ecx
movq -0x1b8(%rbp), %rax
movl %ecx, -0x154(%rbp)
movl -0x154(%rbp), %ecx
addl $0x0, %ecx
movl %ecx, -0x158(%rbp)
movl -0x154(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x15c(%rbp)
movq 0x8(%rax), %rdi
movl -0x158(%rbp), %esi
callq 0x30cb0
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
movq %rcx, -0x168(%rbp)
movq 0x8(%rax), %rdi
movl -0x144(%rbp), %esi
callq 0xea90
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rsi
movq -0x168(%rbp), %rdi
callq 0x2f600
movq -0x1b8(%rbp), %rax
movq -0x168(%rbp), %rcx
movb $0x1, 0x60(%rcx)
movq -0x168(%rbp), %rcx
movl $0x0, 0x64(%rcx)
movq 0x8(%rax), %rdi
movl -0x15c(%rbp), %esi
movl $0x0, -0x174(%rbp)
movl $0x0, -0x178(%rbp)
leaq -0x158(%rbp), %rdx
leaq -0x174(%rbp), %rcx
leaq -0x178(%rbp), %r8
callq 0x30d00
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x8, %rdi
addq $0x30, %rdi
movl -0x15c(%rbp), %eax
movl %eax, %esi
callq 0xead0
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
addq $0x60, %rcx
movq %rcx, -0x180(%rbp)
movq 0x8(%rax), %rax
addq $0x8, %rax
addq $0x30, %rax
movq %rax, -0x1f0(%rbp)
testb $0x1, -0x25(%rbp)
je 0x27993
movl -0x114(%rbp), %eax
movl %eax, -0x1f4(%rbp)
jmp 0x2799f
movl -0x118(%rbp), %eax
movl %eax, -0x1f4(%rbp)
movq -0x1f0(%rbp), %rdi
movl -0x1f4(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0xead0
addq $0x60, %rax
movq %rax, -0x188(%rbp)
movq -0x180(%rbp), %rdi
callq 0x30d60
movq -0x188(%rbp), %rdi
xorl %esi, %esi
callq 0xef50
testb $0x1, %al
jne 0x279e0
jmp 0x279ee
movq -0x180(%rbp), %rdi
xorl %esi, %esi
callq 0x300d0
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x114(%rbp), %esi
callq 0x1fa90
movq %rax, -0x190(%rbp)
cmpq $0x0, -0x190(%rbp)
je 0x27a6c
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x190(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rsi
addq $0x20, %rsi
movq -0x168(%rbp), %rdi
addq $0x20, %rdi
callq 0x31010
movq -0x198(%rbp), %rsi
addq $0x38, %rsi
movq -0x168(%rbp), %rdi
addq $0x38, %rdi
callq 0x31260
movq -0x1b8(%rbp), %rax
movq 0x8(%rax), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
movl -0x15c(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movl -0x114(%rbp), %eax
movl %eax, -0x1a0(%rbp)
movl -0x118(%rbp), %eax
movl %eax, -0x19c(%rbp)
leaq -0x1a4(%rbp), %rsi
callq 0x313c0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x7640
nopl (%rax)