#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 */
scalar_t__ do_cow_name(int, char const *);
scalar_t__ is_cow_open(char const *, int);
int do_cow_open(int dirfd, char const *name, int flags) {
  int cowres = 0;
  if (is_cow_open(name, flags)) {
    do {
    } while (0);
    cowres = (do_cow_name(dirfd, name) < 0) ? -1 : 1;
    if (cowres < 0)
      do {
      } while (0);
    else
      do {
      } while (0);
  }
  return cowres;
}


x86 assembly (clang, -O0):
<do_cow_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <is_cow_open@plt>
cmp    $0x0,%rax
je     11a9 <do_cow_open+0x89>
jmp    1154 <do_cow_open+0x34>
jmp    1159 <do_cow_open+0x39>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <do_cow_name@plt>
mov    %rax,%rdx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%rdx
cmovl  %ecx,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1195 <do_cow_open+0x75>
jmp    118b <do_cow_open+0x6b>
jmp    1190 <do_cow_open+0x70>
jmp    11a4 <do_cow_open+0x84>
jmp    119a <do_cow_open+0x7a>
jmp    119f <do_cow_open+0x7f>
jmp    11a4 <do_cow_open+0x84>
jmp    11a9 <do_cow_open+0x89>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_cow_open>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
mov    %edx,%esi
call   1040 <is_cow_open@plt>
test   %rax,%rax
je     1151 <do_cow_open+0x31>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <do_cow_name@plt>
xor    %ecx,%ecx
test   %rax,%rax
setns  %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
jmp    1153 <do_cow_open+0x33>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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