#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*/ printf(char *);
scalar_t__ system(char *);
int remove_modules() {
  int err = 0;
  printf("uim:"
         " Removing bt_drv "
         "\n");
  if (system("rmmod bt_drv") != 0) {
    printf("uim:"
           " Error removing bt_drv module"
           "\n");
    err = -1;
  } else {
    printf("uim:"
           " Removed bt_drv module"
           "\n");
  }
  printf("uim:"
         " Removing st_drv "
         "\n");
  if (system("rmmod st_drv") != 0) {
    printf("uim:"
           " Error removing st_drv module"
           "\n");
    err = -1;
  } else {
    printf("uim:"
           " Removed st_drv module "
           "\n");
  }
  return err;
}


x86 assembly (clang, -O0):
<remove_modules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     1169 <remove_modules+0x49>
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1175 <remove_modules+0x55>
lea    0xed7(%rip),%rdi
call   1040 <printf@plt>
lea    0xee7(%rip),%rdi
call   1040 <printf@plt>
lea    0xef2(%rip),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     11af <remove_modules+0x8f>
lea    0xee9(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <remove_modules+0x9b>
lea    0xef4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_modules>:
push   %rbp
push   %rbx
push   %rax
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
lea    0xeca(%rip),%rdi
call   1040 <system@plt>
mov    %rax,%rbx
test   %rax,%rax
lea    0xee8(%rip),%rax
lea    0xf50(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
call   1040 <system@plt>
test   %rax,%rax
lea    0xee7(%rip),%rcx
lea    0xefc(%rip),%rdi
cmove  %rcx,%rdi
xor    %ebp,%ebp
or     %rbx,%rax
setne  %bpl
neg    %ebp
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"uim: Removing bt_drv \0A\00"
@.str.1 = [13 x i8] c"rmmod bt_drv\00"
@.str.2 = [35 x i8] c"uim: Error removing bt_drv module\0A\00"
@.str.3 = [28 x i8] c"uim: Removed bt_drv module\0A\00"
@.str.4 = [23 x i8] c"uim: Removing st_drv \0A\00"
@.str.5 = [13 x i8] c"rmmod st_drv\00"
@.str.6 = [35 x i8] c"uim: Error removing st_drv module\0A\00"
@.str.7 = [29 x i8] c"uim: Removed st_drv module \0A\00"
define i32 @remove_modules() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%3 = call i64 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%11 = call i64 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %1
br label %17
15: ; preds = %9
%16 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"rmmod bt_drv\00"
@.str.5 = [13 x i8] c"rmmod st_drv\00"
@str = [22 x i8] c"uim: Removing bt_drv \00"
@str.8 = [27 x i8] c"uim: Removed bt_drv module\00"
@str.9 = [22 x i8] c"uim: Removing st_drv \00"
@str.10 = [28 x i8] c"uim: Removed st_drv module \00"
@str.11 = [34 x i8] c"uim: Error removing st_drv module\00"
@str.12 = [34 x i8] c"uim: Error removing bt_drv module\00"
define i32 @remove_modules() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str.12, i64 0, i64 0)
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i64 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str.11, i64 0, i64 0)
%10 = or i64 %7, %2
%11 = icmp ne i64 %10, 0
%12 = sext i1 %11 to i32
%13 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %12
}