#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 PIOInsDrv() {
  char *const argv[] = {"insmod", "-f", "pio.o", 0};
  int pid;
  int status;
  pid = fork();
  if (pid == -1) {
    return;
  }
  if (pid == 0) {
    execv("/sbin/insmod", argv);
    exit(127);
  }
  do {
    if (waitpid(pid, &status, 0) == -1) {
      if (errno != EINTR) {
        return;
      }
    } else {
      break;
    }
  } while (1);
}


x86 assembly (clang, -O0):
<PIOInsDrv>:
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    0x2c98(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    118d <PIOInsDrv+0x4d>
jmp    120a <PIOInsDrv+0xca>
cmpl   $0x0,-0x24(%rbp)
jne    11b1 <PIOInsDrv+0x71>
lea    -0x20(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1050 <execv@plt>
mov    $0x7f,%edi
call   1040 <exit@plt>
jmp    11b6 <PIOInsDrv+0x76>
mov    -0x24(%rbp),%edi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    11f1 <PIOInsDrv+0xb1>
mov    0x2e0c(%rip),%rax
mov    (%rax),%rax
mov    0x2dfa(%rip),%rcx
cmp    (%rcx),%rax
je     11ec <PIOInsDrv+0xac>
jmp    120a <PIOInsDrv+0xca>
jmp    11f6 <PIOInsDrv+0xb6>
jmp    120a <PIOInsDrv+0xca>
jmp    11fb <PIOInsDrv+0xbb>
mov    $0x1,%al
test   $0x1,%al
jne    11b6 <PIOInsDrv+0x76>
jmp    120a <PIOInsDrv+0xca>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PIOInsDrv>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps 0x2cae(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c92(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <fork@plt>
cmp    $0xffffffff,%eax
je     11aa <PIOInsDrv+0x6a>
mov    %eax,%ebx
test   %eax,%eax
je     11b6 <PIOInsDrv+0x76>
lea    0xc(%rsp),%r14
mov    0x2e5f(%rip),%r15
mov    0x2e50(%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 <PIOInsDrv+0x6a>
mov    (%r15),%rax
cmp    (%r12),%rax
je     1190 <PIOInsDrv+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe4c(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <execv@plt>
mov    $0x7f,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"insmod\00"
@.str.1 = [3 x i8] c"-f\00"
@.str.2 = [6 x i8] c"pio.o\00"
@__const.PIOInsDrv.argv = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [13 x i8] c"/sbin/insmod\00"
@errno = global i64 0
@EINTR = global i64 0
define void @PIOInsDrv() {
%1 = alloca [4 x i8*]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [4 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 [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%14 = call i32 @execv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, 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 = [7 x i8] c"insmod\00"
@.str.1 = [3 x i8] c"-f\00"
@.str.2 = [6 x i8] c"pio.o\00"
@__const.PIOInsDrv.argv = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* null]
@.str.3 = [13 x i8] c"/sbin/insmod\00"
@errno = global i64 0
@EINTR = global i64 0
define void @PIOInsDrv() {
%1 = alloca [4 x i8*]
%2 = alloca i32
%3 = bitcast [4 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 [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%8 = call i32 @execv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, 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
}