#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 */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char *getExecutablePath();
scalar_t__ getenv(char *);
char *mkString(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run(char *, int, char **, int, char **);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  char *binDir;
  char *exePath;
  char *preArgv[1];
  if (getenv("_")) {
    printf("WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells "
           "(cygwin-bash, in particular)\n");
    printf("         doesn't handle Ctrl-C well; use the 'ghcii.sh' shell "
           "wrapper instead\n");
    fflush(stdout);
  }
  binDir = getExecutablePath();
  exePath = mkString("%s/ghc.exe", binDir);
  preArgv[0] = "--interactive";
  run(exePath, 1, preArgv, argc - 1, argv + 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     11b2 <main+0x52>
lea    0xe6f(%rip),%rdi
call   1060 <printf@plt>
lea    0xeba(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x0,%al
call   1040 <getExecutablePath@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xee0(%rip),%rdi
call   1080 <mkString@plt>
mov    %rax,-0x20(%rbp)
lea    0xedb(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%r8
add    $0x8,%r8
mov    $0x1,%esi
call   1050 <run@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe91(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     119f <main+0x3f>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
lea    0xee5(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   1050 <getExecutablePath@plt>
lea    0xe55(%rip),%rdi
mov    %rax,%rsi
call   1080 <mkString@plt>
lea    0xe51(%rip),%rcx
mov    %rcx,(%rsp)
add    $0xffffffff,%ebp
add    $0x8,%rbx
mov    %rsp,%rdx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebp,%ecx
mov    %rbx,%r8
call   1060 <run@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"_\00"
@.str.1 = [87 x i8] c"WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells (cygwin-bash, in particular)\0A\00"
@.str.2 = [79 x i8] c" doesn't handle Ctrl-C well; use the 'ghcii.sh' shell wrapper instead\0A\00"
@stdout = global i32 0
@.str.3 = [11 x i8] c"%s/ghc.exe\00"
@.str.4 = [14 x i8] c"--interactive\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [1 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 @getenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
br label %16
16: ; preds = %11, %2
%17 = call i8* (...) @getExecutablePath()
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i8* @mkString(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %18)
store i8* %19, i8** %7
%20 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %20
%21 = load i8*, i8** %7
%22 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = call i32 @run(i8* %21, i32 1, i8** %22, i32 %24, i8** %26)
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"_\00"
@stdout = global i32 0
@.str.3 = [11 x i8] c"%s/ghc.exe\00"
@.str.4 = [14 x i8] c"--interactive\00"
@str = [86 x i8] c"WARNING: GHCi invoked via 'ghci.exe' in *nix-like shells (cygwin-bash, in particular)\00"
@str.5 = [78 x i8] c" doesn't handle Ctrl-C well; use the 'ghcii.sh' shell wrapper instead\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1 x i8*]
%4 = bitcast [1 x i8*]* %3 to i8*
%5 = tail call i64 @getenv(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.5, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = tail call i32 @fflush(i32 %10)
br label %12
12: ; preds = %7, %2
%13 = tail call i8* (...) @getExecutablePath()
%14 = tail call i8* @mkString(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [1 x i8*], [1 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %15
%16 = add nsw i32 %0, -1
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = call i32 @run(i8* %14, i32 1, i8** %15, i32 %16, i8** %17)
ret i32 0
}