#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 */
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ if_exit(int);
int if_init(int, char **);
int /*<<< orphan*/ if_parse(int);
scalar_t__ select(int, int /*<<< orphan*/ *, int /*<<< orphan*/,
                  int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ tx_abort(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int ifd;
  if (argc < 2) {
    write(1, "This program should only be called by the perl RCU module\n",
          sizeof "This program should only be called by the perl RCU module\n");
    exit(1);
  }
  ifd = if_init(argc - 2, argv + 2);
  if (ifd >= 0) {
    write(1, "I", 2);
    for (;;) {
      fd_set fds;
      FD_ZERO(&fds);
      FD_SET(ifd, &fds);
      FD_SET(0, &fds);
      if (select(ifd + 1, &fds, 0, 0, 0) >= 0) {
        if (FD_ISSET(0, &fds))
          break;
        if (FD_ISSET(ifd, &fds))
          if_parse(ifd);
      }
    }
  } else
    tx_abort("unable to set-up ir-link");
  if_exit(ifd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11e0 <main+0x40>
mov    $0x1,%edi
lea    0xe34(%rip),%rsi
mov    $0x3b,%edx
call   1040 <write@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   1030 <if_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     129f <main+0xff>
mov    $0x1,%edi
lea    0xe2f(%rip),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
lea    -0x18(%rbp),%rdi
call   1070 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   10c0 <FD_SET@plt>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   10c0 <FD_SET@plt>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x18(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1080 <select@plt>
cmp    $0x0,%rax
jl     1295 <main+0xf5>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1272 <main+0xd2>
jmp    129a <main+0xfa>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1290 <main+0xf0>
mov    -0x14(%rbp),%edi
call   1090 <if_parse@plt>
jmp    1295 <main+0xf5>
jmp    1216 <main+0x76>
jmp    12ab <main+0x10b>
lea    0xd97(%rip),%rdi
call   10a0 <tx_abort@plt>
mov    -0x14(%rbp),%edi
call   1060 <if_exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    1268 <main+0xc8>
add    $0xfffffffe,%edi
add    $0x10,%rsi
call   1030 <if_init@plt>
mov    %eax,%ebx
test   %eax,%eax
js     124a <main+0xaa>
lea    0xe6d(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
call   1040 <write@plt>
mov    %ebx,%r14d
add    $0x1,%r14d
lea    0xc(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1070 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   10c0 <FD_SET@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   10c0 <FD_SET@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1080 <select@plt>
test   %rax,%rax
js     11f0 <main+0x50>
xor    %edi,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
jne    1256 <main+0xb6>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     11f0 <main+0x50>
mov    %ebx,%edi
call   1090 <if_parse@plt>
jmp    11f0 <main+0x50>
lea    0xdec(%rip),%rdi
call   10a0 <tx_abort@plt>
mov    %ebx,%edi
call   1060 <if_exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd91(%rip),%rsi
mov    $0x1,%edi
mov    $0x3b,%edx
call   1040 <write@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"This program should only be called by the perl RCU module\0A\00"
@.str.1 = [2 x i8] c"I\00"
@.str.2 = [25 x i8] c"unable to set-up ir-link\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @write(i32 1, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 59)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = call i32 @if_init(i32 %15, i8** %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %46
21: ; preds = %13
%22 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %23
23: ; preds = %44, %21
%24 = call i32 @FD_ZERO(i32* %7)
%25 = load i32, i32* %6
%26 = call i32 @FD_SET(i32 %25, i32* %7)
%27 = call i32 @FD_SET(i32 0, i32* %7)
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
%30 = call i64 @select(i32 %29, i32* %7, i32 0, i32 0, i32 0)
%31 = icmp sge i64 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %23
%33 = call i64 @FD_ISSET(i32 0, i32* %7)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
br label %45
36: ; preds = %32
%37 = load i32, i32* %6
%38 = call i64 @FD_ISSET(i32 %37, i32* %7)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %6
%42 = call i32 @if_parse(i32 %41)
br label %43
43: ; preds = %40, %36
br label %44
44: ; preds = %43, %23
br label %23
45: ; preds = %35
br label %48
46: ; preds = %13
%47 = call i32 @tx_abort(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %46, %45
%49 = load i32, i32* %6
%50 = call i32 @if_exit(i32 %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"This program should only be called by the perl RCU module\0A\00"
@.str.1 = [2 x i8] c"I\00"
@.str.2 = [25 x i8] c"unable to set-up ir-link\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i32 59)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = add nsw i32 %0, -2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = tail call i32 @if_init(i32 %9, i8** %10)
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %33
13: ; preds = %8
%14 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
%15 = bitcast i32* %3 to i8*
%16 = add nuw nsw i32 %11, 1
br label %17
17: ; preds = %32, %13
%18 = call i32 @FD_ZERO(i32* %3)
%19 = call i32 @FD_SET(i32 %11, i32* %3)
%20 = call i32 @FD_SET(i32 0, i32* %3)
%21 = call i64 @select(i32 %16, i32* %3, i32 0, i32 0, i32 0)
%22 = icmp sgt i64 %21, -1
br i1 %22, label %23, label %32
23: ; preds = %17
%24 = call i64 @FD_ISSET(i32 0, i32* %3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %23
br label %35
27: ; preds = %23
%28 = call i64 @FD_ISSET(i32 %11, i32* %3)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 @if_parse(i32 %11)
br label %32
32: ; preds = %17, %30, %27
br label %17
33: ; preds = %8
%34 = tail call i32 @tx_abort(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %26, %33
%36 = call i32 @if_exit(i32 %11)
ret i32 0
}