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

/* Variables and functions */
int /*<<< orphan*/ create_file(char *, int /*<<< orphan*/);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errx(int, char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char *funct, *bin_path;
  pid_t child;
  if (argc != 2)
    errx(1, "need the path to generation binaries");
  bin_path = argv[1];
  funct = malloc(strlen(bin_path) + 16);
  if (funct == NULL)
    err(1, "malloc failed");
  sprintf(funct, "%s/genj0", bin_path);
  child = create_file(funct, 0);
  waitpid(child, NULL, 0);
  sprintf(funct, "%s/genj1", bin_path);
  child = create_file(funct, 0);
  waitpid(child, NULL, 0);
  sprintf(funct, "%s/geny0", bin_path);
  child = create_file(funct, 0);
  waitpid(child, NULL, 0);
  sprintf(funct, "%s/geny1", bin_path);
  child = create_file(funct, 0);
  waitpid(child, NULL, 0);
  sprintf(funct, "%s/genlgamma", bin_path);
  child = create_file(funct, 0);
  waitpid(child, NULL, 0);
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     11a1 <main+0x31>
mov    $0x1,%edi
lea    0xe64(%rip),%rsi
call   1040 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x10,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e2 <main+0x72>
mov    $0x1,%edi
lea    0xe48(%rip),%rsi
call   1050 <err@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe1b(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdf4(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xdcd(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xda6(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
je     118d <main+0x1d>
lea    0xe7d(%rip),%rsi
mov    $0x1,%edi
call   1040 <errx@plt>
mov    0x8(%rbx),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x10(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11bb <main+0x4b>
lea    0xe74(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
lea    0xdf9(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <create_file@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <waitpid@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"need the path to generation binaries\00"
@.str.1 = [14 x i8] c"malloc failed\00"
@.str.2 = [9 x i8] c"%s/genj0\00"
@.str.3 = [9 x i8] c"%s/genj1\00"
@.str.4 = [9 x i8] c"%s/geny0\00"
@.str.5 = [9 x i8] c"%s/geny1\00"
@.str.6 = [13 x i8] c"%s/genlgamma\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @errx(i32 1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i64 @strlen(i8* %17)
%19 = add nsw i64 %18, 16
%20 = call i8* @malloc(i64 %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = call i32 @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %13
%26 = load i8*, i8** %6
%27 = load i8*, i8** %7
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %6
%30 = call i32 @create_file(i8* %29, i32 0)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = call i32 @waitpid(i32 %31, i32* null, i32 0)
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %6
%37 = call i32 @create_file(i8* %36, i32 0)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = call i32 @waitpid(i32 %38, i32* null, i32 0)
%40 = load i8*, i8** %6
%41 = load i8*, i8** %7
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %6
%44 = call i32 @create_file(i8* %43, i32 0)
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = call i32 @waitpid(i32 %45, i32* null, i32 0)
%47 = load i8*, i8** %6
%48 = load i8*, i8** %7
%49 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %6
%51 = call i32 @create_file(i8* %50, i32 0)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = call i32 @waitpid(i32 %52, i32* null, i32 0)
%54 = load i8*, i8** %6
%55 = load i8*, i8** %7
%56 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = load i8*, i8** %6
%58 = call i32 @create_file(i8* %57, i32 0)
store i32 %58, i32* %8
%59 = load i32, i32* %8
%60 = call i32 @waitpid(i32 %59, i32* null, i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"need the path to generation binaries\00"
@.str.1 = [14 x i8] c"malloc failed\00"
@.str.2 = [9 x i8] c"%s/genj0\00"
@.str.3 = [9 x i8] c"%s/genj1\00"
@.str.4 = [9 x i8] c"%s/geny0\00"
@.str.5 = [9 x i8] c"%s/geny1\00"
@.str.6 = [13 x i8] c"%s/genlgamma\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%10 = add nsw i64 %9, 16
%11 = tail call i8* @malloc(i64 %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %6
%16 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%17 = tail call i32 @create_file(i8* %11, i32 0)
%18 = tail call i32 @waitpid(i32 %17, i32* null, i32 0)
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%20 = tail call i32 @create_file(i8* %11, i32 0)
%21 = tail call i32 @waitpid(i32 %20, i32* null, i32 0)
%22 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%23 = tail call i32 @create_file(i8* %11, i32 0)
%24 = tail call i32 @waitpid(i32 %23, i32* null, i32 0)
%25 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%26 = tail call i32 @create_file(i8* %11, i32 0)
%27 = tail call i32 @waitpid(i32 %26, i32* null, i32 0)
%28 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%29 = tail call i32 @create_file(i8* %11, i32 0)
%30 = tail call i32 @waitpid(i32 %29, i32* null, i32 0)
ret i32 0
}