#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*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
int IsTreeAvail(FILE *fv) {
  char ch;
  ch = fgetc(fv);
  while (!feof(fv) && ch != '(' && ch != '[')
    ch = fgetc(fv);
  if (ch == '(' || ch == '[')
    ungetc(ch, fv);
  return (!feof(fv));
}


x86 assembly (clang, -O0):
<IsTreeAvail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xa(%rbp)
jne    1180 <IsTreeAvail+0x50>
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0x28,%ecx
mov    %al,-0xa(%rbp)
je     1180 <IsTreeAvail+0x50>
movsbl -0x9(%rbp),%eax
cmp    $0x5b,%eax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    1190 <IsTreeAvail+0x60>
jmp    11a1 <IsTreeAvail+0x71>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x9(%rbp)
jmp    1148 <IsTreeAvail+0x18>
movsbl -0x9(%rbp),%eax
cmp    $0x28,%eax
je     11bb <IsTreeAvail+0x8b>
movsbl -0x9(%rbp),%eax
cmp    $0x5b,%eax
jne    11ca <IsTreeAvail+0x9a>
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1050 <ungetc@plt>
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsTreeAvail>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
call   1030 <fgetc@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    1162 <IsTreeAvail+0x32>
cmp    $0x28,%bl
je     116c <IsTreeAvail+0x3c>
cmp    $0x5b,%bl
je     116c <IsTreeAvail+0x3c>
mov    %r14,%rdi
jmp    1140 <IsTreeAvail+0x10>
cmp    $0x28,%bl
je     116c <IsTreeAvail+0x3c>
cmp    $0x5b,%bl
jne    1177 <IsTreeAvail+0x47>
movsbl %bl,%edi
mov    %r14,%rsi
call   1050 <ungetc@plt>
mov    %r14,%rdi
call   1040 <feof@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @IsTreeAvail(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call signext i8 @fgetc(i32* %4)
store i8 %5, i8* %3
br label %6
6: ; preds = %20, %1
%7 = load i32*, i32** %2
%8 = call i32 @feof(i32* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 40
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 91
br label %18
18: ; preds = %14, %10, %6
%19 = phi i1 [ false, %10 ], [ false, %6 ], [ %17, %14 ]
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = load i32*, i32** %2
%22 = call signext i8 @fgetc(i32* %21)
store i8 %22, i8* %3
br label %6
23: ; preds = %18
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 40
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 91
br i1 %30, label %31, label %35
31: ; preds = %27, %23
%32 = load i8, i8* %3
%33 = load i32*, i32** %2
%34 = call i32 @ungetc(i8 signext %32, i32* %33)
br label %35
35: ; preds = %31, %27
%36 = load i32*, i32** %2
%37 = call i32 @feof(i32* %36)
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
%40 = zext i1 %39 to i32
ret i32 %40
}

LLVM IR (-O2):
define i32 @IsTreeAvail(i32* nocapture %0) {
%2 = tail call signext i8 @fgetc(i32* %0)
%3 = tail call i32 @feof(i32* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %1, %7
%6 = phi i8 [ %8, %7 ], [ %2, %1 ]
switch i8 %6, label %7 [
i8 91, label %13
i8 40, label %13
]
7: ; preds = %5
%8 = tail call signext i8 @fgetc(i32* %0)
%9 = tail call i32 @feof(i32* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %7, %1
%12 = phi i8 [ %2, %1 ], [ %8, %7 ]
switch i8 %12, label %16 [
i8 91, label %13
i8 40, label %13
]
13: ; preds = %5, %5, %11, %11
%14 = phi i8 [ %12, %11 ], [ %12, %11 ], [ %6, %5 ], [ %6, %5 ]
%15 = tail call i32 @ungetc(i8 signext %14, i32* %0)
br label %16
16: ; preds = %11, %13
%17 = tail call i32 @feof(i32* %0)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
ret i32 %19
}