#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 pqos_mon_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ log_printf(int, char *, unsigned int);
int poll_events(struct pqos_mon_data *);
int os_mon_poll(struct pqos_mon_data **groups, const unsigned num_groups) {
  unsigned i = 0;
  ;
  ;
  for (i = 0; i < num_groups; i++) {
    int ret = poll_events(groups[i]);
    if (ret != 0)
      log_printf((1 << 1),
                 "WARN: "
                 "Failed to poll event on "
                 "group number %u\n",
                 i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<os_mon_poll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    118d <os_mon_poll+0x6d>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1030 <poll_events@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117a <os_mon_poll+0x5a>
mov    -0x10(%rbp),%edx
mov    $0x2,%edi
lea    0xe8b(%rip),%rsi
call   1040 <log_printf@plt>
jmp    117f <os_mon_poll+0x5f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <os_mon_poll+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<os_mon_poll>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1167 <os_mon_poll+0x47>
mov    %rdi,%r14
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xec5(%rip),%r15
jmp    1149 <os_mon_poll+0x29>
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1167 <os_mon_poll+0x47>
mov    (%r14,%rbx,8),%rdi
call   1030 <poll_events@plt>
test   %eax,%eax
je     1140 <os_mon_poll+0x20>
mov    $0x2,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <log_printf@plt>
jmp    1140 <os_mon_poll+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pqos_mon_data = type { i32 }
@.str = [47 x i8] c"WARN: Failed to poll event on group number %u\0A\00"
define i32 @os_mon_poll(%struct.pqos_mon_data** %0, i32 %1) {
%3 = alloca %struct.pqos_mon_data**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.pqos_mon_data** %0, %struct.pqos_mon_data*** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %7
7: ; preds = %24, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
%12 = load %struct.pqos_mon_data**, %struct.pqos_mon_data*** %3
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds %struct.pqos_mon_data*, %struct.pqos_mon_data** %12, i64 %14
%16 = load %struct.pqos_mon_data*, %struct.pqos_mon_data** %15
%17 = call i32 @poll_events(%struct.pqos_mon_data* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %11
%21 = load i32, i32* %5
%22 = call i32 @log_printf(i32 2, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %11
br label %24
24: ; preds = %23
%25 = load i32, i32* %5
%26 = add i32 %25, 1
store i32 %26, i32* %5
br label %7
27: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
%struct.pqos_mon_data = type { i32 }
@.str = [47 x i8] c"WARN: Failed to poll event on group number %u\0A\00"
define i32 @os_mon_poll(%struct.pqos_mon_data** nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %18, label %4
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ 0, %4 ], [ %16, %15 ]
%8 = getelementptr inbounds %struct.pqos_mon_data*, %struct.pqos_mon_data** %0, i64 %7
%9 = load %struct.pqos_mon_data*, %struct.pqos_mon_data** %8
%10 = tail call i32 @poll_events(%struct.pqos_mon_data* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = trunc i64 %7 to i32
%14 = tail call i32 @log_printf(i32 2, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %6
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, %5
br i1 %17, label %18, label %6
18: ; preds = %15, %2
ret i32 0
}