// File: /workspace/github_c_makefile_star2_O0/darwin-on-arm[P]darwin-sdk/xcode_tools/xcrun/xcrun.c
// Function: parse_target_triple
static void parse_target_triple(char *triple, const char *ver, const char *arch)
{
	int where = 1;
	bool is_macosx = false;
	int xx, yy, zz, ch, kern_ver;

	if (ver == NULL)
		return;

	/* For now, assume that any x86 target is macOS. */
	if ((strcmp(arch, "x86_64") == 0) || (strcmp(arch, "i386") == 0))
		is_macosx = true;

	xx = yy = zz = 0;

	do {
		ch = (int)*ver;

		switch (ch) {
			case '9':
			case '8':
			case '7':
			case '6':
			case '5':
			case '4':
			case '3':
			case '2':
			case '1':
			case '0':
				{
					switch (where) {
						case 1: /* major */
							xx *= 10;
							xx += (ch - '0');
							break;
						case 2: /* minor */
							yy *= 10;
							yy += (ch - '0');
							break;
						case 3: /* patch */
							zz *= 10;
							zz += (ch - '0');
						default:
							break;
					}
					break;
				}
			case '.':
			default:
				where++;
				break;
		}
	} while (*ver++ != '\0');

	switch (xx) {
		case 11:
			kern_ver = 17;
			break;
		case 10:
			{
				if (is_macosx)
					kern_ver = (yy + 4);
				else
					kern_ver = 16;
				break;
			}
		case 9:
			kern_ver = 15;
			break;
		case 8:
		case 7:
			kern_ver = 14;
			break;
		case 6:
			kern_ver = 13;
			break;
		case 5:
			kern_ver = 11;
			break;
		case 4:
			{
				if (yy <= 2)
					kern_ver = 10;
				else
					kern_ver = 11;
				break;
			}
		case 3:
			kern_ver = 10;
			break;
		case 2:
			kern_ver = 9;
			break;
		case 1:
		default:
			kern_ver = 9;
			break;
	}

	sprintf(triple, "%s-apple-darwin%d", arch, kern_ver);

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movb $0x0, -0x1d(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x462b
jmp 0x47d7
movq -0x18(%rbp), %rdi
leaq 0x1540(%rip), %rsi      # 0x5b76
callq 0x2110
cmpl $0x0, %eax
je 0x4655
movq -0x18(%rbp), %rdi
leaq 0x1532(%rip), %rsi      # 0x5b7d
callq 0x2110
cmpl $0x0, %eax
jne 0x4659
movb $0x1, -0x1d(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
subl $0x2e, %eax
je 0x46f4
jmp 0x4685
movl -0x38(%rbp), %eax
addl $-0x30, %eax
subl $0x9, %eax
ja 0x46f6
jmp 0x4692
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
subl $0x1, %eax
je 0x46b3
jmp 0x469f
movl -0x3c(%rbp), %eax
subl $0x2, %eax
je 0x46c8
jmp 0x46a9
movl -0x3c(%rbp), %eax
subl $0x3, %eax
je 0x46dd
jmp 0x46f0
imull $0xa, -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x30(%rbp), %eax
subl $0x30, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x46f2
imull $0xa, -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x30(%rbp), %eax
subl $0x30, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x46f2
imull $0xa, -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
subl $0x30, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x46f2
jmp 0x46ff
jmp 0x46f6
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x4701
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x466e
movl -0x24(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0xa, %eax
ja 0x47b7
movq -0x48(%rbp), %rax
leaq 0x91d(%rip), %rcx       # 0x5058
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x11, -0x34(%rbp)
jmp 0x47be
testb $0x1, -0x1d(%rbp)
je 0x475e
movl -0x28(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x34(%rbp)
jmp 0x4765
movl $0x10, -0x34(%rbp)
jmp 0x47be
movl $0xf, -0x34(%rbp)
jmp 0x47be
movl $0xe, -0x34(%rbp)
jmp 0x47be
movl $0xd, -0x34(%rbp)
jmp 0x47be
movl $0xb, -0x34(%rbp)
jmp 0x47be
cmpl $0x2, -0x28(%rbp)
jg 0x479a
movl $0xa, -0x34(%rbp)
jmp 0x47a1
movl $0xb, -0x34(%rbp)
jmp 0x47be
movl $0xa, -0x34(%rbp)
jmp 0x47be
movl $0x9, -0x34(%rbp)
jmp 0x47be
jmp 0x47b7
movl $0x9, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl -0x34(%rbp), %ecx
leaq 0x13b2(%rip), %rsi      # 0x5b82
movb $0x0, %al
callq 0x21c0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)