#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 */
struct pollfd {
  int fd;
  scalar_t__ revents;
  int /*<<< orphan*/ events;
};

/* Variables and functions */
int /*<<< orphan*/ POLLIN;
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ poll(struct pollfd *, int, int);
void looper() {
  int fd[2];
  struct pollfd fds[1];
  pipe(fd);
  fds[0].fd = fd[0];
  fds[0].events = POLLIN;
  for (;;) {
    fds[0].revents = 0;
    poll(fds, 1, -1);
  }
}


x86 assembly (clang, -O0):
<looper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
call   1030 <pipe@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1040 <poll@plt>
jmp    1143 <looper+0x23>

x86 assembly (clang, -O2):
<looper>:
push   %rbx
sub    $0x30,%rsp
lea    0x8(%rsp),%rdi
call   1030 <pipe@plt>
mov    0x8(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
lea    0x10(%rsp),%rbx
nopl   0x0(%rax)
movq   $0x0,0x18(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xffffffff,%edx
call   1040 <poll@plt>
jmp    1150 <looper+0x30>

LLVM IR (-O0):
%struct.pollfd = type { i32, i64, i32 }
@POLLIN = global i32 0
define void @looper() {
%1 = alloca [2 x i32]
%2 = alloca [1 x %struct.pollfd]
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%4 = call i32 @pipe(i32* %3)
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%6 = load i32, i32* %5
%7 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0
%8 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %7, i32 0, i32 0
store i32 %6, i32* %8
%9 = load i32, i32* @POLLIN
%10 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0
%11 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %10, i32 0, i32 2
store i32 %9, i32* %11
br label %12
12: ; preds = %12, %0
%13 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0
%14 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i32 0, i32 1
store i64 0, i64* %14
%15 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0
%16 = call i32 @poll(%struct.pollfd* %15, i32 1, i32 -1)
br label %12
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i64, i32 }
@POLLIN = global i32 0
define void @looper() {
%1 = alloca [2 x i32]
%2 = alloca [1 x %struct.pollfd]
%3 = bitcast [2 x i32]* %1 to i8*
%4 = bitcast [1 x %struct.pollfd]* %2 to i8*
%5 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%6 = call i32 @pipe(i32* %5)
%7 = load i32, i32* %5
%8 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0
%9 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0, i32 0
store i32 %7, i32* %9
%10 = load i32, i32* @POLLIN
%11 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0, i32 2
store i32 %10, i32* %11
%12 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %2, i64 0, i64 0, i32 1
br label %13
13: ; preds = %13, %0
store i64 0, i64* %12
%14 = call i32 @poll(%struct.pollfd* %8, i32 1, i32 -1)
br label %13
}