#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 *escapeQuotesAndBackslashes(char *);
int /*<<< orphan*/ free(char *);
char *getCommandExecutableName(char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
scalar_t__ strlen(char *);
char *getApplicationCommandLineTemplate(char *cmd, char *known[], char *xterm[],
                                        char *opencmd[], size_t total) {
  size_t i;
  int match;
  char *name;
  char localResult[2048 * 4];
  int isXterm;
  int isOpencmd;
  char *result;
  char *escaped;
  match = -1;
  for (i = 0; i < total; i++) {
    if (strcmp(cmd, known[i]) == 0) {
      match = i;
      break;
    }
  }
  if (match == -1) {
    name = getCommandExecutableName(cmd);
    for (i = 0; i < total; i++) {
      if (strcmp(name, known[i]) == 0) {
        match = i;
        break;
      }
    }
    free(name);
  }
  localResult[0] = '\0';
  if (match != -1) {
    isXterm = 0;
    isOpencmd = 0;
    if (strcmp(xterm[match], "y") == 0) {
      isXterm = 1;
    }
    if (strlen(opencmd[match]) > 0) {
      isOpencmd = 1;
    }
    if (isXterm) {
      strcat(localResult, "xterm -e \"");
    }
    if (isXterm) {
      escaped = escapeQuotesAndBackslashes(cmd);
      strcat(localResult, escaped);
      free(escaped);
    } else {
      if (isOpencmd) {
        if (strcmp(opencmd[match], "Finder") == 0) {
          strcat(localResult, "open -R ");
        } else {
          strcat(localResult, "open -a ");
          strcat(localResult, "\"");
          strcat(localResult, opencmd[match]);
          strcat(localResult, "\"");
        }
      } else {
        strcat(localResult, cmd);
      }
    }
    if (strcmp(known[match], "netscape") == 0) {
      strcat(localResult, " -remote \"openFile(%s)\"");
    } else {
      strcat(localResult, " ");
      if (isXterm) {
        strcat(localResult, "\\\"");
      } else {
        strcat(localResult, "\"");
      }
      strcat(localResult, "%s");
      if (isXterm) {
        strcat(localResult, "\\\"");
      } else {
        strcat(localResult, "\"");
      }
    }
    if (isXterm) {
      strcat(localResult, "\"");
    }
  } else {
    strcat(localResult, cmd);
    strcat(localResult, " \"%s\"");
  }
  result = strdup(localResult);
  return result;
}


x86 assembly (clang, -O0):
<getApplicationCommandLineTemplate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2060,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11ed <getApplicationCommandLineTemplate+0x7d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11d7 <getApplicationCommandLineTemplate+0x67>
mov    -0x30(%rbp),%rax
mov    %eax,-0x34(%rbp)
jmp    11ed <getApplicationCommandLineTemplate+0x7d>
jmp    11dc <getApplicationCommandLineTemplate+0x6c>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    119e <getApplicationCommandLineTemplate+0x2e>
cmpl   $0xffffffff,-0x34(%rbp)
jne    1264 <getApplicationCommandLineTemplate+0xf4>
mov    -0x8(%rbp),%rdi
call   1040 <getCommandExecutableName@plt>
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    125b <getApplicationCommandLineTemplate+0xeb>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1245 <getApplicationCommandLineTemplate+0xd5>
mov    -0x30(%rbp),%rax
mov    %eax,-0x34(%rbp)
jmp    125b <getApplicationCommandLineTemplate+0xeb>
jmp    124a <getApplicationCommandLineTemplate+0xda>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    120c <getApplicationCommandLineTemplate+0x9c>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movb   $0x0,-0x2040(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
je     14e7 <getApplicationCommandLineTemplate+0x377>
movl   $0x0,-0x2044(%rbp)
movl   $0x0,-0x2048(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd64(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12b5 <getApplicationCommandLineTemplate+0x145>
movl   $0x1,-0x2044(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jle    12da <getApplicationCommandLineTemplate+0x16a>
movl   $0x1,-0x2048(%rbp)
cmpl   $0x0,-0x2044(%rbp)
je     12fa <getApplicationCommandLineTemplate+0x18a>
lea    -0x2040(%rbp),%rdi
lea    0xd0d(%rip),%rsi
call   1080 <strcat@plt>
cmpl   $0x0,-0x2044(%rbp)
je     133b <getApplicationCommandLineTemplate+0x1cb>
mov    -0x8(%rbp),%rdi
call   1070 <escapeQuotesAndBackslashes@plt>
mov    %rax,-0x2058(%rbp)
lea    -0x2040(%rbp),%rdi
mov    -0x2058(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x2058(%rbp),%rdi
call   1030 <free@plt>
jmp    13ed <getApplicationCommandLineTemplate+0x27d>
cmpl   $0x0,-0x2048(%rbp)
je     13d8 <getApplicationCommandLineTemplate+0x268>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcb2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1382 <getApplicationCommandLineTemplate+0x212>
lea    -0x2040(%rbp),%rdi
lea    0xc9c(%rip),%rsi
call   1080 <strcat@plt>
jmp    13d3 <getApplicationCommandLineTemplate+0x263>
lea    -0x2040(%rbp),%rdi
lea    0xc8d(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x2040(%rbp),%rdi
lea    0xc68(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x2040(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <strcat@plt>
lea    -0x2040(%rbp),%rdi
lea    0xc3d(%rip),%rsi
call   1080 <strcat@plt>
jmp    13e8 <getApplicationCommandLineTemplate+0x278>
lea    -0x2040(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
jmp    13ed <getApplicationCommandLineTemplate+0x27d>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc26(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1427 <getApplicationCommandLineTemplate+0x2b7>
lea    -0x2040(%rbp),%rdi
lea    0xc12(%rip),%rsi
call   1080 <strcat@plt>
jmp    14c2 <getApplicationCommandLineTemplate+0x352>
lea    -0x2040(%rbp),%rdi
lea    0xbe6(%rip),%rsi
call   1080 <strcat@plt>
cmpl   $0x0,-0x2044(%rbp)
je     145f <getApplicationCommandLineTemplate+0x2ef>
lea    -0x2040(%rbp),%rdi
lea    0xbf2(%rip),%rsi
call   1080 <strcat@plt>
jmp    1472 <getApplicationCommandLineTemplate+0x302>
lea    -0x2040(%rbp),%rdi
lea    0xb9e(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x2040(%rbp),%rdi
lea    0xbca(%rip),%rsi
call   1080 <strcat@plt>
cmpl   $0x0,-0x2044(%rbp)
je     14aa <getApplicationCommandLineTemplate+0x33a>
lea    -0x2040(%rbp),%rdi
lea    0xba7(%rip),%rsi
call   1080 <strcat@plt>
jmp    14bd <getApplicationCommandLineTemplate+0x34d>
lea    -0x2040(%rbp),%rdi
lea    0xb53(%rip),%rsi
call   1080 <strcat@plt>
jmp    14c2 <getApplicationCommandLineTemplate+0x352>
cmpl   $0x0,-0x2044(%rbp)
je     14e2 <getApplicationCommandLineTemplate+0x372>
lea    -0x2040(%rbp),%rdi
lea    0xb2e(%rip),%rsi
call   1080 <strcat@plt>
jmp    150a <getApplicationCommandLineTemplate+0x39a>
lea    -0x2040(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x2040(%rbp),%rdi
lea    0xb48(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x2040(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x2050(%rbp)
mov    -0x2050(%rbp),%rax
add    $0x2060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getApplicationCommandLineTemplate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
mov    %rdi,%r14
test   %r8,%r8
je     11bd <getApplicationCommandLineTemplate+0x4d>
mov    %r8,%rbx
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rcx,0x8(%rsp)
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    0x0(%r13,%rbp,8),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11ca <getApplicationCommandLineTemplate+0x5a>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11a0 <getApplicationCommandLineTemplate+0x30>
jmp    11d9 <getApplicationCommandLineTemplate+0x69>
mov    %r14,%rdi
call   1040 <getCommandExecutableName@plt>
mov    %rax,%r15
jmp    120b <getApplicationCommandLineTemplate+0x9b>
cmp    $0xffffffff,%ebp
je     11d9 <getApplicationCommandLineTemplate+0x69>
movb   $0x0,0x10(%rsp)
jmp    1267 <getApplicationCommandLineTemplate+0xf7>
mov    %r14,%rdi
call   1040 <getCommandExecutableName@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     120b <getApplicationCommandLineTemplate+0x9b>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,8),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1255 <getApplicationCommandLineTemplate+0xe5>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11f0 <getApplicationCommandLineTemplate+0x80>
mov    %r15,%rdi
call   1030 <free@plt>
movb   $0x0,0x10(%rsp)
lea    0xe2e(%rip),%rbx
lea    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
lea    0x10(%rsp),%rdi
call   1090 <strdup@plt>
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   1030 <free@plt>
movb   $0x0,0x10(%rsp)
cmp    $0xffffffff,%ebp
je     1218 <getApplicationCommandLineTemplate+0xa8>
movslq %ebp,%r15
mov    (%r12,%r15,8),%rdi
lea    0xd8b(%rip),%rsi
call   1060 <strcmp@plt>
mov    %rax,%r12
test   %rax,%rax
je     12e9 <getApplicationCommandLineTemplate+0x179>
mov    0x8(%rsp),%rbp
mov    0x0(%rbp,%r15,8),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
jle    131d <getApplicationCommandLineTemplate+0x1ad>
lea    0xd69(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1327 <getApplicationCommandLineTemplate+0x1b7>
lea    0xd65(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xd3f(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    0x0(%rbp,%r15,8),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
jmp    1322 <getApplicationCommandLineTemplate+0x1b2>
lea    0xd12(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
call   1070 <escapeQuotesAndBackslashes@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1080 <strcat@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    1338 <getApplicationCommandLineTemplate+0x1c8>
lea    0x10(%rsp),%rdi
mov    %r14,%rsi
jmp    1333 <getApplicationCommandLineTemplate+0x1c3>
lea    0xce6(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcat@plt>
mov    0x0(%r13,%r15,8),%rdi
lea    0xce2(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1384 <getApplicationCommandLineTemplate+0x214>
lea    0xcc6(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcat@plt>
test   %r12,%r12
je     13aa <getApplicationCommandLineTemplate+0x23a>
lea    0xca0(%rip),%rbx
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
lea    0xccb(%rip),%r14
jmp    121f <getApplicationCommandLineTemplate+0xaf>
lea    0xca4(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcat@plt>
test   %r12,%r12
jne    1239 <getApplicationCommandLineTemplate+0xc9>
lea    0xc66(%rip),%rbx
jmp    122c <getApplicationCommandLineTemplate+0xbc>
lea    0xc96(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
lea    0xc82(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xc34(%rip),%rbx
jmp    121f <getApplicationCommandLineTemplate+0xaf>

LLVM IR (-O0):
@.str = [2 x i8] c"y\00"
@.str.1 = [11 x i8] c"xterm -e \22\00"
@.str.2 = [7 x i8] c"Finder\00"
@.str.3 = [9 x i8] c"open -R \00"
@.str.4 = [9 x i8] c"open -a \00"
@.str.5 = [2 x i8] c"\22\00"
@.str.6 = [9 x i8] c"netscape\00"
@.str.7 = [24 x i8] c" -remote \22openFile(%s)\22\00"
@.str.8 = [2 x i8] c" \00"
@.str.9 = [3 x i8] c"\\\22\00"
@.str.10 = [3 x i8] c"%s\00"
@.str.11 = [6 x i8] c" \22%s\22\00"
define i8* @getApplicationCommandLineTemplate(i8* %0, i8** %1, i8** %2, i8** %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i8*
%14 = alloca [8192 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i8*
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
store i64 %4, i64* %10
store i32 -1, i32* %12
store i64 0, i64* %11
br label %19
19: ; preds = %35, %5
%20 = load i64, i64* %11
%21 = load i64, i64* %10
%22 = icmp ult i64 %20, %21
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load i8*, i8** %6
%25 = load i8**, i8*** %7
%26 = load i64, i64* %11
%27 = getelementptr inbounds i8*, i8** %25, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %24, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = load i64, i64* %11
%33 = trunc i64 %32 to i32
store i32 %33, i32* %12
br label %38
34: ; preds = %23
br label %35
35: ; preds = %34
%36 = load i64, i64* %11
%37 = add i64 %36, 1
store i64 %37, i64* %11
br label %19
38: ; preds = %31, %19
%39 = load i32, i32* %12
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %66
41: ; preds = %38
%42 = load i8*, i8** %6
%43 = call i8* @getCommandExecutableName(i8* %42)
store i8* %43, i8** %13
store i64 0, i64* %11
br label %44
44: ; preds = %60, %41
%45 = load i64, i64* %11
%46 = load i64, i64* %10
%47 = icmp ult i64 %45, %46
br i1 %47, label %48, label %63
48: ; preds = %44
%49 = load i8*, i8** %13
%50 = load i8**, i8*** %7
%51 = load i64, i64* %11
%52 = getelementptr inbounds i8*, i8** %50, i64 %51
%53 = load i8*, i8** %52
%54 = call i64 @strcmp(i8* %49, i8* %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %48
%57 = load i64, i64* %11
%58 = trunc i64 %57 to i32
store i32 %58, i32* %12
br label %63
59: ; preds = %48
br label %60
60: ; preds = %59
%61 = load i64, i64* %11
%62 = add i64 %61, 1
store i64 %62, i64* %11
br label %44
63: ; preds = %56, %44
%64 = load i8*, i8** %13
%65 = call i32 @free(i8* %64)
br label %66
66: ; preds = %63, %38
%67 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
store i8 0, i8* %67
%68 = load i32, i32* %12
%69 = icmp ne i32 %68, -1
br i1 %69, label %70, label %180
70: ; preds = %66
store i32 0, i32* %15
store i32 0, i32* %16
%71 = load i8**, i8*** %8
%72 = load i32, i32* %12
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i64 @strcmp(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %70
store i32 1, i32* %15
br label %79
79: ; preds = %78, %70
%80 = load i8**, i8*** %9
%81 = load i32, i32* %12
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = call i64 @strlen(i8* %84)
%86 = icmp sgt i64 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %79
store i32 1, i32* %16
br label %88
88: ; preds = %87, %79
%89 = load i32, i32* %15
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %88
%92 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%93 = call i32 @strcat(i8* %92, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %94
94: ; preds = %91, %88
%95 = load i32, i32* %15
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %105
97: ; preds = %94
%98 = load i8*, i8** %6
%99 = call i8* @escapeQuotesAndBackslashes(i8* %98)
store i8* %99, i8** %18
%100 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%101 = load i8*, i8** %18
%102 = call i32 @strcat(i8* %100, i8* %101)
%103 = load i8*, i8** %18
%104 = call i32 @free(i8* %103)
br label %139
105: ; preds = %94
%106 = load i32, i32* %16
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %134
108: ; preds = %105
%109 = load i8**, i8*** %9
%110 = load i32, i32* %12
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8*, i8** %109, i64 %111
%113 = load i8*, i8** %112
%114 = call i64 @strcmp(i8* %113, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %119
116: ; preds = %108
%117 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%118 = call i32 @strcat(i8* %117, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %133
119: ; preds = %108
%120 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%121 = call i32 @strcat(i8* %120, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%122 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%123 = call i32 @strcat(i8* %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%124 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%125 = load i8**, i8*** %9
%126 = load i32, i32* %12
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i8*, i8** %125, i64 %127
%129 = load i8*, i8** %128
%130 = call i32 @strcat(i8* %124, i8* %129)
%131 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%132 = call i32 @strcat(i8* %131, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %133
133: ; preds = %119, %116
br label %138
134: ; preds = %105
%135 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%136 = load i8*, i8** %6
%137 = call i32 @strcat(i8* %135, i8* %136)
br label %138
138: ; preds = %134, %133
br label %139
139: ; preds = %138, %97
%140 = load i8**, i8*** %7
%141 = load i32, i32* %12
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i8*, i8** %140, i64 %142
%144 = load i8*, i8** %143
%145 = call i64 @strcmp(i8* %144, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%146 = icmp eq i64 %145, 0
br i1 %146, label %147, label %150
147: ; preds = %139
%148 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%149 = call i32 @strcat(i8* %148, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %173
150: ; preds = %139
%151 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%152 = call i32 @strcat(i8* %151, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%153 = load i32, i32* %15
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %158
155: ; preds = %150
%156 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%157 = call i32 @strcat(i8* %156, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %161
158: ; preds = %150
%159 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%160 = call i32 @strcat(i8* %159, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %161
161: ; preds = %158, %155
%162 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%163 = call i32 @strcat(i8* %162, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%164 = load i32, i32* %15
%165 = icmp ne i32 %164, 0
br i1 %165, label %166, label %169
166: ; preds = %161
%167 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%168 = call i32 @strcat(i8* %167, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %172
169: ; preds = %161
%170 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%171 = call i32 @strcat(i8* %170, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %172
172: ; preds = %169, %166
br label %173
173: ; preds = %172, %147
%174 = load i32, i32* %15
%175 = icmp ne i32 %174, 0
br i1 %175, label %176, label %179
176: ; preds = %173
%177 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%178 = call i32 @strcat(i8* %177, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %179
179: ; preds = %176, %173
br label %186
180: ; preds = %66
%181 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%182 = load i8*, i8** %6
%183 = call i32 @strcat(i8* %181, i8* %182)
%184 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%185 = call i32 @strcat(i8* %184, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
br label %186
186: ; preds = %180, %179
%187 = getelementptr inbounds [8192 x i8], [8192 x i8]* %14, i64 0, i64 0
%188 = call i8* @strdup(i8* %187)
store i8* %188, i8** %17
%189 = load i8*, i8** %17
ret i8* %189
}

LLVM IR (-O2):
@.str = [2 x i8] c"y\00"
@.str.1 = [11 x i8] c"xterm -e \22\00"
@.str.2 = [7 x i8] c"Finder\00"
@.str.3 = [9 x i8] c"open -R \00"
@.str.4 = [9 x i8] c"open -a \00"
@.str.5 = [2 x i8] c"\22\00"
@.str.6 = [9 x i8] c"netscape\00"
@.str.7 = [24 x i8] c" -remote \22openFile(%s)\22\00"
@.str.8 = [2 x i8] c" \00"
@.str.9 = [3 x i8] c"\\\22\00"
@.str.10 = [3 x i8] c"%s\00"
@.str.11 = [6 x i8] c" \22%s\22\00"
define noalias i8* @getApplicationCommandLineTemplate(i8* %0, i8** nocapture %1, i8** nocapture %2, i8** nocapture %3, i64 %4) {
%6 = alloca [8192 x i8]
%7 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%8 = icmp eq i64 %4, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i8* @getCommandExecutableName(i8* %0)
br label %26
11: ; preds = %5, %17
%12 = phi i64 [ %18, %17 ], [ 0, %5 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %0, i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = add nuw i64 %12, 1
%19 = icmp eq i64 %18, %4
br i1 %19, label %24, label %11
20: ; preds = %11
%21 = trunc i64 %12 to i32
%22 = icmp eq i32 %21, -1
br i1 %22, label %24, label %23
23: ; preds = %20
store i8 0, i8* %7
br label %42
24: ; preds = %17, %20
%25 = tail call i8* @getCommandExecutableName(i8* %0)
br i1 %8, label %26, label %29
26: ; preds = %35, %9, %24
%27 = phi i8* [ %10, %9 ], [ %25, %24 ], [ %25, %35 ]
%28 = tail call i32 @free(i8* %27)
store i8 0, i8* %7
br label %87
29: ; preds = %24, %35
%30 = phi i64 [ %36, %35 ], [ 0, %24 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = tail call i64 @strcmp(i8* %25, i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %29
%36 = add nuw i64 %30, 1
%37 = icmp eq i64 %36, %4
br i1 %37, label %26, label %29
38: ; preds = %29
%39 = trunc i64 %30 to i32
%40 = tail call i32 @free(i8* %25)
store i8 0, i8* %7
%41 = icmp eq i32 %39, -1
br i1 %41, label %87, label %42
42: ; preds = %23, %38
%43 = phi i64 [ %12, %23 ], [ %30, %38 ]
%44 = shl i64 %43, 32
%45 = ashr exact i64 %44, 32
%46 = getelementptr inbounds i8*, i8** %2, i64 %45
%47 = load i8*, i8** %46
%48 = tail call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
%50 = getelementptr inbounds i8*, i8** %3, i64 %45
%51 = load i8*, i8** %50
br i1 %49, label %52, label %57
52: ; preds = %42
%53 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%54 = call i8* @escapeQuotesAndBackslashes(i8* %0)
%55 = call i32 @strcat(i8* %7, i8* %54)
%56 = call i32 @free(i8* %54)
br label %73
57: ; preds = %42
%58 = tail call i64 @strlen(i8* dereferenceable(1) %51)
%59 = icmp sgt i64 %58, 0
br i1 %59, label %60, label %71
60: ; preds = %57
%61 = tail call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %73
65: ; preds = %60
%66 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%67 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%68 = load i8*, i8** %50
%69 = call i32 @strcat(i8* %7, i8* %68)
%70 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %73
71: ; preds = %57
%72 = call i32 @strcat(i8* %7, i8* %0)
br label %73
73: ; preds = %71, %65, %63, %52
%74 = getelementptr inbounds i8*, i8** %1, i64 %45
%75 = load i8*, i8** %74
%76 = call i64 @strcmp(i8* %75, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %85, label %78
78: ; preds = %73
%79 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br i1 %49, label %80, label %83
80: ; preds = %78
%81 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%82 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
br label %87
83: ; preds = %78
%84 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %87
85: ; preds = %73
%86 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br i1 %49, label %91, label %94
87: ; preds = %38, %26, %83, %80
%88 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), %80 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), %83 ], [ %0, %26 ], [ %0, %38 ]
%89 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %80 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %83 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), %26 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), %38 ]
%90 = call i32 @strcat(i8* %7, i8* %88)
br label %91
91: ; preds = %87, %85
%92 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %85 ], [ %89, %87 ]
%93 = call i32 @strcat(i8* %7, i8* %92)
br label %94
94: ; preds = %91, %85
%95 = call i8* @strdup(i8* %7)
ret i8* %95
}