#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 EXIT_FAILURE;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int dup2(int, int /*<<< orphan*/);
int execlp(char *, char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int execute_child1(int *pipefd1, int *pipefd2) {
  (void)close(pipefd1[1]);
  (void)close(pipefd2[0]);
  if (dup2(pipefd1[0], STDIN_FILENO) == -1) {
    (void)fprintf(stderr, "Error while executing dup2()!\n");
    return EXIT_FAILURE;
  }
  (void)close(pipefd1[0]);
  if (dup2(pipefd2[1], STDOUT_FILENO) == -1) {
    (void)fprintf(stderr, "Error while executing dup2()!\n");
    return EXIT_FAILURE;
  }
  (void)close(pipefd2[1]);
  if (execlp("gzip", "gzip", "-cf", (char *)NULL) == -1) {
    (void)fprintf(stderr, "Error while executing execlp()!\n");
    return EXIT_FAILURE;
  }
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<execute_child1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    11aa <execute_child1+0x6a>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125a <execute_child1+0x11a>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    11f9 <execute_child1+0xb9>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125a <execute_child1+0x11a>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <close@plt>
lea    0xe13(%rip),%rsi
lea    0xe11(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   1060 <execlp@plt>
cmp    $0xffffffff,%eax
jne    124e <execute_child1+0x10e>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    0xdf0(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125a <execute_child1+0x11a>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_child1>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x4(%rdi),%edi
call   1040 <close@plt>
mov    (%r15),%edi
call   1040 <close@plt>
mov    (%rbx),%edi
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
lea    0xe8e(%rip),%r14
cmp    $0xffffffff,%eax
je     11c2 <execute_child1+0x82>
mov    (%rbx),%edi
call   1040 <close@plt>
mov    0x4(%r15),%edi
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
je     11c2 <execute_child1+0x82>
mov    0x4(%r15),%edi
call   1040 <close@plt>
lea    0xe7a(%rip),%rdi
lea    0xe78(%rip),%rdx
mov    %rdi,%rsi
xor    %ecx,%ecx
call   1060 <execlp@plt>
cmp    $0xffffffff,%eax
jne    11d3 <execute_child1+0x93>
lea    0xe66(%rip),%r14
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Error while executing dup2()!\0A\00"
@EXIT_FAILURE = global i32 0
@STDOUT_FILENO = global i32 0
@.str.1 = [5 x i8] c"gzip\00"
@.str.2 = [4 x i8] c"-cf\00"
@.str.3 = [33 x i8] c"Error while executing execlp()!\0A\00"
define i32 @execute_child1(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
%6 = load i32*, i32** %4
%7 = getelementptr inbounds i32, i32* %6, i64 1
%8 = load i32, i32* %7
%9 = call i32 @close(i32 %8)
%10 = load i32*, i32** %5
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = call i32 @close(i32 %12)
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 0
%16 = load i32, i32* %15
%17 = load i32, i32* @STDIN_FILENO
%18 = call i32 @dup2(i32 %16, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %52
24: ; preds = %2
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 0
%27 = load i32, i32* %26
%28 = call i32 @close(i32 %27)
%29 = load i32*, i32** %5
%30 = getelementptr inbounds i32, i32* %29, i64 1
%31 = load i32, i32* %30
%32 = load i32, i32* @STDOUT_FILENO
%33 = call i32 @dup2(i32 %31, i32 %32)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %39
35: ; preds = %24
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
store i32 %38, i32* %3
br label %52
39: ; preds = %24
%40 = load i32*, i32** %5
%41 = getelementptr inbounds i32, i32* %40, i64 1
%42 = load i32, i32* %41
%43 = call i32 @close(i32 %42)
%44 = call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* null)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %50
46: ; preds = %39
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %3
br label %52
50: ; preds = %39
%51 = load i32, i32* @EXIT_FAILURE
store i32 %51, i32* %3
br label %52
52: ; preds = %50, %46, %35, %20
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Error while executing dup2()!\0A\00"
@EXIT_FAILURE = global i32 0
@STDOUT_FILENO = global i32 0
@.str.1 = [5 x i8] c"gzip\00"
@.str.2 = [4 x i8] c"-cf\00"
@.str.3 = [33 x i8] c"Error while executing execlp()!\0A\00"
define i32 @execute_child1(i32* nocapture %0, i32* nocapture %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = load i32, i32* %3
%5 = tail call i32 @close(i32 %4)
%6 = load i32, i32* %1
%7 = tail call i32 @close(i32 %6)
%8 = load i32, i32* %0
%9 = load i32, i32* @STDIN_FILENO
%10 = tail call i32 @dup2(i32 %8, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %25, label %12
12: ; preds = %2
%13 = load i32, i32* %0
%14 = tail call i32 @close(i32 %13)
%15 = getelementptr inbounds i32, i32* %1, i64 1
%16 = load i32, i32* %15
%17 = load i32, i32* @STDOUT_FILENO
%18 = tail call i32 @dup2(i32 %16, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %25, label %20
20: ; preds = %12
%21 = load i32, i32* %15
%22 = tail call i32 @close(i32 %21)
%23 = tail call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* null)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %29
25: ; preds = %20, %12, %2
%26 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), %12 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), %20 ]
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* %26)
br label %29
29: ; preds = %25, %20
%30 = load i32, i32* @EXIT_FAILURE
ret i32 %30
}