#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
char *getprogname();
scalar_t__ strcasecmp(char const *, char *);
int xcselect_invoke_xcrun(char const *, int, char const **, int /*<<< orphan*/);
int main(int argc, const char **argv) {
  const char *tool;
  const char *pname = getprogname();
  if (*pname == '/')
    tool = pname + 1;
  else
    tool = pname;
  if (strcasecmp(tool, "xcrun") == 0)
    tool = NULL;
  return xcselect_invoke_xcrun(tool, argc - 1, &argv[1], 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getprogname@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1172 <main+0x42>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117a <main+0x4a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    119c <main+0x6c>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
xor    %ecx,%ecx
call   1050 <xcselect_invoke_xcrun@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <getprogname@plt>
xor    %ebx,%ebx
cmpb   $0x2f,(%rax)
sete   %bl
add    %rax,%rbx
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
cmove  %rax,%rbx
add    $0xffffffff,%ebp
add    $0x8,%r14
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <xcselect_invoke_xcrun@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"xcrun\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* (...) @getprogname()
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 47
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %15, i8** %6
br label %18
16: ; preds = %2
%17 = load i8*, i8** %7
store i8* %17, i8** %6
br label %18
18: ; preds = %16, %13
%19 = load i8*, i8** %6
%20 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* null, i8** %6
br label %23
23: ; preds = %22, %18
%24 = load i8*, i8** %6
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = call i32 @xcselect_invoke_xcrun(i8* %24, i32 %26, i8** %28, i32 0)
ret i32 %29
}

LLVM IR (-O2):
@.str = [6 x i8] c"xcrun\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i8* (...) @getprogname()
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 47
%6 = zext i1 %5 to i64
%7 = getelementptr i8, i8* %3, i64 %6
%8 = tail call i64 @strcasecmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* null, i8* %7
%11 = add nsw i32 %0, -1
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = tail call i32 @xcselect_invoke_xcrun(i8* %10, i32 %11, i8** %12, i32 0)
ret i32 %13
}