#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
char *read_file_into_string(char *);
int /*<<< orphan*/ runvfm(char *, char *, char *, char **, char **, char *,
                          char *);
int main(int argc, char *argv[]) {
  char *libf = read_file_into_string("./src64/jonesforth64.f");
  if (NULL == libf) {
    printf("Aborting: no lib.f file\n");
    exit(-1);
  }
  char *args[] = {"forth64", "asd", "qwe", NULL};
  char *envp[] = {"USER=test", "HOME=/home/test", NULL};
  runvfm("./forth64", libf, ": ALFA .\" ᚜do-beta-gamma᚛\" CR ;\n", args, envp,
         "ALFA\n", "hash");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1050 <read_file_into_string@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1188 <main+0x48>
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    0x2c51(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c4e(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c4b(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c48(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c45(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c42(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c3f(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x40(%rbp),%rcx
lea    -0x60(%rbp),%r8
lea    0xe6a(%rip),%rdi
lea    0xe6d(%rip),%rdx
lea    0xe8b(%rip),%r9
lea    0xe8a(%rip),%rax
mov    %rax,(%rsp)
call   1030 <runvfm@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
lea    0xeb5(%rip),%rdi
call   1050 <read_file_into_string@plt>
test   %rax,%rax
je     11be <main+0x7e>
movaps 0x2c94(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c78(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0x2c9c(%rip),%rcx
mov    %rcx,0x20(%rsp)
movaps 0x2c80(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xee2(%rip),%rcx
mov    %rcx,(%rsp)
lea    0xea2(%rip),%rdi
lea    0xea5(%rip),%rdx
lea    0xec3(%rip),%r9
lea    0x30(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rax,%rsi
call   1040 <runvfm@plt>
xor    %eax,%eax
add    $0x58,%rsp
ret
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"./src64/jonesforth64.f\00"
@.str.1 = [25 x i8] c"Aborting: no lib.f file\0A\00"
@.str.2 = [8 x i8] c"forth64\00"
@.str.3 = [4 x i8] c"asd\00"
@.str.4 = [4 x i8] c"qwe\00"
@__const.main.args = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str.5 = [10 x i8] c"USER=test\00"
@.str.6 = [16 x i8] c"HOME=/home/test\00"
@__const.main.envp = [3 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i32 0, i32 0), i8* null]
@.str.7 = [10 x i8] c"./forth64\00"
@.str.8 = [37 x i8] c": ALFA .\22 \E1\9A\9Cdo-beta-gamma\E1\9A\9B\22 CR ;\0A\00"
@.str.9 = [6 x i8] c"ALFA\0A\00"
@.str.10 = [5 x i8] c"hash\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [4 x i8*]
%8 = alloca [3 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i8* @read_file_into_string(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* null, %10
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = bitcast [4 x i8*]* %7 to i8*
%17 = bitcast [3 x i8*]* %8 to i8*
%18 = load i8*, i8** %6
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%20 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%21 = call i32 @runvfm(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8** %19, i8** %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"./src64/jonesforth64.f\00"
@.str.2 = [8 x i8] c"forth64\00"
@.str.3 = [4 x i8] c"asd\00"
@.str.4 = [4 x i8] c"qwe\00"
@__const.main.args = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* null]
@.str.5 = [10 x i8] c"USER=test\00"
@.str.6 = [16 x i8] c"HOME=/home/test\00"
@__const.main.envp = [3 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i32 0, i32 0), i8* null]
@.str.7 = [10 x i8] c"./forth64\00"
@.str.8 = [37 x i8] c": ALFA .\22 \E1\9A\9Cdo-beta-gamma\E1\9A\9B\22 CR ;\0A\00"
@.str.9 = [6 x i8] c"ALFA\0A\00"
@.str.10 = [5 x i8] c"hash\00"
@str = [24 x i8] c"Aborting: no lib.f file\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i8*]
%4 = alloca [3 x i8*]
%5 = tail call i8* @read_file_into_string(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = bitcast [4 x i8*]* %3 to i8*
%12 = bitcast [3 x i8*]* %4 to i8*
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%14 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%15 = call i32 @runvfm(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8** %13, i8** %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}