#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;
};
typedef int /*<<< orphan*/ pollfd;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(struct pollfd *, int /*<<< orphan*/, int);
int poll(struct pollfd *, int, int);
void __poll(int fd) {
  struct pollfd pollfd;
  int ret;
  memset(&pollfd, 0, sizeof(pollfd));
  pollfd.fd = fd;
  ret = poll(&pollfd, 1, 100);
  if (ret != 1) {
    error(1, errno, "poll");
  }
}


x86 assembly (clang, -O0):
<__poll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x64,%edx
call   1040 <poll@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     118b <__poll+0x5b>
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    0xe7a(%rip),%rdx
call   1050 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__poll>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    %ebx,(%rsp)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x64,%edx
call   1040 <poll@plt>
cmp    $0x1,%eax
je     117c <__poll+0x4c>
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdx
mov    $0x1,%edi
call   1050 <error@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.pollfd = type { i32 }
@errno = global i32 0
@.str = [5 x i8] c"poll\00"
define void @__poll(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.pollfd
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @memset(%struct.pollfd* %3, i32 0, i32 4)
%6 = load i32, i32* %2
%7 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %3, i32 0, i32 0
store i32 %6, i32* %7
%8 = call i32 @poll(%struct.pollfd* %3, i32 1, i32 100)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = call i32 @error(i32 1, i32 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %1
ret void
}

LLVM IR (-O2):
%struct.pollfd = type { i32 }
@errno = global i32 0
@.str = [5 x i8] c"poll\00"
define void @__poll(i32 %0) {
%2 = alloca %struct.pollfd
%3 = bitcast %struct.pollfd* %2 to i8*
%4 = call i32 @memset(%struct.pollfd* %2, i32 0, i32 4)
%5 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %2, i64 0, i32 0
store i32 %0, i32* %5
%6 = call i32 @poll(%struct.pollfd* %2, i32 1, i32 100)
%7 = icmp eq i32 %6, 1
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* @errno
%10 = call i32 @error(i32 1, i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %1
ret void
}