#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*/ AT_FDCWD;
scalar_t__ do_cow_name(int /*<<< orphan*/, char const *);
scalar_t__ is_cow_fopen(char const *, char const *);
int do_cow_fopen(char const *name, char const *mode) {
  int cowres = 0;
  if (is_cow_fopen(name, mode)) {
    do {
    } while (0);
    cowres = (do_cow_name(AT_FDCWD, name) < 0) ? -1 : 1;
    if (cowres < 0)
      do {
      } while (0);
    else
      do {
      } while (0);
  }
  return cowres;
}


x86 assembly (clang, -O0):
<do_cow_fopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <is_cow_fopen@plt>
cmp    $0x0,%rax
je     11ae <do_cow_fopen+0x8e>
jmp    1153 <do_cow_fopen+0x33>
jmp    1158 <do_cow_fopen+0x38>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1040 <do_cow_name@plt>
mov    %rax,%rdx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%rdx
cmovl  %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    119a <do_cow_fopen+0x7a>
jmp    1190 <do_cow_fopen+0x70>
jmp    1195 <do_cow_fopen+0x75>
jmp    11a9 <do_cow_fopen+0x89>
jmp    119f <do_cow_fopen+0x7f>
jmp    11a4 <do_cow_fopen+0x84>
jmp    11a9 <do_cow_fopen+0x89>
jmp    11ae <do_cow_fopen+0x8e>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_cow_fopen>:
push   %rbx
mov    %rdi,%rbx
call   1030 <is_cow_fopen@plt>
test   %rax,%rax
je     114f <do_cow_fopen+0x2f>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1040 <do_cow_name@plt>
xor    %ecx,%ecx
test   %rax,%rax
setns  %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@AT_FDCWD = global i32 0
define i32 @do_cow_fopen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i64 @is_cow_fopen(i8* %6, i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %28
10: ; preds = %2
br label %11
11: ; preds = %10
br label %12
12: ; preds = %11
%13 = load i32, i32* @AT_FDCWD
%14 = load i8*, i8** %3
%15 = call i64 @do_cow_name(i32 %13, i8* %14)
%16 = icmp slt i64 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 -1, i32 1
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %12
br label %22
22: ; preds = %21
br label %23
23: ; preds = %22
br label %27
24: ; preds = %12
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26, %23
br label %28
28: ; preds = %27, %2
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
@AT_FDCWD = global i32 0
define i32 @do_cow_fopen(i8* %0, i8* %1) {
%3 = tail call i64 @is_cow_fopen(i8* %0, i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @AT_FDCWD
%7 = tail call i64 @do_cow_name(i32 %6, i8* %0)
%8 = icmp slt i64 %7, 0
%9 = select i1 %8, i32 -1, i32 1
br label %10
10: ; preds = %5, %2
%11 = phi i32 [ %9, %5 ], [ 0, %2 ]
ret i32 %11
}