#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 open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int mbox_open() {
  int file_desc;
  file_desc = open("/dev/vcio", 0);
  if (file_desc < 0) {
    printf("Can't open device file: %s\n", "/dev/vcio");
    printf("Try creating a device file with: sudo mknod %s c %d 0\n",
           "/dev/vcio", 100);
    exit(-1);
  }
  return file_desc;
}


x86 assembly (clang, -O0):
<mbox_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %esi,%esi
call   1040 <open@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    118c <mbox_open+0x5c>
lea    0xeb0(%rip),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x64,%edx
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mbox_open>:
push   %rbx
lea    0xec8(%rip),%rdi
xor    %esi,%esi
call   1040 <open@plt>
test   %eax,%eax
js     1145 <mbox_open+0x15>
pop    %rbx
ret
lea    0xebe(%rip),%rdi
lea    0xead(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x64,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/vcio\00"
@.str.1 = [28 x i8] c"Can't open device file: %s\0A\00"
@.str.2 = [55 x i8] c"Try creating a device file with: sudo mknod %s c %d 0\0A\00"
define i32 @mbox_open() {
%1 = alloca i32
%2 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 100)
%8 = call i32 @exit(i32 -1)
unreachable
9: ; preds = %0
%10 = load i32, i32* %1
ret i32 %10
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/vcio\00"
@.str.1 = [28 x i8] c"Can't open device file: %s\0A\00"
@.str.2 = [55 x i8] c"Try creating a device file with: sudo mknod %s c %d 0\0A\00"
define i32 @mbox_open() {
%1 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 100)
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %0
ret i32 %1
}