#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 pollfd {
  scalar_t__ revents;
  int /*<<< orphan*/ events;
  int /*<<< orphan*/ fd;
};
struct TYPE_2__ {
  int /*<<< orphan*/ events;
  int /*<<< orphan*/ fd;
};

/* Variables and functions */
int /*<<< orphan*/ EINTR;
int /*<<< orphan*/ _(char *);
int *__rpc_thread_svc_max_pollfd();
TYPE_1__ **__rpc_thread_svc_pollfd();
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(struct pollfd *);
struct pollfd *malloc(int);
int /*<<< orphan*/ perror(int /*<<< orphan*/);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ svc_getreq_poll(struct pollfd *, int);
void svc_run(void) {
  int i;
  for (;;) {
    struct pollfd *my_pollfd;
    if ((*__rpc_thread_svc_max_pollfd()) == 0 &&
        (*__rpc_thread_svc_pollfd()) == NULL)
      return;
    my_pollfd =
        malloc(sizeof(struct pollfd) * (*__rpc_thread_svc_max_pollfd()));
    for (i = 0; i < (*__rpc_thread_svc_max_pollfd()); ++i) {
      my_pollfd[i].fd = (*__rpc_thread_svc_pollfd())[i].fd;
      my_pollfd[i].events = (*__rpc_thread_svc_pollfd())[i].events;
      my_pollfd[i].revents = 0;
    }
    switch (i = poll(my_pollfd, (*__rpc_thread_svc_max_pollfd()), -1)) {
    case -1:
      free(my_pollfd);
      if (errno == EINTR)
        continue;
      perror(_("svc_run: - poll failed"));
      return;
    case 0:
      free(my_pollfd);
      continue;
    default:
      svc_getreq_poll(my_pollfd, i);
      free(my_pollfd);
    }
  }
}


x86 assembly (clang, -O0):
<svc_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1090 <__rpc_thread_svc_max_pollfd@plt>
cmpl   $0x0,(%rax)
jne    11ae <svc_run+0x2e>
mov    $0x0,%al
call   1040 <__rpc_thread_svc_pollfd@plt>
cmpq   $0x0,(%rax)
jne    11ae <svc_run+0x2e>
jmp    12ff <svc_run+0x17f>
mov    $0x0,%al
call   1090 <__rpc_thread_svc_max_pollfd@plt>
movslq (%rax),%rax
shl    $0x4,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1090 <__rpc_thread_svc_max_pollfd@plt>
mov    %rax,%rcx
mov    -0x14(%rbp),%eax
cmp    (%rcx),%eax
jge    1254 <svc_run+0xd4>
mov    $0x0,%al
call   1040 <__rpc_thread_svc_pollfd@plt>
mov    (%rax),%rax
movslq -0x4(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%ecx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %ecx,0xc(%rax)
mov    $0x0,%al
call   1040 <__rpc_thread_svc_pollfd@plt>
mov    (%rax),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%ecx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movq   $0x0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11ce <svc_run+0x4e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
call   1090 <__rpc_thread_svc_max_pollfd@plt>
mov    -0x20(%rbp),%rdi
mov    (%rax),%esi
mov    $0xffffffff,%edx
call   1070 <poll@plt>
mov    %eax,-0x4(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0xffffffff,%eax
je     1299 <svc_run+0x119>
jmp    1289 <svc_run+0x109>
mov    -0x18(%rbp),%eax
test   %eax,%eax
je     12d7 <svc_run+0x157>
jmp    12e5 <svc_run+0x165>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    0x2d26(%rip),%rcx
cmp    (%rcx),%eax
jne    12bf <svc_run+0x13f>
jmp    1188 <svc_run+0x8>
lea    0xd3a(%rip),%rdi
call   1060 <_@plt>
mov    %eax,%edi
call   1080 <perror@plt>
jmp    12ff <svc_run+0x17f>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1188 <svc_run+0x8>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   10a0 <svc_getreq_poll@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1188 <svc_run+0x8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<svc_run>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2e50(%rip),%r14
mov    0x2e41(%rip),%r15
jmp    11b2 <svc_run+0x32>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %eax,%esi
call   10a0 <svc_getreq_poll@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1090 <__rpc_thread_svc_max_pollfd@plt>
cmpl   $0x0,(%rax)
jne    11cf <svc_run+0x4f>
xor    %eax,%eax
call   1040 <__rpc_thread_svc_pollfd@plt>
cmpq   $0x0,(%rax)
je     1299 <svc_run+0x119>
xor    %eax,%eax
call   1090 <__rpc_thread_svc_max_pollfd@plt>
mov    (%rax),%edi
shl    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1090 <__rpc_thread_svc_max_pollfd@plt>
cmpl   $0x0,(%rax)
jle    1242 <svc_run+0xc2>
lea    0xc(%r12),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <__rpc_thread_svc_pollfd@plt>
mov    (%rax),%rax
mov    0x4(%rax,%rbx,8),%eax
mov    %eax,0x0(%r13)
xor    %eax,%eax
call   1040 <__rpc_thread_svc_pollfd@plt>
mov    (%rax),%rax
mov    (%rax,%rbx,8),%eax
mov    %eax,-0x4(%r13)
movq   $0x0,-0xc(%r13)
add    $0x1,%rbx
xor    %eax,%eax
call   1090 <__rpc_thread_svc_max_pollfd@plt>
movslq (%rax),%rax
add    $0x10,%r13
cmp    %rax,%rbx
jl     1200 <svc_run+0x80>
xor    %eax,%eax
call   1090 <__rpc_thread_svc_max_pollfd@plt>
mov    (%rax),%esi
mov    %r12,%rdi
mov    $0xffffffff,%edx
call   1070 <poll@plt>
test   %eax,%eax
je     11aa <svc_run+0x2a>
cmp    $0xffffffff,%eax
jne    11a0 <svc_run+0x20>
mov    %r12,%rdi
call   1030 <free@plt>
mov    (%r14),%eax
cmp    (%r15),%eax
je     11b2 <svc_run+0x32>
lea    0xd7c(%rip),%rdi
call   1060 <_@plt>
mov    %eax,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1080 <perror@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.pollfd = type { i64, i32, i32 }
%struct.TYPE_2__ = type { i32, i32 }
@errno = global i32 0
@EINTR = global i32 0
@.str = [23 x i8] c"svc_run: - poll failed\00"
define void @svc_run() {
%1 = alloca i32
%2 = alloca %struct.pollfd*
br label %3
3: ; preds = %81, %72, %68, %0
%4 = call i32* (...) @__rpc_thread_svc_max_pollfd()
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = call %struct.TYPE_2__** (...) @__rpc_thread_svc_pollfd()
%9 = load %struct.TYPE_2__*, %struct.TYPE_2__** %8
%10 = icmp eq %struct.TYPE_2__* %9, null
br i1 %10, label %11, label %12
11: ; preds = %7
br label %82
12: ; preds = %7, %3
%13 = call i32* (...) @__rpc_thread_svc_max_pollfd()
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = mul i64 16, %15
%17 = trunc i64 %16 to i32
%18 = call %struct.pollfd* @malloc(i32 %17)
store %struct.pollfd* %18, %struct.pollfd** %2
store i32 0, i32* %1
br label %19
19: ; preds = %54, %12
%20 = load i32, i32* %1
%21 = call i32* (...) @__rpc_thread_svc_max_pollfd()
%22 = load i32, i32* %21
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %57
24: ; preds = %19
%25 = call %struct.TYPE_2__** (...) @__rpc_thread_svc_pollfd()
%26 = load %struct.TYPE_2__*, %struct.TYPE_2__** %25
%27 = load i32, i32* %1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %26, i64 %28
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i32 0, i32 1
%31 = load i32, i32* %30
%32 = load %struct.pollfd*, %struct.pollfd** %2
%33 = load i32, i32* %1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %32, i64 %34
%36 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %35, i32 0, i32 2
store i32 %31, i32* %36
%37 = call %struct.TYPE_2__** (...) @__rpc_thread_svc_pollfd()
%38 = load %struct.TYPE_2__*, %struct.TYPE_2__** %37
%39 = load i32, i32* %1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i64 %40
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 0
%43 = load i32, i32* %42
%44 = load %struct.pollfd*, %struct.pollfd** %2
%45 = load i32, i32* %1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %44, i64 %46
%48 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %47, i32 0, i32 1
store i32 %43, i32* %48
%49 = load %struct.pollfd*, %struct.pollfd** %2
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %49, i64 %51
%53 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %52, i32 0, i32 0
store i64 0, i64* %53
br label %54
54: ; preds = %24
%55 = load i32, i32* %1
%56 = add nsw i32 %55, 1
store i32 %56, i32* %1
br label %19
57: ; preds = %19
%58 = load %struct.pollfd*, %struct.pollfd** %2
%59 = call i32* (...) @__rpc_thread_svc_max_pollfd()
%60 = load i32, i32* %59
%61 = call i32 @poll(%struct.pollfd* %58, i32 %60, i32 -1)
store i32 %61, i32* %1
switch i32 %61, label %75 [
i32 -1, label %62
i32 0, label %72
]
62: ; preds = %57
%63 = load %struct.pollfd*, %struct.pollfd** %2
%64 = call i32 @free(%struct.pollfd* %63)
%65 = load i32, i32* @errno
%66 = load i32, i32* @EINTR
%67 = icmp eq i32 %65, %66
br i1 %67, label %68, label %69
68: ; preds = %62
br label %3
69: ; preds = %62
%70 = call i32 @_(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%71 = call i32 @perror(i32 %70)
br label %82
72: ; preds = %57
%73 = load %struct.pollfd*, %struct.pollfd** %2
%74 = call i32 @free(%struct.pollfd* %73)
br label %3
75: ; preds = %57
%76 = load %struct.pollfd*, %struct.pollfd** %2
%77 = load i32, i32* %1
%78 = call i32 @svc_getreq_poll(%struct.pollfd* %76, i32 %77)
%79 = load %struct.pollfd*, %struct.pollfd** %2
%80 = call i32 @free(%struct.pollfd* %79)
br label %81
81: ; preds = %75
br label %3
82: ; preds = %69, %11
ret void
}

LLVM IR (-O2):
%struct.TYPE_2__ = type { i32, i32 }
%struct.pollfd = type { i64, i32, i32 }
@errno = global i32 0
@EINTR = global i32 0
@.str = [23 x i8] c"svc_run: - poll failed\00"
define void @svc_run() {
br label %1
1: ; preds = %51, %0
%2 = tail call i32* (...) @__rpc_thread_svc_max_pollfd()
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call %struct.TYPE_2__** (...) @__rpc_thread_svc_pollfd()
%7 = load %struct.TYPE_2__*, %struct.TYPE_2__** %6
%8 = icmp eq %struct.TYPE_2__* %7, null
br i1 %8, label %52, label %9
9: ; preds = %5, %1
%10 = tail call i32* (...) @__rpc_thread_svc_max_pollfd()
%11 = load i32, i32* %10
%12 = shl i32 %11, 4
%13 = tail call %struct.pollfd* @malloc(i32 %12)
%14 = tail call i32* (...) @__rpc_thread_svc_max_pollfd()
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %35
17: ; preds = %9, %17
%18 = phi i64 [ %30, %17 ], [ 0, %9 ]
%19 = tail call %struct.TYPE_2__** (...) @__rpc_thread_svc_pollfd()
%20 = load %struct.TYPE_2__*, %struct.TYPE_2__** %19
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i64 %18, i32 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i64 %18, i32 2
store i32 %22, i32* %23
%24 = tail call %struct.TYPE_2__** (...) @__rpc_thread_svc_pollfd()
%25 = load %struct.TYPE_2__*, %struct.TYPE_2__** %24
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i64 %18, i32 0
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i64 %18, i32 1
store i32 %27, i32* %28
%29 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %13, i64 %18, i32 0
store i64 0, i64* %29
%30 = add nuw nsw i64 %18, 1
%31 = tail call i32* (...) @__rpc_thread_svc_max_pollfd()
%32 = load i32, i32* %31
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %30, %33
br i1 %34, label %17, label %35
35: ; preds = %17, %9
%36 = tail call i32* (...) @__rpc_thread_svc_max_pollfd()
%37 = load i32, i32* %36
%38 = tail call i32 @poll(%struct.pollfd* %13, i32 %37, i32 -1)
switch i32 %38, label %47 [
i32 -1, label %39
i32 0, label %49
]
39: ; preds = %35
%40 = tail call i32 @free(%struct.pollfd* %13)
%41 = load i32, i32* @errno
%42 = load i32, i32* @EINTR
%43 = icmp eq i32 %41, %42
br i1 %43, label %51, label %44
44: ; preds = %39
%45 = tail call i32 @_(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%46 = tail call i32 @perror(i32 %45)
br label %52
47: ; preds = %35
%48 = tail call i32 @svc_getreq_poll(%struct.pollfd* %13, i32 %38)
br label %49
49: ; preds = %35, %47
%50 = tail call i32 @free(%struct.pollfd* %13)
br label %51
51: ; preds = %49, %39
br label %1
52: ; preds = %5, %44
ret void
}