#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__ check_module_loaded(char *, int *);
int /*<<< orphan*/ printf(char *, char *);
int check_module_loaded_no_dev(char *module) {
  bool loaded;
  if (check_module_loaded(module, &loaded) != 0)
    return 0;
  if (loaded) {
    printf("Module '%s' is already loaded, but device not available.\n",
           module);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_module_loaded_no_dev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <check_module_loaded@plt>
cmp    $0x0,%rax
je     114f <check_module_loaded_no_dev+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    117c <check_module_loaded_no_dev+0x5c>
cmpl   $0x0,-0x14(%rbp)
je     1175 <check_module_loaded_no_dev+0x55>
mov    -0x10(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    117c <check_module_loaded_no_dev+0x5c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_module_loaded_no_dev>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
call   1040 <check_module_loaded@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1157 <check_module_loaded_no_dev+0x37>
cmpl   $0x0,0xc(%rsp)
je     1157 <check_module_loaded_no_dev+0x37>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Module '%s' is already loaded, but device not available.\0A\00"
define i32 @check_module_loaded_no_dev(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @check_module_loaded(i8* %5, i32* %4)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %16
9: ; preds = %1
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 -1, i32* %2
br label %16
15: ; preds = %9
store i32 0, i32* %2
br label %16
16: ; preds = %15, %12, %8
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [58 x i8] c"Module '%s' is already loaded, but device not available.\0A\00"
define i32 @check_module_loaded_no_dev(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i64 @check_module_loaded(i8* %0, i32* %2)
%5 = icmp ne i64 %4, 0
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
%8 = select i1 %5, i1 true, i1 %7
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %1, %9
%12 = phi i32 [ -1, %9 ], [ 0, %1 ]
ret i32 %12
}