// File: rossy[P]crossc/SPIRV-Cross/spirv_msl.cpp
// Function: spirv_cross::CompilerMSL::extract_global_variables_from_function(unsigned int, std::set<unsigned int, std::less<unsigned int>, std::allocator<unsigned int>>&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&)
void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std::set<uint32_t> &added_arg_ids,
                                                         unordered_set<uint32_t> &global_var_ids,
                                                         unordered_set<uint32_t> &processed_func_ids)
{
	// Avoid processing a function more than once
	if (processed_func_ids.find(func_id) != processed_func_ids.end())
	{
		// Return function global variables
		added_arg_ids = function_global_vars[func_id];
		return;
	}

	processed_func_ids.insert(func_id);

	auto &func = get<SPIRFunction>(func_id);

	// Recursively establish global args added to functions on which we depend.
	for (auto block : func.blocks)
	{
		auto &b = get<SPIRBlock>(block);
		for (auto &i : b.ops)
		{
			auto ops = stream(i);
			auto op = static_cast<Op>(i.op);

			switch (op)
			{
			case OpLoad:
			case OpInBoundsAccessChain:
			case OpAccessChain:
			{
				uint32_t base_id = ops[2];
				if (global_var_ids.find(base_id) != global_var_ids.end())
					added_arg_ids.insert(base_id);

				auto &type = get<SPIRType>(ops[0]);
				if (type.basetype == SPIRType::Image && type.image.dim == DimSubpassData)
				{
					// Implicitly reads gl_FragCoord.
					assert(builtin_frag_coord_id != 0);
					added_arg_ids.insert(builtin_frag_coord_id);
				}

				if (msl_options.swizzle_texture_samples && has_sampled_images && is_sampled_image_type(type))
				{
					// Implicitly reads spvAuxBuffer.
					assert(aux_buffer_id != 0);
					added_arg_ids.insert(aux_buffer_id);
				}

				break;
			}

			case OpFunctionCall:
			{
				// First see if any of the function call args are globals
				for (uint32_t arg_idx = 3; arg_idx < i.length; arg_idx++)
				{
					uint32_t arg_id = ops[arg_idx];
					if (global_var_ids.find(arg_id) != global_var_ids.end())
						added_arg_ids.insert(arg_id);
				}

				// Then recurse into the function itself to extract globals used internally in the function
				uint32_t inner_func_id = ops[2];
				std::set<uint32_t> inner_func_args;
				extract_global_variables_from_function(inner_func_id, inner_func_args, global_var_ids,
				                                       processed_func_ids);
				added_arg_ids.insert(inner_func_args.begin(), inner_func_args.end());
				break;
			}

			case OpStore:
			{
				uint32_t base_id = ops[0];
				if (global_var_ids.find(base_id) != global_var_ids.end())
					added_arg_ids.insert(base_id);
				break;
			}

			default:
				break;
			}

			// TODO: Add all other operations which can affect memory.
			// We should consider a more unified system here to reduce boiler-plate.
			// This kind of analysis is done in several places ...
		}
	}

	function_global_vars[func_id] = added_arg_ids;

	// Add the global variables as arguments to the function
	if (func_id != ir.default_entry_point)
	{
		for (uint32_t arg_id : added_arg_ids)
		{
			auto &var = get<SPIRVariable>(arg_id);
			uint32_t type_id = var.basetype;
			auto *p_type = &get<SPIRType>(type_id);

			if (is_builtin_variable(var) && p_type->basetype == SPIRType::Struct)
			{
				// Get the non-pointer type
				type_id = get_non_pointer_type_id(type_id);
				p_type = &get<SPIRType>(type_id);

				uint32_t mbr_idx = 0;
				for (auto &mbr_type_id : p_type->member_types)
				{
					BuiltIn builtin;
					bool is_builtin = is_member_builtin(*p_type, mbr_idx, &builtin);
					if (is_builtin && has_active_builtin(builtin, var.storage))
					{
						// Add a arg variable with the same type and decorations as the member
						uint32_t next_ids = ir.increase_bound_by(2);
						uint32_t ptr_type_id = next_ids + 0;
						uint32_t var_id = next_ids + 1;

						// Make sure we have an actual pointer type,
						// so that we will get the appropriate address space when declaring these builtins.
						auto &ptr = set<SPIRType>(ptr_type_id, get<SPIRType>(mbr_type_id));
						ptr.self = mbr_type_id;
						ptr.storage = var.storage;
						ptr.pointer = true;

						func.add_parameter(mbr_type_id, var_id, true);
						set<SPIRVariable>(var_id, ptr_type_id, StorageClassFunction);
						ir.meta[var_id].decoration = ir.meta[type_id].members[mbr_idx];
					}
					mbr_idx++;
				}
			}
			else
			{
				uint32_t next_id = ir.increase_bound_by(1);
				func.add_parameter(type_id, next_id, true);
				set<SPIRVariable>(next_id, type_id, StorageClassFunction, 0, arg_id);

				// Ensure the existing variable has a valid name and the new variable has all the same meta info
				set_name(arg_id, ensure_valid_name(to_name(arg_id), "v"));
				ir.meta[next_id] = ir.meta[arg_id];
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x28(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0x2ff00
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x31e90
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2fed0
testb $0x1, %al
jne 0xf930a
jmp 0xf9332
movq -0x298(%rbp), %rdi
addq $0x788, %rdi            # imm = 0x788
leaq -0xc(%rbp), %rsi
callq 0x113c70
movq %rax, %rsi
movq -0x18(%rbp), %rdi
callq 0x113ca0
jmp 0xf9da6
movq -0x28(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0x2e890
movq -0x298(%rbp), %rdi
movq %rax, -0x48(%rbp)
movb %dl, -0x40(%rbp)
movl -0xc(%rbp), %esi
callq 0x106d0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x86d0
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x8700
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x8730
testb $0x1, %al
jne 0xf9395
jmp 0xf9805
leaq -0x60(%rbp), %rdi
callq 0x8770
movq -0x298(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %esi
callq 0x87d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0xa4cc0
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
callq 0xa4cf0
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xa4d20
testb $0x1, %al
jne 0xf93fe
jmp 0xf97f5
leaq -0x88(%rbp), %rdi
callq 0xa4d60
movq -0x298(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rsi
callq 0x2e560
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
addl $-0x39, %eax
movl %eax, %ecx
movq %rcx, -0x2a0(%rbp)
subl $0x9, %eax
ja 0xf97e0
movq -0x2a0(%rbp), %rax
leaq 0x50a28(%rip), %rcx     # 0x149e8c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xa8(%rbp)
movq -0x20(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x2ff00
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x31e90
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2fed0
testb $0x1, %al
jne 0xf94bd
jmp 0xf94da
movq -0x18(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x113cd0
movq %rax, -0xc8(%rbp)
movb %dl, -0xc0(%rbp)
movq -0x298(%rbp), %rdi
movq -0xa0(%rbp), %rax
movl (%rax), %esi
callq 0xea90
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0xf9568
movq -0xd0(%rbp), %rax
cmpl $0x6, 0x84(%rax)
jne 0xf9568
movq -0x298(%rbp), %rax
cmpl $0x0, 0x7c0(%rax)
je 0xf9525
jmp 0xf9544
leaq 0x51578(%rip), %rdi     # 0x14aaa4
leaq 0x5158c(%rip), %rsi     # 0x14aabf
movl $0x276, %edx            # imm = 0x276
leaq 0x5159a(%rip), %rcx     # 0x14aad9
callq 0x7260
movq -0x298(%rbp), %rsi
movq -0x18(%rbp), %rdi
addq $0x7c0, %rsi            # imm = 0x7C0
callq 0x113cd0
movq %rax, -0xe0(%rbp)
movb %dl, -0xd8(%rbp)
movq -0x298(%rbp), %rax
testb $0x1, 0x7df(%rax)
je 0xf95f6
movq -0x298(%rbp), %rax
testb $0x1, 0x934(%rax)
je 0xf95f6
movq -0x298(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x22ec0
testb $0x1, %al
jne 0xf95a1
jmp 0xf95f6
movq -0x298(%rbp), %rax
cmpl $0x0, 0x7c8(%rax)
je 0xf95b3
jmp 0xf95d2
leaq 0x515bb(%rip), %rdi     # 0x14ab75
leaq 0x514fe(%rip), %rsi     # 0x14aabf
movl $0x27d, %edx            # imm = 0x27D
leaq 0x5150c(%rip), %rcx     # 0x14aad9
callq 0x7260
movq -0x298(%rbp), %rsi
movq -0x18(%rbp), %rdi
addq $0x7c8, %rsi            # imm = 0x7C8
callq 0x113cd0
movq %rax, -0xf0(%rbp)
movb %dl, -0xe8(%rbp)
jmp 0xf97e2
movl $0x3, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
movq -0x98(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0xf96a4
movq -0xa0(%rbp), %rax
movl -0xf4(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0xf8(%rbp)
movq -0x20(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x2ff00
movq %rax, -0x100(%rbp)
movq -0x20(%rbp), %rdi
callq 0x31e90
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x2fed0
testb $0x1, %al
jne 0xf9671
jmp 0xf968e
movq -0x18(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x113cd0
movq %rax, -0x118(%rbp)
movb %dl, -0x110(%rbp)
jmp 0xf9690
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0xf9605
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x11c(%rbp)
leaq -0x150(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x113c30
movq -0x298(%rbp), %rdi
movq -0x2a8(%rbp), %rdx
movl -0x11c(%rbp), %esi
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0xf92b0
jmp 0xf96ea
movq -0x18(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x150(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x113d60
movq -0x2b8(%rbp), %rdi
movq %rax, -0x168(%rbp)
callq 0x113d90
movq -0x2b0(%rbp), %rdi
movq %rax, -0x170(%rbp)
movq -0x168(%rbp), %rsi
movq -0x170(%rbp), %rdx
callq 0x113d20
jmp 0xf973e
leaq -0x150(%rbp), %rdi
callq 0x113c50
jmp 0xf97e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x113c50
jmp 0xf9daf
movq -0xa0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x174(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x174(%rbp), %rsi
callq 0x2ff00
movq %rax, -0x180(%rbp)
movq -0x20(%rbp), %rdi
callq 0x31e90
movq %rax, -0x188(%rbp)
leaq -0x180(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x2fed0
testb $0x1, %al
jne 0xf97c1
jmp 0xf97de
movq -0x18(%rbp), %rdi
leaq -0x174(%rbp), %rsi
callq 0x113cd0
movq %rax, -0x198(%rbp)
movb %dl, -0x190(%rbp)
jmp 0xf97e2
jmp 0xf97e2
jmp 0xf97e4
leaq -0x88(%rbp), %rdi
callq 0xa4d80
jmp 0xf93e2
jmp 0xf97f7
leaq -0x60(%rbp), %rdi
callq 0x8790
jmp 0xf937f
movq -0x298(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x2c0(%rbp)
addq $0x788, %rdi            # imm = 0x788
leaq -0xc(%rbp), %rsi
callq 0x113c70
movq -0x2c0(%rbp), %rsi
movq %rax, %rdi
callq 0x113ca0
movq -0x298(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x108(%rcx), %eax
je 0xf9da6
movq -0x18(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rdi
callq 0x113d60
movq %rax, -0x1a8(%rbp)
movq -0x1a0(%rbp), %rdi
callq 0x113d90
movq %rax, -0x1b0(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x113dc0
testb $0x1, %al
jne 0xf9899
jmp 0xf9da4
leaq -0x1a8(%rbp), %rdi
callq 0x113df0
movq -0x298(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x1b4(%rbp)
movl -0x1b4(%rbp), %esi
callq 0xfec0
movq -0x298(%rbp), %rdi
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x1c4(%rbp)
movl -0x1c4(%rbp), %esi
callq 0xea90
movq -0x298(%rbp), %rdi
movq %rax, -0x1d0(%rbp)
movq -0x1c0(%rbp), %rsi
callq 0x205a0
testb $0x1, %al
jne 0xf990b
jmp 0xf9b91
movq -0x1d0(%rbp), %rax
cmpl $0xc, 0xc(%rax)
jne 0xf9b91
movq -0x298(%rbp), %rdi
movl -0x1c4(%rbp), %esi
callq 0x22d70
movq -0x298(%rbp), %rdi
movl %eax, -0x1c4(%rbp)
movl -0x1c4(%rbp), %esi
callq 0xea90
movq %rax, -0x1d0(%rbp)
movl $0x0, -0x1d4(%rbp)
movq -0x1d0(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rdi
callq 0x86d0
movq %rax, -0x1e8(%rbp)
movq -0x1e0(%rbp), %rdi
callq 0x8700
movq %rax, -0x1f0(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x8730
testb $0x1, %al
jne 0xf99ab
jmp 0xf9b8c
leaq -0x1e8(%rbp), %rdi
callq 0x8770
movq -0x298(%rbp), %rdi
movq %rax, -0x1f8(%rbp)
movq -0x1d0(%rbp), %rsi
movl -0x1d4(%rbp), %edx
leaq -0x1fc(%rbp), %rcx
callq 0x20760
andb $0x1, %al
movb %al, -0x1fd(%rbp)
testb $0x1, -0x1fd(%rbp)
je 0xf9b6c
movq -0x298(%rbp), %rdi
movl -0x1fc(%rbp), %esi
movq -0x1c0(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x2b1b0
testb $0x1, %al
jne 0xf9a18
jmp 0xf9b6c
movq -0x298(%rbp), %rdi
addq $0x8, %rdi
movl $0x2, %esi
callq 0x55780
movq -0x298(%rbp), %rdi
movl %eax, -0x204(%rbp)
movl -0x204(%rbp), %eax
addl $0x0, %eax
movl %eax, -0x208(%rbp)
movl -0x204(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20c(%rbp)
movl -0x208(%rbp), %eax
movl %eax, -0x2cc(%rbp)
movq -0x1f8(%rbp), %rax
movl (%rax), %esi
callq 0xea90
movl -0x2cc(%rbp), %esi
movq -0x298(%rbp), %rdi
movq %rax, %rdx
callq 0xdeb40
movq %rax, -0x218(%rbp)
movq -0x1f8(%rbp), %rax
movl (%rax), %ecx
movq -0x218(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x1c0(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x218(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x218(%rbp), %rax
movb $0x1, 0x60(%rax)
movq -0x50(%rbp), %rdi
movq -0x1f8(%rbp), %rax
movl (%rax), %esi
movl -0x20c(%rbp), %edx
movl $0x1, %ecx
callq 0x113e10
movq -0x298(%rbp), %rdi
movl -0x20c(%rbp), %esi
movl $0x7, -0x21c(%rbp)
leaq -0x208(%rbp), %rdx
leaq -0x21c(%rbp), %rcx
callq 0xdeb90
movq -0x298(%rbp), %rdi
addq $0x8, %rdi
addq $0x30, %rdi
movl -0x1c4(%rbp), %eax
movl %eax, %esi
callq 0xead0
movq %rax, %rdi
addq $0xd0, %rdi
movl -0x1d4(%rbp), %eax
movl %eax, %esi
callq 0x2fa30
movq -0x298(%rbp), %rdi
movq %rax, -0x2c8(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movl -0x20c(%rbp), %eax
movl %eax, %esi
callq 0xead0
movq -0x2c8(%rbp), %rsi
movq %rax, %rdi
callq 0x38270
movl -0x1d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x8790
jmp 0xf998f
jmp 0xf9d91
movq -0x298(%rbp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movl %esi, -0x2e0(%rbp)
callq 0x55780
movl -0x2e0(%rbp), %ecx
movl %eax, -0x220(%rbp)
movq -0x50(%rbp), %rdi
movl -0x1c4(%rbp), %esi
movl -0x220(%rbp), %edx
callq 0x113e10
movq -0x298(%rbp), %rdi
movl -0x220(%rbp), %esi
movl $0x7, -0x224(%rbp)
movl $0x0, -0x228(%rbp)
leaq -0x1c4(%rbp), %rdx
leaq -0x224(%rbp), %rcx
leaq -0x228(%rbp), %r8
leaq -0x1b4(%rbp), %r9
callq 0x113e70
movq -0x298(%rbp), %rsi
movl -0x2e0(%rbp), %ecx
movl -0x1b4(%rbp), %edx
movl %edx, -0x2dc(%rbp)
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x268(%rbp), %rdi
callq *%rax
leaq -0x289(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x7650
movq -0x2d8(%rbp), %rdx
leaq 0x50f2f(%rip), %rsi     # 0x14ab88
leaq -0x288(%rbp), %rdi
callq 0x7520
jmp 0xf9c67
movq -0x298(%rbp), %rsi
leaq -0x248(%rbp), %rdi
leaq -0x268(%rbp), %rdx
leaq -0x288(%rbp), %rcx
callq 0xf9dc0
jmp 0xf9c8a
movl -0x2dc(%rbp), %esi
movq -0x298(%rbp), %rdi
leaq -0x248(%rbp), %rdx
callq 0x22cd0
jmp 0xf9ca5
leaq -0x248(%rbp), %rdi
callq 0x7708
leaq -0x288(%rbp), %rdi
callq 0x7708
leaq -0x289(%rbp), %rdi
callq 0x73d0
leaq -0x268(%rbp), %rdi
callq 0x7708
movq -0x298(%rbp), %rdi
addq $0x8, %rdi
addq $0x30, %rdi
movl -0x1b4(%rbp), %eax
movl %eax, %esi
callq 0xead0
movq -0x298(%rbp), %rdi
movq %rax, -0x2e8(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movl -0x220(%rbp), %eax
movl %eax, %esi
callq 0xead0
movq -0x2e8(%rbp), %rsi
movq %rax, %rdi
callq 0x381e0
jmp 0xf9d91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xf9d77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
jmp 0xf9d6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x158(%rbp)
movl %eax, -0x15c(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x7708
leaq -0x288(%rbp), %rdi
callq 0x7708
leaq -0x289(%rbp), %rdi
callq 0x73d0
leaq -0x268(%rbp), %rdi
callq 0x7708
jmp 0xf9daf
jmp 0xf9d93
leaq -0x1a8(%rbp), %rdi
callq 0x113ee0
jmp 0xf987d
jmp 0xf9da6
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq -0x158(%rbp), %rdi
callq 0x7640
nopl (%rax,%rax)