// File: /workspace/github_c_makefile_star2_O0/darwin-on-arm[P]darwin-sdk/xcode_tools/xcrun/xcrun.c
// Function: call_command
static int call_command(const char *cmd, int argc, char *argv[])
{
	int i;
	char *envp[8] = { NULL };
	char *target_triple, *deployment_target;

	/*
	 * Pass useful variables to the enviroment of the program to be executed.
	 *
	 *  * SDKROOT is used for when programs such as clang need to know the location of the sdk.
	 *
	 *  * PATH is used for when programs such as clang need to call on another program (such as the linker).
	 *
	 *  * HOME is used for recursive calls to xcrun (such as when xcrun calls a script calling xcrun ect).
	 *
	 *  * LD_LIBRARY_PATH is used for when tools needs to access libraries that are specific to the toolchain.
	 *
	 *  * TARGET_TRIPLE is used for clang/clang++ cross compilation when building on a foreign host.
	 *
	 *  * {MACOSX|IPHONEOS}_DEPLOYMENT_TARGET is used for tools like ld that need to set the minimum compatibility
	 *    version number for a linked binary.
	 *
	 *  * DEVELOPER_DIR is used as a performance optimization when making recursive calls to xcrun.
	 */

	envp[0] = (char *)calloc(PATH_MAX, sizeof(char));
	envp[1] = (char *)calloc(PATH_MAX, sizeof(char));
	envp[2] = (char *)calloc(PATH_MAX, sizeof(char));
	envp[3] = (char *)calloc(PATH_MAX, sizeof(char));
	envp[4] = (char *)calloc(NAME_MAX, sizeof(char));
	envp[5] = (char *)calloc(NAME_MAX, sizeof(char));
	envp[6] = (char *)calloc(PATH_MAX, sizeof(char));

	sprintf(envp[0], "SDKROOT=%s", get_sdk_path(current_sdk));
	sprintf(envp[1], "PATH=%s/usr/bin:%s/usr/bin:%s", developer_dir, get_toolchain_path(current_toolchain), getenv("PATH"));
	sprintf(envp[2], "LD_LIBRARY_PATH=%s/usr/lib", get_toolchain_path(current_toolchain));
	sprintf(envp[3], "HOME=%s", getenv("HOME"));
	sprintf(envp[6], "DEVELOPER_DIR=%s", developer_dir);

	if ((target_triple = get_target_triple(current_sdk)) != NULL)
		sprintf(envp[4], "TARGET_TRIPLE=%s", target_triple);
	else
		fprintf(stderr, "xcrun: warning: failed to retrieve target triple information for %s.sdk.\n", current_sdk);

	if ((deployment_target = getenv("IPHONEOS_DEPLOYMENT_TARGET")) != NULL)
		sprintf(envp[5], "IPHONEOS_DEPLOYMENT_TARGET=%s", deployment_target);
	else if ((deployment_target = getenv("MACOSX_DEPLOYMENT_TARGET")) != NULL)
		sprintf(envp[5], "MACOSX_DEPLOYMENT_TARGET=%s", deployment_target);
	else {
		/* Use the deployment target info that is provided by the SDK. */
		if ((deployment_target = strdup(get_sdk_info(get_sdk_path(current_sdk)).deployment_target)) != NULL) {
			if (macosx_deployment_target_set == 1)
				sprintf(envp[5], "MACOSX_DEPLOYMENT_TARGET=%s", deployment_target);
			else if (ios_deployment_target_set == 1)
				sprintf(envp[5], "IPHONEOS_DEPLOYMENT_TARGET=%s", deployment_target);
		} else {
			fprintf(stderr, "xcrun: error: failed to retrieve deployment target information for %s.sdk.\n", current_sdk);
			return -1;
		}
	}

	if (logging_mode == 1) {
		logging_printf(stdout, "xcrun: info: invoking command:\n\t\"%s", cmd);
		for (i = 1; i < argc; i++)
			logging_printf(stdout, " %s", argv[i]);
		logging_printf(stdout, "\"\n");
	}

	return execve(cmd, argv, envp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x20c0
movl $0x1000, %edi           # imm = 0x1000
movl $0x1, %esi
callq 0x2100
movq %rax, -0x70(%rbp)
movl $0x1000, %edi           # imm = 0x1000
movl $0x1, %esi
callq 0x2100
movq %rax, -0x68(%rbp)
movl $0x1000, %edi           # imm = 0x1000
movl $0x1, %esi
callq 0x2100
movq %rax, -0x60(%rbp)
movl $0x1000, %edi           # imm = 0x1000
movl $0x1, %esi
callq 0x2100
movq %rax, -0x58(%rbp)
movl $0xff, %edi
movl $0x1, %esi
callq 0x2100
movq %rax, -0x50(%rbp)
movl $0xff, %edi
movl $0x1, %esi
callq 0x2100
movq %rax, -0x48(%rbp)
movl $0x1000, %edi           # imm = 0x1000
movl $0x1, %esi
callq 0x2100
movq %rax, -0x40(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq 0x4983(%rip), %rdi      # 0x93c0
callq 0x3ec0
movq -0xd0(%rbp), %rdi
movq %rax, %rdx
leaq 0x121d(%rip), %rsi      # 0x5c70
movb $0x0, %al
callq 0x21c0
movq -0x68(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq 0x5964(%rip), %rdi      # 0xa3d0
callq 0x4040
movq %rax, -0xc0(%rbp)
leaq 0x121a(%rip), %rdi      # 0x5c99
callq 0x2030
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rcx
movq %rax, %r8
leaq 0x11df(%rip), %rsi      # 0x5c7b
leaq 0x38bd(%rip), %rdx      # 0x8360
movb $0x0, %al
callq 0x21c0
movq -0x60(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq 0x5914(%rip), %rdi      # 0xa3d0
callq 0x4040
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
leaq 0x11cc(%rip), %rsi      # 0x5c9e
movb $0x0, %al
callq 0x21c0
movq -0x58(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq 0x6b6(%rip), %rdi       # 0x51a1
callq 0x2030
movq -0xb0(%rbp), %rdi
movq %rax, %rdx
leaq 0x11b8(%rip), %rsi      # 0x5cb9
movb $0x0, %al
callq 0x21c0
movq -0x40(%rbp), %rdi
leaq 0x11ae(%rip), %rsi      # 0x5cc1
leaq 0x3846(%rip), %rdx      # 0x8360
movb $0x0, %al
callq 0x21c0
leaq 0x4898(%rip), %rdi      # 0x93c0
callq 0x41b0
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0x4b4f
movq -0x50(%rbp), %rdi
movq -0x78(%rbp), %rdx
leaq 0x118c(%rip), %rsi      # 0x5cd2
movb $0x0, %al
callq 0x21c0
jmp 0x4b6e
movq 0x34a2(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x1183(%rip), %rsi      # 0x5ce3
leaq 0x4859(%rip), %rdx      # 0x93c0
movb $0x0, %al
callq 0x2120
leaq 0x11b8(%rip), %rdi      # 0x5d2d
callq 0x2030
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0x4b9f
movq -0x48(%rbp), %rdi
movq -0x80(%rbp), %rdx
leaq 0x11b5(%rip), %rsi      # 0x5d48
movb $0x0, %al
callq 0x21c0
jmp 0x4c74
leaq 0x11c0(%rip), %rdi      # 0x5d66
callq 0x2030
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0x4bd0
movq -0x48(%rbp), %rdi
movq -0x80(%rbp), %rdx
leaq 0x11bb(%rip), %rsi      # 0x5d7f
movb $0x0, %al
callq 0x21c0
jmp 0x4c72
leaq 0x47e9(%rip), %rdi      # 0x93c0
callq 0x3ec0
movq %rax, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x3f70
movq -0x88(%rbp), %rdi
callq 0x21e0
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0x4c45
cmpl $0x1, 0x67d0(%rip)      # 0xb3d8
jne 0x4c22
movq -0x48(%rbp), %rdi
movq -0x80(%rbp), %rdx
leaq 0x1166(%rip), %rsi      # 0x5d7f
movb $0x0, %al
callq 0x21c0
jmp 0x4c43
cmpl $0x1, 0x67ab(%rip)      # 0xb3d4
jne 0x4c41
movq -0x48(%rbp), %rdi
movq -0x80(%rbp), %rdx
leaq 0x110e(%rip), %rsi      # 0x5d48
movb $0x0, %al
callq 0x21c0
jmp 0x4c43
jmp 0x4c70
movq 0x33ac(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x1145(%rip), %rsi      # 0x5d9b
leaq 0x4763(%rip), %rdx      # 0x93c0
movb $0x0, %al
callq 0x2120
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4d03
jmp 0x4c72
jmp 0x4c74
cmpl $0x1, 0x46e5(%rip)      # 0x9360
jne 0x4cef
movq 0x3344(%rip), %rax      # 0x7fc8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1155(%rip), %rsi      # 0x5de7
movb $0x0, %al
callq 0x4d10
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x4cd7
movq 0x3319(%rip), %rax      # 0x7fc8
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x1146(%rip), %rsi      # 0x5e0b
movb $0x0, %al
callq 0x4d10
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4ca0
movq 0x32ea(%rip), %rax      # 0x7fc8
movq (%rax), %rdi
leaq 0x1127(%rip), %rsi      # 0x5e0f
movb $0x0, %al
callq 0x4d10
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x20f0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nop