#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 */

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ errno;
int /*<<< orphan*/ execv(char *, char *const *);
int /*<<< orphan*/ exit(int);
int fork();
int waitpid(int, int *, int /*<<< orphan*/);
void PIORmDrv() {
  char *const argv[] = {"rmmod", "pio", 0};
  int pid;
  int status;
  pid = fork();
  if (pid == -1) {
    return;
  }
  if (pid == 0) {
    execv("/sbin/rmmod", argv);
    exit(127);
  }
  do {
    if (waitpid(pid, &status, 0) == -1) {
      if (errno != EINTR) {
        return;
      }
    } else {
      break;
    }
  } while (1);
}


x86 assembly (clang, -O0):
<PIORmDrv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2ca1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c9b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1182 <PIORmDrv+0x42>
jmp    11ff <PIORmDrv+0xbf>
cmpl   $0x0,-0x24(%rbp)
jne    11a6 <PIORmDrv+0x66>
lea    -0x20(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1050 <execv@plt>
mov    $0x7f,%edi
call   1040 <exit@plt>
jmp    11ab <PIORmDrv+0x6b>
mov    -0x24(%rbp),%edi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    11e6 <PIORmDrv+0xa6>
mov    0x2e0f(%rip),%rax
mov    (%rax),%rax
mov    0x2dfd(%rip),%rcx
cmp    (%rcx),%rax
je     11e1 <PIORmDrv+0xa1>
jmp    11ff <PIORmDrv+0xbf>
jmp    11eb <PIORmDrv+0xab>
jmp    11ff <PIORmDrv+0xbf>
jmp    11f0 <PIORmDrv+0xb0>
mov    $0x1,%al
test   $0x1,%al
jne    11ab <PIORmDrv+0x6b>
jmp    11ff <PIORmDrv+0xbf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PIORmDrv>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2cae(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0x2c92(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     11aa <PIORmDrv+0x6a>
mov    %eax,%ebx
test   %eax,%eax
je     11b6 <PIORmDrv+0x76>
lea    0xc(%rsp),%r14
mov    0x2e57(%rip),%r15
mov    0x2e48(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    11aa <PIORmDrv+0x6a>
mov    (%r15),%rax
cmp    (%r12),%rax
je     1190 <PIORmDrv+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe47(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <execv@plt>
mov    $0x7f,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"rmmod\00"
@.str.1 = [4 x i8] c"pio\00"
@__const.PIORmDrv.argv = [3 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [12 x i8] c"/sbin/rmmod\00"
@errno = global i64 0
@EINTR = global i64 0
define void @PIORmDrv() {
%1 = alloca [3 x i8*]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [3 x i8*]* %1 to i8*
%5 = call i32 (...) @fork()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %0
br label %30
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%14 = call i32 @execv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %13)
%15 = call i32 @exit(i32 127)
unreachable
16: ; preds = %9
br label %17
17: ; preds = %29, %16
%18 = load i32, i32* %2
%19 = call i32 @waitpid(i32 %18, i32* %3, i32 0)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i64, i64* @errno
%23 = load i64, i64* @EINTR
%24 = icmp ne i64 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %21
br label %30
26: ; preds = %21
br label %28
27: ; preds = %17
br label %30
28: ; preds = %26
br label %29
29: ; preds = %28
br i1 true, label %17, label %30
30: ; preds = %8, %25, %29, %27
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"rmmod\00"
@.str.1 = [4 x i8] c"pio\00"
@__const.PIORmDrv.argv = [3 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [12 x i8] c"/sbin/rmmod\00"
@errno = global i64 0
@EINTR = global i64 0
define void @PIORmDrv() {
%1 = alloca [3 x i8*]
%2 = alloca i32
%3 = bitcast [3 x i8*]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @fork()
switch i32 %5, label %10 [
i32 -1, label %17
i32 0, label %6
]
6: ; preds = %0
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %1, i64 0, i64 0
%8 = call i32 @execv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %7)
%9 = call i32 @exit(i32 127)
unreachable
10: ; preds = %0, %13
%11 = call i32 @waitpid(i32 %5, i32* %2, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* @errno
%15 = load i64, i64* @EINTR
%16 = icmp eq i64 %14, %15
br i1 %16, label %10, label %17
17: ; preds = %10, %13, %0
ret void
}