#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__ EXIT_SUCCESS;
scalar_t__ bb_run_fork(char **, int);
int module_is_available(char *module_name) {
  char *mod_argv[] = {"modinfo", "--field", "", module_name, NULL};
  return bb_run_fork(mod_argv, 1) == EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<module_is_available>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xed6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1030 <bb_run_fork@plt>
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<module_is_available>:
sub    $0x28,%rsp
lea    0xee5(%rip),%rax
mov    %rax,(%rsp)
lea    0xee2(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xedd(%rip),%rax
mov    %rax,0x10(%rsp)
mov    %rdi,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    %rsp,%rdi
mov    $0x1,%esi
call   1030 <bb_run_fork@plt>
mov    0x2e87(%rip),%rdx
xor    %ecx,%ecx
cmp    (%rdx),%rax
sete   %cl
mov    %ecx,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"modinfo\00"
@.str.1 = [8 x i8] c"--field\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_SUCCESS = global i64 0
define i32 @module_is_available(i8* %0) {
%2 = alloca i8*
%3 = alloca [5 x i8*]
store i8* %0, i8** %2
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds i8*, i8** %4, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds i8*, i8** %5, i64 1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %2
store i8* %8, i8** %7
%9 = getelementptr inbounds i8*, i8** %7, i64 1
store i8* null, i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
%11 = call i64 @bb_run_fork(i8** %10, i32 1)
%12 = load i64, i64* @EXIT_SUCCESS
%13 = icmp eq i64 %11, %12
%14 = zext i1 %13 to i32
ret i32 %14
}

LLVM IR (-O2):
@.str = [8 x i8] c"modinfo\00"
@.str.1 = [8 x i8] c"--field\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_SUCCESS = global i64 0
define i32 @module_is_available(i8* %0) {
%2 = alloca [5 x i8*]
%3 = bitcast [5 x i8*]* %2 to i8*
%4 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 3
store i8* %0, i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
store i8* null, i8** %8
%9 = call i64 @bb_run_fork(i8** %4, i32 1)
%10 = load i64, i64* @EXIT_SUCCESS
%11 = icmp eq i64 %9, %10
%12 = zext i1 %11 to i32
ret i32 %12
}