#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*/ add_filter(char *const *, int, int *, int);
int /*<<< orphan*/ error(char *);
int pipe(int *);
void first_filter(char *const *args, int *fdin, int *fdout) {
  int filter_input[2];
  int res;
  res = pipe(filter_input);
  if (res == -1)
    error("Error making pipe");
  *fdin = filter_input[1];
  add_filter(args, filter_input[0], fdout, *fdin);
}


x86 assembly (clang, -O0):
<first_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <pipe@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1166 <first_filter+0x36>
lea    0xe9f(%rip),%rdi
call   1050 <error@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
call   1040 <add_filter@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first_filter>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x8(%rsp),%rdi
call   1030 <pipe@plt>
cmp    $0xffffffff,%eax
jne    115d <first_filter+0x2d>
lea    0xea8(%rip),%rdi
call   1050 <error@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,(%rbx)
mov    0x8(%rsp),%esi
mov    %r15,%rdi
mov    %r14,%rdx
call   1040 <add_filter@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Error making pipe\00"
define void @first_filter(i8** %0, i32* %1, i32* %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [2 x i32]
%8 = alloca i32
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%10 = call i32 @pipe(i32* %9)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %3
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%17 = load i32, i32* %16
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%21 = load i32, i32* %20
%22 = load i32*, i32** %6
%23 = load i32*, i32** %5
%24 = load i32, i32* %23
%25 = call i32 @add_filter(i8** %19, i32 %21, i32* %22, i32 %24)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Error making pipe\00"
define void @first_filter(i8** %0, i32* nocapture writeonly %1, i32* %2) {
%4 = alloca [2 x i32]
%5 = bitcast [2 x i32]* %4 to i8*
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%7 = call i32 @pipe(i32* %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %3
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%13 = load i32, i32* %12
store i32 %13, i32* %1
%14 = load i32, i32* %6
%15 = call i32 @add_filter(i8** %0, i32 %14, i32* %2, i32 %13)
ret void
}