#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ ptr;
};
struct epoll_event {
  int events;
  TYPE_1__ data;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, char const *, int);
void print_events(const struct epoll_event *evts, int event_count) {
  int i;
  for (i = 0; i < event_count; i++) {
    printf("Event %d: %s, events=0x%x\n", i, (const char *)evts[i].data.ptr,
           evts[i].events);
  }
}


x86 assembly (clang, -O0):
<print_events>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1173 <print_events+0x63>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%ecx
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <print_events+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_events>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    114e <print_events+0x3e>
mov    %rdi,%r14
mov    %esi,%r12d
add    $0x8,%r14
xor    %ebx,%ebx
lea    0xed1(%rip),%r15
nop
mov    (%r14),%rdx
mov    -0x8(%r14),%ecx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
add    $0x10,%r14
cmp    %rbx,%r12
jne    1130 <print_events+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@.str = [27 x i8] c"Event %d: %s, events=0x%x\0A\00"
define void @print_events(%struct.epoll_event* %0, i32 %1) {
%3 = alloca %struct.epoll_event*
%4 = alloca i32
%5 = alloca i32
store %struct.epoll_event* %0, %struct.epoll_event** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %27, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %30
10: ; preds = %6
%11 = load i32, i32* %5
%12 = load %struct.epoll_event*, %struct.epoll_event** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %12, i64 %14
%16 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %15, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = inttoptr i64 %18 to i8*
%20 = load %struct.epoll_event*, %struct.epoll_event** %3
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %20, i64 %22
%24 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %19, i32 %25)
br label %27
27: ; preds = %10
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %6
30: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.epoll_event = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@.str = [27 x i8] c"Event %d: %s, events=0x%x\0A\00"
define void @print_events(%struct.epoll_event* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %15, %6 ]
%8 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %0, i64 %7, i32 1, i32 0
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i8*
%11 = getelementptr inbounds %struct.epoll_event, %struct.epoll_event* %0, i64 %7, i32 0
%12 = load i32, i32* %11
%13 = trunc i64 %7 to i32
%14 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %10, i32 %12)
%15 = add nuw nsw i64 %7, 1
%16 = icmp eq i64 %15, %5
br i1 %16, label %17, label %6
17: ; preds = %6, %2
ret void
}