int fimc_poll(struct pollfd *events) {
  int ret;
  ret = poll(events, 1, 10000);
  if (ret < 0) {
    printf("ERR(%s):poll error\n", __func__);
    return ret;
  }
  if (ret == 0) {
    printf("ERR(%s):No data in 10 secs..\n", __func__);
    return ret;
  }
  return ret;
}


x86 assembly (clang, -O0):
<fimc_poll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
mov    $0x2710,%edx
mov    $0x0,%al
call   1040 <poll@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    116e <fimc_poll+0x4e>
lea    0xeab(%rip),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119e <fimc_poll+0x7e>
cmpl   $0x0,-0x14(%rbp)
jne    1198 <fimc_poll+0x78>
lea    0xe9f(%rip),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119e <fimc_poll+0x7e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fimc_poll>:
push   %rbx
mov    $0x1,%esi
mov    $0x2710,%edx
xor    %eax,%eax
call   1040 <poll@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1143 <fimc_poll+0x23>
jne    1158 <fimc_poll+0x38>
lea    0xedd(%rip),%rdi
jmp    114a <fimc_poll+0x2a>
lea    0xeb6(%rip),%rdi
lea    0xec3(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.pollfd = type opaque
@.str = [20 x i8] c"ERR(%s):poll error\0A\00"
@__func__.fimc_poll = [10 x i8] c"fimc_poll\00"
@.str.1 = [30 x i8] c"ERR(%s):No data in 10 secs..\0A\00"
define i32 @fimc_poll(%struct.pollfd* %0) {
%2 = alloca i32
%3 = alloca %struct.pollfd*
%4 = alloca i32
store %struct.pollfd* %0, %struct.pollfd** %3
%5 = load %struct.pollfd*, %struct.pollfd** %3
%6 = call i32 (%struct.pollfd*, i32, i32, ...) bitcast (i32 (...)* @poll to i32 (%struct.pollfd*, i32, i32, ...)*)(%struct.pollfd* %5, i32 1, i32 10000)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__func__.fimc_poll, i64 0, i64 0))
%11 = load i32, i32* %4
store i32 %11, i32* %2
br label %20
12: ; preds = %1
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__func__.fimc_poll, i64 0, i64 0))
%17 = load i32, i32* %4
store i32 %17, i32* %2
br label %20
18: ; preds = %12
%19 = load i32, i32* %4
store i32 %19, i32* %2
br label %20
20: ; preds = %18, %15, %9
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
%struct.pollfd = type opaque
@.str = [20 x i8] c"ERR(%s):poll error\0A\00"
@__func__.fimc_poll = [10 x i8] c"fimc_poll\00"
@.str.1 = [30 x i8] c"ERR(%s):No data in 10 secs..\0A\00"
define i32 @fimc_poll(%struct.pollfd* %0) {
%2 = tail call i32 (%struct.pollfd*, i32, i32, ...) bitcast (i32 (...)* @poll to i32 (%struct.pollfd*, i32, i32, ...)*)(%struct.pollfd* %0, i32 1, i32 10000)
%3 = icmp slt i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = icmp eq i32 %2, 0
br i1 %5, label %6, label %9
6: ; preds = %4, %1
%7 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), %4 ]
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__func__.fimc_poll, i64 0, i64 0))
br label %9
9: ; preds = %6, %4
ret i32 %2
}