#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*/ known;

/* Variables and functions */
char *detectApplications(char **, size_t);
char *getenv(char *);
char *detectEditors() {
  char *known[] = {NULL,
                   NULL,
                   "nedit",
                   "gedit",
                   "xedit",
                   "textedit",
                   "/Applications/TextWrangler.app/Contents/MacOS/TextWrangler",
                   "/Applications/TextEdit.app/Contents/MacOS/TextEdit",
                   "/Applications/Eclipse.app/Contents/MacOS/eclipse",
                   "/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse",
                   "xemacs",
                   "emacs",
                   "/Applications/Emacs.app/Contents/MacOS/Emacs",
                   "kedit",
                   "gvim",
                   "nano",
                   "pico",
                   "vi"};
  size_t total = sizeof(known) / sizeof(known[0]);
  known[0] = getenv("VISUAL");
  known[1] = getenv("XEDITOR");
  return detectApplications(known, total);
}


x86 assembly (clang, -O0):
<detectEditors>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x90(%rbp),%rdi
lea    0x2c47(%rip),%rsi
mov    $0x90,%edx
call   1050 <memcpy@plt>
movq   $0x12,-0x98(%rbp)
lea    0xfda(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x90(%rbp)
lea    0xfce(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x88(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1040 <detectApplications@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detectEditors>:
push   %rbx
sub    $0x90,%rsp
lea    0x2c51(%rip),%rsi
mov    %rsp,%rbx
mov    $0x90,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
lea    0xfe9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,(%rsp)
lea    0xfe0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x8(%rsp)
mov    $0x12,%esi
mov    %rbx,%rdi
call   1040 <detectApplications@plt>
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"nedit\00"
@.str.1 = [6 x i8] c"gedit\00"
@.str.2 = [6 x i8] c"xedit\00"
@.str.3 = [9 x i8] c"textedit\00"
@.str.4 = [59 x i8] c"/Applications/TextWrangler.app/Contents/MacOS/TextWrangler\00"
@.str.5 = [51 x i8] c"/Applications/TextEdit.app/Contents/MacOS/TextEdit\00"
@.str.6 = [49 x i8] c"/Applications/Eclipse.app/Contents/MacOS/eclipse\00"
@.str.7 = [57 x i8] c"/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse\00"
@.str.8 = [7 x i8] c"xemacs\00"
@.str.9 = [6 x i8] c"emacs\00"
@.str.10 = [45 x i8] c"/Applications/Emacs.app/Contents/MacOS/Emacs\00"
@.str.11 = [6 x i8] c"kedit\00"
@.str.12 = [5 x i8] c"gvim\00"
@.str.13 = [5 x i8] c"nano\00"
@.str.14 = [5 x i8] c"pico\00"
@.str.15 = [3 x i8] c"vi\00"
@__const.detectEditors.known = [18 x i8*] [i8* null, i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i32 0, i32 0)]
@.str.16 = [7 x i8] c"VISUAL\00"
@.str.17 = [8 x i8] c"XEDITOR\00"
define i8* @detectEditors() {
%1 = alloca [18 x i8*]
%2 = alloca i64
%3 = bitcast [18 x i8*]* %1 to i8*
store i64 18, i64* %2
%4 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
%5 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 0
store i8* %4, i8** %5
%6 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0))
%7 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 1
store i8* %6, i8** %7
%8 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 0
%9 = load i64, i64* %2
%10 = call i8* @detectApplications(i8** %8, i64 %9)
ret i8* %10
}

LLVM IR (-O2):
@.str = [6 x i8] c"nedit\00"
@.str.1 = [6 x i8] c"gedit\00"
@.str.2 = [6 x i8] c"xedit\00"
@.str.3 = [9 x i8] c"textedit\00"
@.str.4 = [59 x i8] c"/Applications/TextWrangler.app/Contents/MacOS/TextWrangler\00"
@.str.5 = [51 x i8] c"/Applications/TextEdit.app/Contents/MacOS/TextEdit\00"
@.str.6 = [49 x i8] c"/Applications/Eclipse.app/Contents/MacOS/eclipse\00"
@.str.7 = [57 x i8] c"/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse\00"
@.str.8 = [7 x i8] c"xemacs\00"
@.str.9 = [6 x i8] c"emacs\00"
@.str.10 = [45 x i8] c"/Applications/Emacs.app/Contents/MacOS/Emacs\00"
@.str.11 = [6 x i8] c"kedit\00"
@.str.12 = [5 x i8] c"gvim\00"
@.str.13 = [5 x i8] c"nano\00"
@.str.14 = [5 x i8] c"pico\00"
@.str.15 = [3 x i8] c"vi\00"
@__const.detectEditors.known = [18 x i8*] [i8* null, i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i32 0, i32 0)]
@.str.16 = [7 x i8] c"VISUAL\00"
@.str.17 = [8 x i8] c"XEDITOR\00"
define i8* @detectEditors() {
%1 = alloca [18 x i8*]
%2 = bitcast [18 x i8*]* %1 to i8*
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
%4 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 0
store i8* %3, i8** %4
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0))
%6 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 1
store i8* %5, i8** %6
%7 = call i8* @detectApplications(i8** %4, i64 18)
ret i8* %7
}