#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 /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ POLLIN;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int poll(struct pollfd *, int, int /*<<< orphan*/);
int file_stdin_poll_in_(void) {
  struct pollfd fd = {0, POLLIN, 0};
  int res = poll(&fd, 1, 0);
  if (res == -1) {
    perror("Error poll stdin");
    exit(EXIT_FAILURE);
  }
  return res > 0;
}


x86 assembly (clang, -O0):
<file_stdin_poll_in_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <poll@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1189 <file_stdin_poll_in_+0x59>
lea    0xe8a(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_stdin_poll_in_>:
sub    $0x18,%rsp
movl   $0x0,0x8(%rsp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
movl   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1030 <poll@plt>
cmp    $0xffffffff,%eax
je     1175 <file_stdin_poll_in_+0x45>
xor    %ecx,%ecx
test   %eax,%eax
setg   %cl
mov    %ecx,%eax
add    $0x18,%rsp
ret
lea    0xe84(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
@POLLIN = global i32 0
@.str = [17 x i8] c"Error poll stdin\00"
@EXIT_FAILURE = global i32 0
define i32 @file_stdin_poll_in_() {
%1 = alloca %struct.pollfd
%2 = alloca i32
%3 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i32 0, i32 0
store i32 0, i32* %3
%4 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i32 0, i32 1
%5 = load i32, i32* @POLLIN
store i32 %5, i32* %4
%6 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i32 0, i32 2
store i32 0, i32* %6
%7 = call i32 @poll(%struct.pollfd* %1, i32 1, i32 0)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
%17 = zext i1 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
@POLLIN = global i32 0
@.str = [17 x i8] c"Error poll stdin\00"
@EXIT_FAILURE = global i32 0
define i32 @file_stdin_poll_in_() {
%1 = alloca %struct.pollfd
%2 = bitcast %struct.pollfd* %1 to i8*
%3 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i64 0, i32 0
store i32 0, i32* %3
%4 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i64 0, i32 1
%5 = load i32, i32* @POLLIN
store i32 %5, i32* %4
%6 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %1, i64 0, i32 2
store i32 0, i32* %6
%7 = call i32 @poll(%struct.pollfd* %1, i32 1, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
%14 = icmp sgt i32 %7, 0
%15 = zext i1 %14 to i32
ret i32 %15
}