#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*/ SEEK_SET;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int check_file_cons(FILE *file) {
  int brac = 0, comm = 0;
  char c;
  int ok = 1;
  fseek(file, 0, SEEK_SET);
  while (!feof(file)) {
    fread(&c, 1, 1, file);
    switch (c) {
    case '(':
      brac++;
      break;
    case ')':
      brac--;
      break;
    case '#':
      comm++;
      break;
    }
  }
  fseek(file, 0, SEEK_SET);
  if (brac != 0 || (comm % 2) != 0) {
    ok = 0;
  }
  return ok;
}


x86 assembly (clang, -O0):
<check_file_cons>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1183 <check_file_cons+0x53>
jmp    11f8 <check_file_cons+0xc8>
mov    -0x8(%rbp),%rcx
lea    -0x11(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x23,%eax
je     11ea <check_file_cons+0xba>
jmp    11ac <check_file_cons+0x7c>
mov    -0x1c(%rbp),%eax
sub    $0x28,%eax
je     11ce <check_file_cons+0x9e>
jmp    11bd <check_file_cons+0x8d>
mov    -0x1c(%rbp),%eax
sub    $0x29,%eax
je     11dc <check_file_cons+0xac>
jmp    11f3 <check_file_cons+0xc3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f3 <check_file_cons+0xc3>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11f3 <check_file_cons+0xc3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1165 <check_file_cons+0x35>
mov    -0x8(%rbp),%rdi
mov    0x2ddd(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
cmpl   $0x0,-0xc(%rbp)
jne    122a <check_file_cons+0xfa>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1231 <check_file_cons+0x101>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_file_cons>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2e9a(%rip),%r15
mov    (%r15),%edx
xor    %ebp,%ebp
xor    %esi,%esi
call   1050 <fseek@plt>
mov    %rbx,%rdi
call   1040 <feof@plt>
mov    $0x0,%r12d
test   %eax,%eax
je     118a <check_file_cons+0x5a>
mov    (%r15),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <fseek@plt>
and    $0x1,%r12d
xor    %eax,%eax
or     %ebp,%r12d
sete   %al
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
lea    0xf(%rsp),%r14
xor    %ebp,%ebp
jmp    11af <check_file_cons+0x7f>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    1164 <check_file_cons+0x34>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
movsbl 0xf(%rsp),%eax
cmp    $0x23,%eax
je     11e0 <check_file_cons+0xb0>
cmp    $0x29,%eax
je     11a0 <check_file_cons+0x70>
cmp    $0x28,%eax
jne    11a3 <check_file_cons+0x73>
add    $0x1,%ebp
jmp    11a3 <check_file_cons+0x73>
nopl   (%rax)
add    $0x1,%r12d
jmp    11a3 <check_file_cons+0x73>

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @check_file_cons(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %6
%7 = load i32*, i32** %2
%8 = load i32, i32* @SEEK_SET
%9 = call i32 @fseek(i32* %7, i32 0, i32 %8)
br label %10
10: ; preds = %29, %1
%11 = load i32*, i32** %2
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %30
15: ; preds = %10
%16 = load i32*, i32** %2
%17 = call i32 @fread(i8* %5, i32 1, i32 1, i32* %16)
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
switch i32 %19, label %29 [
i32 40, label %20
i32 41, label %23
i32 35, label %26
]
20: ; preds = %15
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %29
23: ; preds = %15
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
store i32 %25, i32* %3
br label %29
26: ; preds = %15
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %29
29: ; preds = %15, %26, %23, %20
br label %10
30: ; preds = %10
%31 = load i32*, i32** %2
%32 = load i32, i32* @SEEK_SET
%33 = call i32 @fseek(i32* %31, i32 0, i32 %32)
%34 = load i32, i32* %3
%35 = icmp ne i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %30
%37 = load i32, i32* %4
%38 = srem i32 %37, 2
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36, %30
store i32 0, i32* %6
br label %41
41: ; preds = %40, %36
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @check_file_cons(i32* nocapture %0) {
%2 = alloca i8
%3 = load i32, i32* @SEEK_SET
%4 = tail call i32 @fseek(i32* %0, i32 0, i32 %3)
%5 = tail call i32 @feof(i32* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %24
7: ; preds = %1, %19
%8 = phi i32 [ %21, %19 ], [ 0, %1 ]
%9 = phi i32 [ %20, %19 ], [ 0, %1 ]
%10 = call i32 @fread(i8* %2, i32 1, i32 1, i32* %0)
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
switch i32 %12, label %19 [
i32 40, label %13
i32 41, label %15
i32 35, label %17
]
13: ; preds = %7
%14 = add nsw i32 %9, 1
br label %19
15: ; preds = %7
%16 = add nsw i32 %9, -1
br label %19
17: ; preds = %7
%18 = add nsw i32 %8, 1
br label %19
19: ; preds = %7, %17, %15, %13
%20 = phi i32 [ %9, %7 ], [ %9, %17 ], [ %16, %15 ], [ %14, %13 ]
%21 = phi i32 [ %8, %7 ], [ %18, %17 ], [ %8, %15 ], [ %8, %13 ]
%22 = tail call i32 @feof(i32* %0)
%23 = icmp eq i32 %22, 0
br i1 %23, label %7, label %24
24: ; preds = %19, %1
%25 = phi i32 [ 0, %1 ], [ %20, %19 ]
%26 = phi i32 [ 0, %1 ], [ %21, %19 ]
%27 = load i32, i32* @SEEK_SET
%28 = tail call i32 @fseek(i32* %0, i32 0, i32 %27)
%29 = icmp eq i32 %25, 0
%30 = and i32 %26, 1
%31 = icmp eq i32 %30, 0
%32 = select i1 %29, i1 %31, i1 false
%33 = zext i1 %32 to i32
ret i32 %33
}