#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 */
char get_top_paren();
scalar_t__ is_match(char, int);
int /*<<< orphan*/ pop_paren();
int /*<<< orphan*/ push_paren(int);
int check_paren_match(int cur_char) {
  extern int state;
  char pre_paren;
  if (state == 0) {
    if (cur_char == '(' || cur_char == '[' || cur_char == '{') {
      push_paren(cur_char);
    } else {
      if (cur_char == ')' || cur_char == ']' || cur_char == '}') {
        pre_paren = get_top_paren();
        if (pre_paren != ' ' && is_match(pre_paren, cur_char)) {
          pop_paren();
        } else {
          return 0;
        }
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_paren_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2e8e(%rip),%rax
cmpl   $0x0,(%rax)
jne    11fa <check_paren_match+0xba>
cmpl   $0x28,-0x8(%rbp)
je     1179 <check_paren_match+0x39>
cmpl   $0x5b,-0x8(%rbp)
je     1179 <check_paren_match+0x39>
cmpl   $0x7b,-0x8(%rbp)
jne    1186 <check_paren_match+0x46>
mov    -0x8(%rbp),%edi
call   1050 <push_paren@plt>
jmp    11f5 <check_paren_match+0xb5>
cmpl   $0x29,-0x8(%rbp)
je     11a4 <check_paren_match+0x64>
cmpl   $0x5d,-0x8(%rbp)
je     11a4 <check_paren_match+0x64>
cmpl   $0x7d,-0x8(%rbp)
jne    11f0 <check_paren_match+0xb0>
mov    $0x0,%al
call   1030 <get_top_paren@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
je     11df <check_paren_match+0x9f>
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%esi
movsbl %al,%edi
call   1060 <is_match@plt>
cmp    $0x0,%rax
je     11df <check_paren_match+0x9f>
mov    $0x0,%al
call   1040 <pop_paren@plt>
jmp    11eb <check_paren_match+0xab>
movl   $0x0,-0x4(%rbp)
jmp    1201 <check_paren_match+0xc1>
jmp    11f0 <check_paren_match+0xb0>
jmp    11f5 <check_paren_match+0xb5>
jmp    11fa <check_paren_match+0xba>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_paren_match>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rax
mov    $0x1,%ebx
cmpl   $0x0,(%rax)
jne    11b5 <check_paren_match+0x75>
mov    %edi,%r14d
lea    -0x5b(%r14),%eax
cmp    $0x22,%eax
ja     1176 <check_paren_match+0x36>
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    $0x1,%ebx
jmp    *%rax
cmp    $0x29,%r14d
je     118c <check_paren_match+0x4c>
cmp    $0x28,%r14d
jne    11b5 <check_paren_match+0x75>
mov    %r14d,%edi
call   1050 <push_paren@plt>
jmp    11b0 <check_paren_match+0x70>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get_top_paren@plt>
cmp    $0x20,%al
je     11b5 <check_paren_match+0x75>
movsbl %al,%edi
mov    %r14d,%esi
call   1060 <is_match@plt>
test   %rax,%rax
je     11b5 <check_paren_match+0x75>
xor    %eax,%eax
call   1040 <pop_paren@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@state = external global i32
define i32 @check_paren_match(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
%5 = load i32, i32* @state
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %44
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 40
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 91
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 123
br i1 %15, label %16, label %19
16: ; preds = %13, %10, %7
%17 = load i32, i32* %3
%18 = call i32 @push_paren(i32 %17)
br label %43
19: ; preds = %13
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 41
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 93
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 125
br i1 %27, label %28, label %42
28: ; preds = %25, %22, %19
%29 = call signext i8 (...) @get_top_paren()
store i8 %29, i8* %4
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 32
br i1 %32, label %33, label %40
33: ; preds = %28
%34 = load i8, i8* %4
%35 = load i32, i32* %3
%36 = call i64 @is_match(i8 signext %34, i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 (...) @pop_paren()
br label %41
40: ; preds = %33, %28
store i32 0, i32* %2
br label %45
41: ; preds = %38
br label %42
42: ; preds = %41, %25
br label %43
43: ; preds = %42, %16
br label %44
44: ; preds = %43, %1
store i32 1, i32* %2
br label %45
45: ; preds = %44, %40
%46 = load i32, i32* %2
ret i32 %46
}

LLVM IR (-O2):
@state = external global i32
define i32 @check_paren_match(i32 %0) {
%2 = load i32, i32* @state
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %15
4: ; preds = %1
switch i32 %0, label %15 [
i32 123, label %5
i32 91, label %5
i32 40, label %5
i32 125, label %7
i32 93, label %7
i32 41, label %7
]
5: ; preds = %4, %4, %4
%6 = tail call i32 @push_paren(i32 %0)
br label %15
7: ; preds = %4, %4, %4
%8 = tail call signext i8 (...) @get_top_paren()
%9 = icmp eq i8 %8, 32
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = tail call i64 @is_match(i8 signext %8, i32 %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 (...) @pop_paren()
br label %15
15: ; preds = %4, %1, %13, %5, %7, %10
%16 = phi i32 [ 0, %10 ], [ 0, %7 ], [ 1, %5 ], [ 1, %13 ], [ 1, %1 ], [ 1, %4 ]
ret i32 %16
}