#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char const *, char const *);
FILE *xfopen(const char *path, const char *mode, FILE *minus_meaning) {
  if (minus_meaning && path && (path[0] == '-') && (path[1] == 0))
    return minus_meaning;
  return fopen(path, mode);
}


x86 assembly (clang, -O0):
<xfopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1168 <xfopen+0x58>
cmpq   $0x0,-0x10(%rbp)
je     1168 <xfopen+0x58>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1168 <xfopen+0x58>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1168 <xfopen+0x58>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1179 <xfopen+0x69>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfopen>:
test   %rdi,%rdi
je     1125 <xfopen+0x15>
test   %rdx,%rdx
je     1125 <xfopen+0x15>
cmpb   $0x2d,(%rdi)
jne    1125 <xfopen+0x15>
cmpb   $0x0,0x1(%rdi)
je     112a <xfopen+0x1a>
jmp    1030 <fopen@plt>
mov    %rdx,%rax
ret

LLVM IR (-O0):
define i32* @xfopen(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%8 = load i32*, i32** %7
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %27
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 45
br i1 %18, label %19, label %27
19: ; preds = %13
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = load i32*, i32** %7
store i32* %26, i32** %4
br label %31
27: ; preds = %19, %13, %10, %3
%28 = load i8*, i8** %5
%29 = load i8*, i8** %6
%30 = call i32* @fopen(i8* %28, i8* %29)
store i32* %30, i32** %4
br label %31
31: ; preds = %27, %25
%32 = load i32*, i32** %4
ret i32* %32
}

LLVM IR (-O2):
define i32* @xfopen(i8* %0, i8* nocapture %1, i32* readnone %2) {
%4 = icmp ne i32* %2, null
%5 = icmp ne i8* %0, null
%6 = and i1 %5, %4
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 45
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10, %7, %3
%15 = tail call i32* @fopen(i8* %0, i8* %1)
br label %16
16: ; preds = %10, %14
%17 = phi i32* [ %15, %14 ], [ %2, %10 ]
ret i32* %17
}