#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*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ stderr;
void *kvm_open(const char *execfile, const char *corefile, const char *swapfile,
               int flags, const char *errstr) {
  fprintf(stderr, "%s%s/dev/mem: No such file or directory",
          errstr ? errstr : "", errstr ? ": " : "");
  return (0);
}


x86 assembly (clang, -O0):
<kvm_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     114f <kvm_open+0x3f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    115f <kvm_open+0x4f>
lea    0xed4(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    115f <kvm_open+0x4f>
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%rsi
lea    0xeb9(%rip),%rcx
lea    0xeb0(%rip),%rax
cmp    $0x0,%rsi
cmovne %rax,%rcx
lea    0xe79(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kvm_open>:
push   %rax
mov    %r8,%rdx
mov    0x2ec5(%rip),%rax
test   %r8,%r8
lea    0xf05(%rip),%rsi
cmove  %rsi,%rdx
mov    (%rax),%edi
lea    0xef6(%rip),%rcx
cmove  %rsi,%rcx
lea    0xec3(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [40 x i8] c"%s%s/dev/mem: No such file or directory\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c": \00"
define i8* @kvm_open(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %10
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %5
%15 = load i8*, i8** %10
br label %17
16: ; preds = %5
br label %17
17: ; preds = %16, %14
%18 = phi i8* [ %15, %14 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %16 ]
%19 = load i8*, i8** %10
%20 = icmp ne i8* %19, null
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%23 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %22)
ret i8* null
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"%s%s/dev/mem: No such file or directory\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c": \00"
define noalias i8* @kvm_open(i8* nocapture readnone %0, i8* nocapture readnone %1, i8* nocapture readnone %2, i32 %3, i8* %4) {
%6 = load i32, i32* @stderr
%7 = icmp eq i8* %4, null
%8 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %4
%9 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%10 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
ret i8* null
}