#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*/ execl(char const *, char const *, char const *,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ print_file(char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
void print_file_2(const char *filename, const char *prfcmd) {
  pid_t p;
  print_file(filename);
  if (p = fork()) {
    wait(NULL);
  } else {
    printf("Child -> exec %s\n", prfcmd);
    execl(prfcmd, prfcmd, filename, NULL);
    printf("Child -> exec FAILED\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<print_file_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <print_file@plt>
mov    $0x0,%al
call   1080 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     119a <print_file_2+0x3a>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <wait@plt>
jmp    11d9 <print_file_2+0x79>
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <execl@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_file_2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <print_file@plt>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     1198 <print_file_2+0x28>
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <wait@plt>
lea    0xe61(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1070 <execl@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Child -> exec %s\0A\00"
@.str.1 = [22 x i8] c"Child -> exec FAILED\0A\00"
define void @print_file_2(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @print_file(i8* %6)
%8 = call i32 (...) @fork()
store i32 %8, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @wait(i32* null)
br label %21
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %4
%16 = load i8*, i8** %4
%17 = load i8*, i8** %3
%18 = call i32 @execl(i8* %15, i8* %16, i8* %17, i32* null)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Child -> exec %s\0A\00"
@str = [21 x i8] c"Child -> exec FAILED\00"
define void @print_file_2(i8* %0, i8* %1) {
%3 = tail call i32 @print_file(i8* %0)
%4 = tail call i32 (...) @fork()
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @wait(i32* null)
ret void
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = tail call i32 @execl(i8* %1, i8* %1, i8* %0, i32* null)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
}