#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 */
struct basl_fio {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ basl_close(struct basl_fio *);
int basl_open(struct basl_fio *, int);
int basl_start(struct basl_fio *in, struct basl_fio *out) {
  int err;
  err = basl_open(in, 0);
  if (!err) {
    err = basl_open(out, 1);
    if (err) {
      basl_close(in);
    }
  }
  return (err);
}


x86 assembly (clang, -O0):
<basl_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <basl_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1171 <basl_start+0x51>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <basl_open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116c <basl_start+0x4c>
mov    -0x8(%rbp),%rdi
call   1030 <basl_close@plt>
jmp    1171 <basl_start+0x51>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basl_start>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <basl_open@plt>
test   %eax,%eax
jne    1157 <basl_start+0x37>
mov    %r14,%rdi
mov    $0x1,%esi
call   1040 <basl_open@plt>
mov    %eax,%ebp
mov    $0x0,%eax
test   %ebp,%ebp
je     1157 <basl_start+0x37>
mov    %rbx,%rdi
call   1030 <basl_close@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.basl_fio = type { i32 }
define i32 @basl_start(%struct.basl_fio* %0, %struct.basl_fio* %1) {
%3 = alloca %struct.basl_fio*
%4 = alloca %struct.basl_fio*
%5 = alloca i32
store %struct.basl_fio* %0, %struct.basl_fio** %3
store %struct.basl_fio* %1, %struct.basl_fio** %4
%6 = load %struct.basl_fio*, %struct.basl_fio** %3
%7 = call i32 @basl_open(%struct.basl_fio* %6, i32 0)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %2
%11 = load %struct.basl_fio*, %struct.basl_fio** %4
%12 = call i32 @basl_open(%struct.basl_fio* %11, i32 1)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load %struct.basl_fio*, %struct.basl_fio** %3
%17 = call i32 @basl_close(%struct.basl_fio* %16)
br label %18
18: ; preds = %15, %10
br label %19
19: ; preds = %18, %2
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
%struct.basl_fio = type { i32 }
define i32 @basl_start(%struct.basl_fio* %0, %struct.basl_fio* %1) {
%3 = tail call i32 @basl_open(%struct.basl_fio* %0, i32 0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i32 @basl_open(%struct.basl_fio* %1, i32 1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @basl_close(%struct.basl_fio* %0)
br label %10
10: ; preds = %5, %8, %2
%11 = phi i32 [ %3, %2 ], [ %6, %8 ], [ 0, %5 ]
ret i32 %11
}