#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ moduleLoaded(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ system(char *);
void loadModule(char *module) {
  char cmd[80];
  if (moduleLoaded(module)) {
    return;
  }
  printf("Loading module: %s", module);
  sprintf(cmd, "modprobe %s", module);
  system(cmd);
  sleep(1);
  if (!moduleLoaded(module)) {
    fprintf(stderr, "Unable to load %s\n", module);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<loadModule>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <moduleLoaded@plt>
cmp    $0x0,%rax
je     1194 <loadModule+0x24>
jmp    1201 <loadModule+0x91>
mov    -0x8(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe60(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x60(%rbp),%rdi
call   1040 <system@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    -0x8(%rbp),%rdi
call   1030 <moduleLoaded@plt>
cmp    $0x0,%rax
jne    1201 <loadModule+0x91>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe2d(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadModule>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
call   1030 <moduleLoaded@plt>
test   %rax,%rax
jne    11c7 <loadModule+0x57>
lea    0xe75(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0xe79(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    %rbx,%rdi
call   1030 <moduleLoaded@plt>
test   %rax,%rax
je     11cf <loadModule+0x5f>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Loading module: %s\00"
@.str.1 = [12 x i8] c"modprobe %s\00"
@stderr = global i32 0
@.str.2 = [19 x i8] c"Unable to load %s\0A\00"
define void @loadModule(i8* %0) {
%2 = alloca i8*
%3 = alloca [80 x i8]
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @moduleLoaded(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
br label %25
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%15 = call i32 @system(i8* %14)
%16 = call i32 @sleep(i32 1)
%17 = load i8*, i8** %2
%18 = call i64 @moduleLoaded(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %8
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %2
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %7, %8
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Loading module: %s\00"
@.str.1 = [12 x i8] c"modprobe %s\00"
@stderr = global i32 0
@.str.2 = [19 x i8] c"Unable to load %s\0A\00"
define void @loadModule(i8* %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @moduleLoaded(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%9 = call i32 @system(i8* %3)
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i64 @moduleLoaded(i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %6, %1
ret void
}