#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*/ close(int);
scalar_t__ pipe(int *);
scalar_t__ ppoll(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *,
                 int /*<<< orphan*/ *);
int test1();
int test2();
int main(void) {
  int rc;
  int fds[2];
  (void)close(0);
  (void)close(1);
  (void)close(3);
  (void)close(4);
  if (pipe(fds) || pipe(fds))
    return 77;
  if ((rc = test1()))
    return rc;
  if ((rc = test2()))
    return rc;
  return ppoll(NULL, 42, NULL, NULL) < 0 ? 0 : 77;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    $0x3,%edi
call   1040 <close@plt>
mov    $0x4,%edi
call   1040 <close@plt>
lea    -0x10(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
jne    11aa <main+0x5a>
lea    -0x10(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0x0,%rax
je     11b6 <main+0x66>
movl   $0x4d,-0x4(%rbp)
jmp    121a <main+0xca>
mov    $0x0,%al
call   1030 <test1@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11d4 <main+0x84>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121a <main+0xca>
mov    $0x0,%al
call   1070 <test2@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11f2 <main+0xa2>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121a <main+0xca>
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x2a,%esi
mov    %rcx,%rdi
mov    %rcx,%rdx
call   1060 <ppoll@plt>
mov    %rax,%rdx
mov    $0x4d,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1040 <close@plt>
mov    $0x1,%edi
call   1040 <close@plt>
mov    $0x3,%edi
call   1040 <close@plt>
mov    $0x4,%edi
call   1040 <close@plt>
mov    %rsp,%rdi
call   1050 <pipe@plt>
mov    $0x4d,%ebx
test   %rax,%rax
jne    11d1 <main+0x81>
mov    %rsp,%rdi
call   1050 <pipe@plt>
test   %rax,%rax
jne    11d1 <main+0x81>
xor    %eax,%eax
call   1030 <test1@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    11d1 <main+0x81>
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <test2@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    11d1 <main+0x81>
xor    %edi,%edi
mov    $0x2a,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1060 <ppoll@plt>
test   %rax,%rax
mov    $0x4d,%ebx
cmovs  %r14d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i32]
store i32 0, i32* %1
%4 = call i32 @close(i32 0)
%5 = call i32 @close(i32 1)
%6 = call i32 @close(i32 3)
%7 = call i32 @close(i32 4)
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%9 = call i64 @pipe(i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%13 = call i64 @pipe(i32* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11, %0
store i32 77, i32* %1
br label %31
16: ; preds = %11
%17 = call i32 (...) @test1()
store i32 %17, i32* %2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i32, i32* %2
store i32 %20, i32* %1
br label %31
21: ; preds = %16
%22 = call i32 (...) @test2()
store i32 %22, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32, i32* %2
store i32 %25, i32* %1
br label %31
26: ; preds = %21
%27 = call i64 @ppoll(i32* null, i32 42, i32* null, i32* null)
%28 = icmp slt i64 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 0, i32 77
store i32 %30, i32* %1
br label %31
31: ; preds = %26, %24, %19, %15
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = tail call i32 @close(i32 0)
%4 = tail call i32 @close(i32 1)
%5 = tail call i32 @close(i32 3)
%6 = tail call i32 @close(i32 4)
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%8 = call i64 @pipe(i32* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %0
%11 = call i64 @pipe(i32* %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = call i32 (...) @test1()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = call i32 (...) @test2()
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i64 @ppoll(i32* null, i32 42, i32* null, i32* null)
%21 = icmp slt i64 %20, 0
%22 = select i1 %21, i32 0, i32 77
br label %23
23: ; preds = %16, %13, %0, %10, %19
%24 = phi i32 [ %22, %19 ], [ 77, %10 ], [ 77, %0 ], [ %14, %13 ], [ %17, %16 ]
ret i32 %24
}