#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;
  scalar_t__ revents;
  scalar_t__ events;
};

/* Variables and functions */
void RandomInit(struct pollfd *fds, int total) {
  int i = 0;
  for (; i < total; ++i) {
    fds[i].fd = -1;
    fds[i].events = 0;
    fds[i].revents = 0;
  }
}


x86 assembly (clang, -O0):
<RandomInit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116f <RandomInit+0x6f>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x10(%rax)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movq   $0x0,0x8(%rax)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <RandomInit+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<RandomInit>:
test   %esi,%esi
jle    11a5 <RandomInit+0xa5>
mov    %esi,%ecx
lea    -0x1(%rcx),%rdx
mov    %ecx,%eax
and    $0x3,%eax
cmp    $0x3,%rdx
jae    111d <RandomInit+0x1d>
xor    %edx,%edx
jmp    1168 <RandomInit+0x68>
and    $0xfffffffc,%ecx
lea    0x50(%rdi),%rsi
xor    %edx,%edx
xorps  %xmm0,%xmm0
nopl   0x0(%rax)
movl   $0xffffffff,-0x50(%rsi)
movups %xmm0,-0x48(%rsi)
movl   $0xffffffff,-0x38(%rsi)
movups %xmm0,-0x30(%rsi)
movl   $0xffffffff,-0x20(%rsi)
movups %xmm0,-0x18(%rsi)
movl   $0xffffffff,-0x8(%rsi)
add    $0x4,%rdx
movups %xmm0,(%rsi)
add    $0x60,%rsi
cmp    %rdx,%rcx
jne    1130 <RandomInit+0x30>
test   %rax,%rax
je     11a5 <RandomInit+0xa5>
lea    (%rdx,%rdx,2),%rcx
lea    (%rdi,%rcx,8),%rcx
add    $0x8,%rcx
shl    $0x3,%rax
lea    (%rax,%rax,2),%rax
xor    %edx,%edx
xorps  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
movl   $0xffffffff,-0x8(%rcx,%rdx,1)
ff
movups %xmm0,(%rcx,%rdx,1)
add    $0x18,%rdx
cmp    %rdx,%rax
jne    1190 <RandomInit+0x90>
ret

LLVM IR (-O0):
%struct.pollfd = type { i32, i64, i64 }
define void @RandomInit(%struct.pollfd* %0, i32 %1) {
%3 = alloca %struct.pollfd*
%4 = alloca i32
%5 = alloca i32
store %struct.pollfd* %0, %struct.pollfd** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %26, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = load %struct.pollfd*, %struct.pollfd** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %11, i64 %13
%15 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %14, i32 0, i32 0
store i32 -1, i32* %15
%16 = load %struct.pollfd*, %struct.pollfd** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %16, i64 %18
%20 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %19, i32 0, i32 2
store i64 0, i64* %20
%21 = load %struct.pollfd*, %struct.pollfd** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %21, i64 %23
%25 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %24, i32 0, i32 1
store i64 0, i64* %25
br label %26
26: ; preds = %10
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %6
29: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i64, i64 }
define void @RandomInit(%struct.pollfd* nocapture writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %44
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = add nsw i64 %5, -1
%7 = and i64 %5, 3
%8 = icmp ult i64 %6, 3
br i1 %8, label %32, label %9
9: ; preds = %4
%10 = and i64 %5, 4294967292
br label %11
11: ; preds = %11, %9
%12 = phi i64 [ 0, %9 ], [ %28, %11 ]
%13 = phi i64 [ 0, %9 ], [ %30, %11 ]
%14 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %12, i32 0
store i32 -1, i32* %14
%15 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %12, i32 1
%16 = or i64 %12, 1
%17 = bitcast i64* %15 to i8*
%18 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %16, i32 0
store i32 -1, i32* %18
%19 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %16, i32 1
%20 = or i64 %12, 2
%21 = bitcast i64* %19 to i8*
%22 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %20, i32 0
store i32 -1, i32* %22
%23 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %20, i32 1
%24 = or i64 %12, 3
%25 = bitcast i64* %23 to i8*
%26 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %24, i32 0
store i32 -1, i32* %26
%27 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %24, i32 1
%28 = add nuw nsw i64 %12, 4
%29 = bitcast i64* %27 to i8*
%30 = add i64 %13, 4
%31 = icmp eq i64 %30, %10
br i1 %31, label %32, label %11
32: ; preds = %11, %4
%33 = phi i64 [ 0, %4 ], [ %28, %11 ]
%34 = icmp eq i64 %7, 0
br i1 %34, label %44, label %35
35: ; preds = %32, %35
%36 = phi i64 [ %40, %35 ], [ %33, %32 ]
%37 = phi i64 [ %42, %35 ], [ 0, %32 ]
%38 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %36, i32 0
store i32 -1, i32* %38
%39 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %0, i64 %36, i32 1
%40 = add nuw nsw i64 %36, 1
%41 = bitcast i64* %39 to i8*
%42 = add i64 %37, 1
%43 = icmp eq i64 %42, %7
br i1 %43, label %44, label %35
44: ; preds = %32, %35, %2
ret void
}