#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*/ print_log(char *);
int /*<<< orphan*/ printf(char *);
int system(char *);
void check_for_virtualbox() {
  print_log("checking for virtualbox");
  int exit_code = system("which virtualbox >/dev/null 2>&1");
  if (exit_code == 256) {
    printf("I cannot find virtualbox on your computer.\n");
    printf("Please install virtualbox, then run me again.\n");
    exit(1);
  } else if (exit_code == 0) {
    print_log("-- virtualbox exists");
    print_log("-- moving on...");
  } else {
    printf("I could not find virtualbox on your computer.\n");
    printf("I got an error when I looked for it.\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check_for_virtualbox>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <print_log@plt>
lea    0xebd(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jne    1192 <check_for_virtualbox+0x52>
lea    0xec2(%rip),%rdi
call   1050 <printf@plt>
lea    0xee2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11b9 <check_for_virtualbox+0x79>
lea    0xef1(%rip),%rdi
call   1030 <print_log@plt>
lea    0xefa(%rip),%rdi
call   1030 <print_log@plt>
jmp    11db <check_for_virtualbox+0x9b>
lea    0xef9(%rip),%rdi
call   1050 <printf@plt>
lea    0xf1c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11e0 <check_for_virtualbox+0xa0>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_virtualbox>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <print_log@plt>
lea    0xec4(%rip),%rdi
call   1050 <system@plt>
test   %eax,%eax
jne    1176 <check_for_virtualbox+0x36>
lea    0xed5(%rip),%rdi
call   1040 <print_log@plt>
lea    0xede(%rip),%rdi
pop    %rax
jmp    1040 <print_log@plt>
cmp    $0x100,%eax
jne    1192 <check_for_virtualbox+0x52>
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4c(%rip),%rdi
jmp    11a5 <check_for_virtualbox+0x65>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"checking for virtualbox\00"
@.str.1 = [33 x i8] c"which virtualbox >/dev/null 2>&1\00"
@.str.2 = [44 x i8] c"I cannot find virtualbox on your computer.\0A\00"
@.str.3 = [47 x i8] c"Please install virtualbox, then run me again.\0A\00"
@.str.4 = [21 x i8] c"-- virtualbox exists\00"
@.str.5 = [16 x i8] c"-- moving on...\00"
@.str.6 = [47 x i8] c"I could not find virtualbox on your computer.\0A\00"
@.str.7 = [38 x i8] c"I got an error when I looked for it.\0A\00"
define void @check_for_virtualbox() {
%1 = alloca i32
%2 = call i32 @print_log(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 256
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @print_log(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @print_log(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %20
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13
br label %21
21: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"checking for virtualbox\00"
@.str.1 = [33 x i8] c"which virtualbox >/dev/null 2>&1\00"
@.str.4 = [21 x i8] c"-- virtualbox exists\00"
@.str.5 = [16 x i8] c"-- moving on...\00"
@str = [46 x i8] c"I could not find virtualbox on your computer.\00"
@str.8 = [37 x i8] c"I got an error when I looked for it.\00"
@str.9 = [43 x i8] c"I cannot find virtualbox on your computer.\00"
@str.10 = [46 x i8] c"Please install virtualbox, then run me again.\00"
define void @check_for_virtualbox() {
%1 = tail call i32 @print_log(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @system(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
switch i32 %2, label %10 [
i32 256, label %3
i32 0, label %7
]
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.10, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @print_log(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @print_log(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
ret void
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.8, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
}