#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 */
typedef int /*<<< orphan*/ python_path;
typedef int /*<<< orphan*/ argv;

/* Variables and functions */
int PATH_MAX;
char *dirname(char *);
int execv(char *, char **);
int /*<<< orphan*/ memcpy(char **, char **, int);
char *realpath(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int main(int argc, char *argv[]) {
  char python_path[PATH_MAX];
  char *new_argv[4 + argc];
  char *app_dir;
  app_dir = realpath(argv[0], NULL);
  app_dir = dirname(dirname(app_dir));
  snprintf(python_path, sizeof(python_path),
           "%s/Frameworks/Python.framework/Versions/Current/bin/python",
           app_dir);
  new_argv[0] = python_path;
  new_argv[1] = "-s";
  new_argv[2] = "-m";
  new_argv[3] = "plover.dist_main";
  memcpy(new_argv + 4, argv + 1, argc * sizeof(argv[0]));
  return execv(new_argv[0], new_argv);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x4,%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <realpath@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <dirname@plt>
mov    %rax,%rdi
call   1040 <dirname@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,-0x30(%rbp)
mov    %eax,%esi
mov    -0x30(%rbp),%rcx
lea    0xe06(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %rax,(%rdi)
lea    0xe2a(%rip),%rax
mov    %rax,0x8(%rdi)
lea    0xe22(%rip),%rax
mov    %rax,0x10(%rdi)
lea    0xe1a(%rip),%rax
mov    %rax,0x18(%rdi)
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rsi
mov    (%rsi),%rdi
call   1070 <execv@plt>
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x30(%rbp)
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    0x4(%r14),%eax
mov    %rsp,%rbx
mov    %rbx,-0x38(%rbp)
lea    0xf(,%rax,8),%r12
and    $0xfffffffffffffff0,%r12
sub    %r12,%rbx
mov    %rbx,%rsp
neg    %r12
mov    (%rsi),%rdi
xor    %esi,%esi
call   1050 <realpath@plt>
mov    %rax,%rdi
call   1040 <dirname@plt>
mov    %rax,%rdi
call   1040 <dirname@plt>
lea    0xe3a(%rip),%rdx
mov    %r13,%rdi
mov    -0x30(%rbp),%rsi
mov    %rax,%rcx
call   1030 <snprintf@plt>
mov    %r13,(%rbx)
lea    0xe5c(%rip),%rax
mov    %rax,0x8(%rbx)
lea    0xe54(%rip),%rax
mov    %rax,0x10(%rbx)
lea    0xe4c(%rip),%rax
mov    %rax,0x18(%rbx)
lea    0x20(%rbx),%rdi
add    $0x8,%r15
shl    $0x3,%r14d
mov    %r15,%rsi
mov    %r14d,%edx
call   1060 <memcpy@plt>
mov    -0x38(%rbp),%rax
mov    (%rax,%r12,1),%rdi
mov    %rbx,%rsi
call   1070 <execv@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [59 x i8] c"%s/Frameworks/Python.framework/Versions/Current/bin/python\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"-m\00"
@.str.3 = [17 x i8] c"plover.dist_main\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @PATH_MAX
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i8, i64 %11
store i64 %11, i64* %7
%14 = load i32, i32* %4
%15 = add nsw i32 4, %14
%16 = zext i32 %15 to i64
%17 = alloca i8*, i64 %16
store i64 %16, i64* %8
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i8* @realpath(i8* %20, i32* null)
store i8* %21, i8** %9
%22 = load i8*, i8** %9
%23 = call i8* @dirname(i8* %22)
%24 = call i8* @dirname(i8* %23)
store i8* %24, i8** %9
%25 = trunc i64 %11 to i32
%26 = load i8*, i8** %9
%27 = call i32 @snprintf(i8* %13, i32 %25, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds i8*, i8** %17, i64 0
store i8* %13, i8** %28
%29 = getelementptr inbounds i8*, i8** %17, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds i8*, i8** %17, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %30
%31 = getelementptr inbounds i8*, i8** %17, i64 3
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %31
%32 = getelementptr inbounds i8*, i8** %17, i64 4
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 8
%38 = trunc i64 %37 to i32
%39 = call i32 @memcpy(i8** %32, i8** %34, i32 %38)
%40 = getelementptr inbounds i8*, i8** %17, i64 0
%41 = load i8*, i8** %40
%42 = call i32 @execv(i8* %41, i8** %17)
store i32 %42, i32* %3
%43 = load i8*, i8** %6
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [59 x i8] c"%s/Frameworks/Python.framework/Versions/Current/bin/python\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [3 x i8] c"-m\00"
@.str.3 = [17 x i8] c"plover.dist_main\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = add nsw i32 %0, 4
%7 = zext i32 %6 to i64
%8 = alloca i8*, i64 %7
%9 = load i8*, i8** %1
%10 = tail call i8* @realpath(i8* %9, i32* null)
%11 = tail call i8* @dirname(i8* %10)
%12 = tail call i8* @dirname(i8* %11)
%13 = call i32 @snprintf(i8* %5, i32 %3, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %12)
store i8* %5, i8** %8
%14 = getelementptr inbounds i8*, i8** %8, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds i8*, i8** %8, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds i8*, i8** %8, i64 3
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds i8*, i8** %8, i64 4
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = shl i32 %0, 3
%20 = call i32 @memcpy(i8** %17, i8** %18, i32 %19)
%21 = load i8*, i8** %8
%22 = call i32 @execv(i8* %21, i8** %8)
ret i32 %22
}