#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ execlp(char *, char *, char const *, char *);
scalar_t__ vfork();
int /*<<< orphan*/ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int compile_command(const char *filename) {
  pid_t pid;
  int ret;
  if ((pid = vfork()) < 0)
    die("Unable to fork");
  if (pid == 0) {
    close(STDIN_FILENO);
    execlp("pdflatex", "pdflatex", filename, (char *)NULL);
    _exit(-1);
  } else {
    waitpid(pid, &ret, 0);
  }
  return ret;
}


x86 assembly (clang, -O0):
<compile_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <vfork@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jge    118d <compile_command+0x2d>
lea    0xe78(%rip),%rdi
call   1060 <die@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11c7 <compile_command+0x67>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    -0x8(%rbp),%rdx
lea    0xe5e(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   1080 <execlp@plt>
mov    $0xffffffff,%edi
call   1030 <_exit@plt>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compile_command>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1070 <vfork@plt>
mov    %rax,%rbx
test   %rax,%rax
js     11a4 <compile_command+0x44>
jne    11b0 <compile_command+0x50>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
lea    0xe82(%rip),%rdi
mov    %rdi,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1080 <execlp@plt>
mov    $0xffffffff,%edi
call   1030 <_exit@plt>
lea    0xe55(%rip),%rdi
call   1060 <die@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <waitpid@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Unable to fork\00"
@STDIN_FILENO = global i32 0
@.str.1 = [9 x i8] c"pdflatex\00"
define i32 @compile_command(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i64 (...) @vfork()
store i64 %5, i64* %3
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @die(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load i64, i64* %3
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32, i32* @STDIN_FILENO
%14 = call i32 @close(i32 %13)
%15 = load i8*, i8** %2
%16 = call i32 @execlp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* null)
%17 = call i32 @_exit(i32 -1)
unreachable
18: ; preds = %9
%19 = load i64, i64* %3
%20 = call i32 @waitpid(i64 %19, i32* %4, i32 0)
br label %21
21: ; preds = %18
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [15 x i8] c"Unable to fork\00"
@STDIN_FILENO = global i32 0
@.str.1 = [9 x i8] c"pdflatex\00"
define i32 @compile_command(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i64 (...) @vfork()
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @die(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %15
8: ; preds = %1
%9 = icmp eq i64 %4, 0
br i1 %9, label %10, label %15
10: ; preds = %8
%11 = load i32, i32* @STDIN_FILENO
%12 = tail call i32 @close(i32 %11)
%13 = tail call i32 @execlp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* null)
%14 = tail call i32 @_exit(i32 -1)
unreachable
15: ; preds = %6, %8
%16 = call i32 @waitpid(i64 %4, i32* %2, i32 0)
%17 = load i32, i32* %2
ret i32 %17
}