#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 */
int /*<<< orphan*/ make_empty(char *, int);
char pop(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int top = -1;
  int item;
  int c, t;
  int coun, coun2;
  char n[20], p[20];
  char k[20];
  char u[20];
  char stack[20];
  int j, m, o;
  int intTest;
  int l = strlen(stack);
  int c1, c2, c3, c4;
  c1 = 0;
  c2 = 0;
  c3 = 0;
  c4 = 0;
  intTest = 1;
  char a;
  int i;
  while (intTest == 1) {
    printf("Enter your input that contains parenthesis or Q to quit: \n");
    scanf("%s", n);
    i = strlen(n);
    do {
      scanf("%c", &a);
      n[i++] = a;
    } while (a != '\n');
    n[i - 1] = 0;
    if ((l = strlen(n)) > 20) {
      printf("The input is not balanced.\n");
      continue;
    } else {
      c1 = c2 = c3 = c4 = coun = 0;
      for (j = 0; j < strlen(n); j++) {
        if (n[j] == 'Q') {
          return 0;
        } else {
          if (n[j] == '(') {
            item = n[j];
            push(stack, item);
            coun++;
            ++c1;
          }
          if (n[j] == ')') {
            item = n[j];
            push(stack, item);
            coun++;
            ++c2;
          }
          if (n[j] == '{') {
            item = n[j];
            push(stack, item);
            coun++;
            ++c3;
          }
          if (n[j] == '}') {
            item = n[j];
            push(stack, item);
            coun++;
            ++c4;
          }
        }
      }
      printf("%d\n", coun);
      if (coun == 0) {
        printf("There is no parenthesis or braces in your input.\n");
        continue;
      } else if (coun == 1) {
        printf("The input is not balanced.\n");
        continue;
      } else if (c1 != c2 || c3 != c4) {
        printf("The input is not balanced.\n");
        continue;
      } else if (coun > 1) {
        u[0] = '\0';
        for (o = 0; o < coun; o++) {
          k[o] = pop(stack);
          u[o + 1] = k[o];
          if (u[o] == ')') {
            if (u[o + 1] == '{') {
              printf("The input is not balanced.\n");
              continue;
            }
          } else if (u[o] == '}') {
            if (u[o + 1] == '(') {
              printf("The input is not balanced.\n");
              continue;
            }
          }
        }
        if (k[0] == '(' || k[0] == '{') {
          printf("The input is not balanced.\n");
          continue;
        } else if (k[coun - 1] == ')' || k[coun - 1] == '}') {
          printf("The input is not balanced.\n");
          continue;
        }
      }
    }
    make_empty(p, coun);
  };
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
lea    -0xb0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc4(%rbp)
movl   $0x0,-0xc8(%rbp)
movl   $0x0,-0xcc(%rbp)
movl   $0x0,-0xd0(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x1,-0xc0(%rbp)
cmpl   $0x1,-0xc0(%rbp)
jne    166e <main+0x50e>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xdc(%rbp)
lea    0xe40(%rip),%rdi
lea    -0xd5(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xd5(%rbp),%cl
mov    -0xdc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xdc(%rbp)
cltq
mov    %cl,-0x30(%rbp,%rax,1)
movsbl -0xd5(%rbp),%eax
cmp    $0xa,%eax
jne    11f7 <main+0x97>
mov    -0xdc(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc4(%rbp)
cmp    $0x14,%eax
jle    1272 <main+0x112>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <main+0x5d>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd0(%rbp)
movl   $0x0,-0xcc(%rbp)
movl   $0x0,-0xc8(%rbp)
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
mov    %eax,-0xe0(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xe0(%rbp),%eax
cmp    %ecx,%eax
jge    143b <main+0x2db>
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x51,%eax
jne    12f1 <main+0x191>
movl   $0x0,-0x4(%rbp)
jmp    1675 <main+0x515>
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x28,%eax
jne    133c <main+0x1dc>
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0xc(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <push@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x29,%eax
jne    1387 <main+0x227>
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0xc(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <push@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x7b,%eax
jne    13d2 <main+0x272>
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0xc(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <push@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xd0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd0(%rbp)
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x7d,%eax
jne    141d <main+0x2bd>
movslq -0xb4(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0xc(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <push@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1422 <main+0x2c2>
jmp    1427 <main+0x2c7>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    12ab <main+0x14b>
mov    -0x18(%rbp),%esi
lea    0xc18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1469 <main+0x309>
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <main+0x5d>
cmpl   $0x1,-0x18(%rbp)
jne    1486 <main+0x326>
lea    0xbc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <main+0x5d>
mov    -0xc8(%rbp),%eax
cmp    -0xcc(%rbp),%eax
jne    14aa <main+0x34a>
mov    -0xd0(%rbp),%eax
cmp    -0xd4(%rbp),%eax
je     14bd <main+0x35d>
lea    0xb90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <main+0x5d>
cmpl   $0x1,-0x18(%rbp)
jle    1649 <main+0x4e9>
movb   $0x0,-0x90(%rbp)
movl   $0x0,-0xbc(%rbp)
mov    -0xbc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    15d3 <main+0x473>
lea    -0xb0(%rbp),%rdi
call   1050 <pop@plt>
mov    %al,%cl
movslq -0xbc(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
movslq -0xbc(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x90(%rbp,%rax,1)
movslq -0xbc(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x29,%eax
jne    1569 <main+0x409>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x7b,%eax
jne    1564 <main+0x404>
lea    0xae9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15bf <main+0x45f>
jmp    15ba <main+0x45a>
movslq -0xbc(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x7d,%eax
jne    15b5 <main+0x455>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x28,%eax
jne    15b0 <main+0x450>
lea    0xa9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15bf <main+0x45f>
jmp    15b5 <main+0x455>
jmp    15ba <main+0x45a>
jmp    15bf <main+0x45f>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    14d8 <main+0x378>
movsbl -0x70(%rbp),%eax
cmp    $0x28,%eax
je     15ed <main+0x48d>
movsbl -0x70(%rbp),%eax
cmp    $0x7b,%eax
jne    1600 <main+0x4a0>
lea    0xa4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <main+0x5d>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x29,%eax
je     162c <main+0x4cc>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x7d,%eax
jne    163f <main+0x4df>
lea    0xa0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <main+0x5d>
jmp    1644 <main+0x4e4>
jmp    1649 <main+0x4e9>
jmp    164e <main+0x4ee>
jmp    1653 <main+0x4f3>
jmp    1658 <main+0x4f8>
jmp    165d <main+0x4fd>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1080 <make_empty@plt>
jmp    11bd <main+0x5d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0x30(%rsp),%rdi
call   1040 <strlen@plt>
lea    0xe78(%rip),%r12
lea    0xe67(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe5e(%rip),%r13
lea    0xb(%rsp),%rbp
jmp    11bc <main+0x4c>
nopl   0x0(%rax)
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbx
add    $0x10,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
movzbl 0xb(%rsp),%eax
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    $0xa,%al
jne    11f0 <main+0x80>
movb   $0x0,-0x1(%rbx)
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x14,%eax
jg     11b0 <main+0x40>
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    137c <main+0x20c>
xor    %r12d,%r12d
movl   $0x0,0x28(%rsp)
movl   $0x0,0xc(%rsp)
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    1269 <main+0xf9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r12
jge    1320 <main+0x1b0>
movzbl 0x10(%rsp,%r12,1),%eax
cmp    $0x28,%al
je     1290 <main+0x120>
cmp    $0x51,%al
je     146e <main+0x2fe>
cmp    $0x29,%al
je     12b1 <main+0x141>
cmp    $0x7b,%al
je     12d1 <main+0x161>
cmp    $0x7d,%al
jne    1250 <main+0xe0>
jmp    12f7 <main+0x187>
nopl   0x0(%rax)
lea    0x30(%rsp),%rdi
mov    $0x28,%esi
call   1080 <push@plt>
add    $0x1,%r14d
add    $0x1,%r15d
movzbl 0x10(%rsp,%r12,1),%eax
cmp    $0x29,%al
jne    127f <main+0x10f>
lea    0x30(%rsp),%rdi
mov    $0x29,%esi
call   1080 <push@plt>
add    $0x1,%r14d
add    $0x1,%ebx
movzbl 0x10(%rsp,%r12,1),%eax
cmp    $0x7b,%al
jne    1283 <main+0x113>
lea    0x30(%rsp),%rdi
mov    $0x7b,%esi
call   1080 <push@plt>
add    $0x1,%r14d
addl   $0x1,0xc(%rsp)
movzbl 0x10(%rsp,%r12,1),%eax
cmp    $0x7d,%al
jne    1250 <main+0xe0>
lea    0x30(%rsp),%rdi
mov    $0x7d,%esi
call   1080 <push@plt>
add    $0x1,%r14d
addl   $0x1,0x28(%rsp)
jmp    1250 <main+0xe0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xcdf(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%r14d
je     13fd <main+0x28d>
test   %r14d,%r14d
lea    0xcc5(%rip),%r12
je     138c <main+0x21c>
cmp    %ebx,%r15d
jne    13e8 <main+0x278>
mov    0xc(%rsp),%eax
cmp    0x28(%rsp),%eax
jne    13e8 <main+0x278>
cmp    $0x2,%r14d
lea    0x10(%rsp),%r15
jl     1455 <main+0x2e5>
mov    %r14d,%eax
mov    %rax,0x28(%rsp)
xor    %r12d,%r12d
xor    %ebx,%ebx
jmp    13b6 <main+0x246>
lea    0xc83(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcb1(%rip),%rdi
call   1030 <puts@plt>
jmp    1410 <main+0x2a0>
nopw   0x0(%rax,%rax,1)
lea    0xcce(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%r12d
cmp    %rbx,0x28(%rsp)
je     13f1 <main+0x281>
lea    0x30(%rsp),%rdi
call   1060 <pop@plt>
mov    %eax,%r15d
mov    %al,0x50(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x7d,%r12b
je     13e0 <main+0x270>
cmp    $0x29,%r12b
jne    13ac <main+0x23c>
cmp    $0x7b,%r15b
je     13a0 <main+0x230>
jmp    13ac <main+0x23c>
nop
cmp    $0x28,%r15b
je     13a0 <main+0x230>
jmp    13ac <main+0x23c>
lea    0xc86(%rip),%rdi
jmp    1393 <main+0x223>
mov    0x50(%rsp),%al
cmp    $0x7b,%al
je     13fd <main+0x28d>
cmp    $0x28,%al
jne    1421 <main+0x2b1>
lea    0xc71(%rip),%rdi
call   1030 <puts@plt>
lea    0xbfa(%rip),%r12
lea    0xbe9(%rip),%r14
lea    0x10(%rsp),%r15
jmp    11bc <main+0x4c>
lea    -0x1(%r14),%eax
mov    0x50(%rsp,%rax,1),%al
cmp    $0x7d,%al
lea    0xbd8(%rip),%r12
lea    0x10(%rsp),%r15
je     143d <main+0x2cd>
cmp    $0x29,%al
jne    1455 <main+0x2e5>
lea    0xc31(%rip),%rdi
call   1030 <puts@plt>
lea    0xbb0(%rip),%r14
jmp    11bc <main+0x4c>
lea    0x70(%rsp),%rdi
mov    %r14d,%esi
call   1090 <make_empty@plt>
lea    0xb97(%rip),%r14
jmp    11bc <main+0x4c>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"Enter your input that contains parenthesis or Q to quit: \0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [28 x i8] c"The input is not balanced.\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [50 x i8] c"There is no parenthesis or braces in your input.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [20 x i8]
%9 = alloca [20 x i8]
%10 = alloca [20 x i8]
%11 = alloca [20 x i8]
%12 = alloca [20 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i8
%23 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 1, i32* %16
br label %26
26: ; preds = %276, %268, %250, %175, %165, %160, %54, %0
%27 = load i32, i32* %16
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %280
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
store i32 %34, i32* %23
br label %35
35: ; preds = %42, %29
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%37 = load i8, i8* %22
%38 = load i32, i32* %23
%39 = add nsw i32 %38, 1
store i32 %39, i32* %23
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %40
store i8 %37, i8* %41
br label %42
42: ; preds = %35
%43 = load i8, i8* %22
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 10
br i1 %45, label %35, label %46
46: ; preds = %42
%47 = load i32, i32* %23
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %49
store i8 0, i8* %50
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
store i32 %52, i32* %17
%53 = icmp sgt i32 %52, 20
br i1 %53, label %54, label %56
54: ; preds = %46
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %26
56: ; preds = %46
store i32 0, i32* %6
store i32 0, i32* %21
store i32 0, i32* %20
store i32 0, i32* %19
store i32 0, i32* %18
store i32 0, i32* %13
br label %57
57: ; preds = %152, %56
%58 = load i32, i32* %13
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = icmp slt i32 %58, %60
br i1 %61, label %62, label %155
62: ; preds = %57
%63 = load i32, i32* %13
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 81
br i1 %68, label %69, label %70
69: ; preds = %62
store i32 0, i32* %1
br label %281
70: ; preds = %62
%71 = load i32, i32* %13
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 40
br i1 %76, label %77, label %90
77: ; preds = %70
%78 = load i32, i32* %13
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
store i32 %82, i32* %3
%83 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%84 = load i32, i32* %3
%85 = call i32 @push(i8* %83, i32 %84)
%86 = load i32, i32* %6
%87 = add nsw i32 %86, 1
store i32 %87, i32* %6
%88 = load i32, i32* %18
%89 = add nsw i32 %88, 1
store i32 %89, i32* %18
br label %90
90: ; preds = %77, %70
%91 = load i32, i32* %13
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 41
br i1 %96, label %97, label %110
97: ; preds = %90
%98 = load i32, i32* %13
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %99
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
store i32 %102, i32* %3
%103 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%104 = load i32, i32* %3
%105 = call i32 @push(i8* %103, i32 %104)
%106 = load i32, i32* %6
%107 = add nsw i32 %106, 1
store i32 %107, i32* %6
%108 = load i32, i32* %19
%109 = add nsw i32 %108, 1
store i32 %109, i32* %19
br label %110
110: ; preds = %97, %90
%111 = load i32, i32* %13
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %112
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp eq i32 %115, 123
br i1 %116, label %117, label %130
117: ; preds = %110
%118 = load i32, i32* %13
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %119
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
store i32 %122, i32* %3
%123 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%124 = load i32, i32* %3
%125 = call i32 @push(i8* %123, i32 %124)
%126 = load i32, i32* %6
%127 = add nsw i32 %126, 1
store i32 %127, i32* %6
%128 = load i32, i32* %20
%129 = add nsw i32 %128, 1
store i32 %129, i32* %20
br label %130
130: ; preds = %117, %110
%131 = load i32, i32* %13
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %132
%134 = load i8, i8* %133
%135 = sext i8 %134 to i32
%136 = icmp eq i32 %135, 125
br i1 %136, label %137, label %150
137: ; preds = %130
%138 = load i32, i32* %13
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %139
%141 = load i8, i8* %140
%142 = sext i8 %141 to i32
store i32 %142, i32* %3
%143 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%144 = load i32, i32* %3
%145 = call i32 @push(i8* %143, i32 %144)
%146 = load i32, i32* %6
%147 = add nsw i32 %146, 1
store i32 %147, i32* %6
%148 = load i32, i32* %21
%149 = add nsw i32 %148, 1
store i32 %149, i32* %21
br label %150
150: ; preds = %137, %130
br label %151
151: ; preds = %150
br label %152
152: ; preds = %151
%153 = load i32, i32* %13
%154 = add nsw i32 %153, 1
store i32 %154, i32* %13
br label %57
155: ; preds = %57
%156 = load i32, i32* %6
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %156)
%158 = load i32, i32* %6
%159 = icmp eq i32 %158, 0
br i1 %159, label %160, label %162
160: ; preds = %155
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %26
162: ; preds = %155
%163 = load i32, i32* %6
%164 = icmp eq i32 %163, 1
br i1 %164, label %165, label %167
165: ; preds = %162
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %26
167: ; preds = %162
%168 = load i32, i32* %18
%169 = load i32, i32* %19
%170 = icmp ne i32 %168, %169
br i1 %170, label %175, label %171
171: ; preds = %167
%172 = load i32, i32* %20
%173 = load i32, i32* %21
%174 = icmp ne i32 %172, %173
br i1 %174, label %175, label %177
175: ; preds = %171, %167
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %26
177: ; preds = %171
%178 = load i32, i32* %6
%179 = icmp sgt i32 %178, 1
br i1 %179, label %180, label %272
180: ; preds = %177
%181 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
store i8 0, i8* %181
store i32 0, i32* %15
br label %182
182: ; preds = %237, %180
%183 = load i32, i32* %15
%184 = load i32, i32* %6
%185 = icmp slt i32 %183, %184
br i1 %185, label %186, label %240
186: ; preds = %182
%187 = getelementptr inbounds [20 x i8], [20 x i8]* %12, i64 0, i64 0
%188 = call signext i8 @pop(i8* %187)
%189 = load i32, i32* %15
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %190
store i8 %188, i8* %191
%192 = load i32, i32* %15
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %193
%195 = load i8, i8* %194
%196 = load i32, i32* %15
%197 = add nsw i32 %196, 1
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %198
store i8 %195, i8* %199
%200 = load i32, i32* %15
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %201
%203 = load i8, i8* %202
%204 = sext i8 %203 to i32
%205 = icmp eq i32 %204, 41
br i1 %205, label %206, label %217
206: ; preds = %186
%207 = load i32, i32* %15
%208 = add nsw i32 %207, 1
%209 = sext i32 %208 to i64
%210 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %209
%211 = load i8, i8* %210
%212 = sext i8 %211 to i32
%213 = icmp eq i32 %212, 123
br i1 %213, label %214, label %216
214: ; preds = %206
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %237
216: ; preds = %206
br label %236
217: ; preds = %186
%218 = load i32, i32* %15
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %219
%221 = load i8, i8* %220
%222 = sext i8 %221 to i32
%223 = icmp eq i32 %222, 125
br i1 %223, label %224, label %235
224: ; preds = %217
%225 = load i32, i32* %15
%226 = add nsw i32 %225, 1
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 %227
%229 = load i8, i8* %228
%230 = sext i8 %229 to i32
%231 = icmp eq i32 %230, 40
br i1 %231, label %232, label %234
232: ; preds = %224
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %237
234: ; preds = %224
br label %235
235: ; preds = %234, %217
br label %236
236: ; preds = %235, %216
br label %237
237: ; preds = %236, %232, %214
%238 = load i32, i32* %15
%239 = add nsw i32 %238, 1
store i32 %239, i32* %15
br label %182
240: ; preds = %182
%241 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%242 = load i8, i8* %241
%243 = sext i8 %242 to i32
%244 = icmp eq i32 %243, 40
br i1 %244, label %250, label %245
245: ; preds = %240
%246 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%247 = load i8, i8* %246
%248 = sext i8 %247 to i32
%249 = icmp eq i32 %248, 123
br i1 %249, label %250, label %252
250: ; preds = %245, %240
%251 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %26
252: ; preds = %245
%253 = load i32, i32* %6
%254 = sub nsw i32 %253, 1
%255 = sext i32 %254 to i64
%256 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %255
%257 = load i8, i8* %256
%258 = sext i8 %257 to i32
%259 = icmp eq i32 %258, 41
br i1 %259, label %268, label %260
260: ; preds = %252
%261 = load i32, i32* %6
%262 = sub nsw i32 %261, 1
%263 = sext i32 %262 to i64
%264 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %263
%265 = load i8, i8* %264
%266 = sext i8 %265 to i32
%267 = icmp eq i32 %266, 125
br i1 %267, label %268, label %270
268: ; preds = %260, %252
%269 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %26
270: ; preds = %260
br label %271
271: ; preds = %270
br label %272
272: ; preds = %271, %177
br label %273
273: ; preds = %272
br label %274
274: ; preds = %273
br label %275
275: ; preds = %274
br label %276
276: ; preds = %275
%277 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%278 = load i32, i32* %6
%279 = call i32 @make_empty(i8* %277, i32 %278)
br label %26
280: ; preds = %26
store i32 0, i32* %1
br label %281
281: ; preds = %280, %69
%282 = load i32, i32* %1
ret i32 %282
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [58 x i8] c"Enter your input that contains parenthesis or Q to quit: \00"
@str.12 = [49 x i8] c"There is no parenthesis or braces in your input.\00"
@str.13 = [27 x i8] c"The input is not balanced.\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca [20 x i8]
%5 = alloca i8
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
br label %11
11: ; preds = %34, %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = call i32 @strlen(i8* %6)
%15 = sext i32 %14 to i64
br label %16
16: ; preds = %16, %11
%17 = phi i64 [ %20, %16 ], [ %15, %11 ]
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%19 = load i8, i8* %5
%20 = add i64 %17, 1
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %17
store i8 %19, i8* %21
%22 = icmp eq i8 %19, 10
br i1 %22, label %23, label %16
23: ; preds = %16
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %17
store i8 0, i8* %24
%25 = call i32 @strlen(i8* %6)
%26 = icmp sgt i32 %25, 20
br i1 %26, label %32, label %27
27: ; preds = %23
%28 = call i32 @strlen(i8* %6)
%29 = icmp sgt i32 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 0)
br label %87
32: ; preds = %23
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %34
34: ; preds = %32, %87, %89, %95, %118, %125, %127
br label %11
35: ; preds = %27, %78
%36 = phi i64 [ %81, %78 ], [ 0, %27 ]
%37 = phi i32 [ %80, %78 ], [ 0, %27 ]
%38 = phi i32 [ %72, %78 ], [ 0, %27 ]
%39 = phi i32 [ %62, %78 ], [ 0, %27 ]
%40 = phi i32 [ %52, %78 ], [ 0, %27 ]
%41 = phi i32 [ %79, %78 ], [ 0, %27 ]
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %36
%43 = load i8, i8* %42
switch i8 %43, label %49 [
i8 81, label %129
i8 40, label %44
]
44: ; preds = %35
%45 = call i32 @push(i8* %9, i32 40)
%46 = add nsw i32 %41, 1
%47 = add nsw i32 %40, 1
%48 = load i8, i8* %42
br label %49
49: ; preds = %35, %44
%50 = phi i8 [ %43, %35 ], [ %48, %44 ]
%51 = phi i32 [ %41, %35 ], [ %46, %44 ]
%52 = phi i32 [ %40, %35 ], [ %47, %44 ]
%53 = icmp eq i8 %50, 41
br i1 %53, label %54, label %59
54: ; preds = %49
%55 = call i32 @push(i8* %9, i32 41)
%56 = add nsw i32 %51, 1
%57 = add nsw i32 %39, 1
%58 = load i8, i8* %42
br label %59
59: ; preds = %54, %49
%60 = phi i8 [ %58, %54 ], [ %50, %49 ]
%61 = phi i32 [ %56, %54 ], [ %51, %49 ]
%62 = phi i32 [ %57, %54 ], [ %39, %49 ]
%63 = icmp eq i8 %60, 123
br i1 %63, label %64, label %69
64: ; preds = %59
%65 = call i32 @push(i8* %9, i32 123)
%66 = add nsw i32 %61, 1
%67 = add nsw i32 %38, 1
%68 = load i8, i8* %42
br label %69
69: ; preds = %64, %59
%70 = phi i8 [ %68, %64 ], [ %60, %59 ]
%71 = phi i32 [ %66, %64 ], [ %61, %59 ]
%72 = phi i32 [ %67, %64 ], [ %38, %59 ]
%73 = icmp eq i8 %70, 125
br i1 %73, label %74, label %78
74: ; preds = %69
%75 = call i32 @push(i8* %9, i32 125)
%76 = add nsw i32 %71, 1
%77 = add nsw i32 %37, 1
br label %78
78: ; preds = %74, %69
%79 = phi i32 [ %76, %74 ], [ %71, %69 ]
%80 = phi i32 [ %77, %74 ], [ %37, %69 ]
%81 = add nuw nsw i64 %36, 1
%82 = call i32 @strlen(i8* %6)
%83 = sext i32 %82 to i64
%84 = icmp slt i64 %81, %83
br i1 %84, label %35, label %85
85: ; preds = %78
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %79)
switch i32 %79, label %91 [
i32 0, label %87
i32 1, label %89
]
87: ; preds = %30, %85
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.12, i64 0, i64 0))
br label %34
89: ; preds = %85
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %34
91: ; preds = %85
%92 = icmp eq i32 %52, %62
%93 = icmp eq i32 %72, %80
%94 = select i1 %92, i1 %93, i1 false
br i1 %94, label %97, label %95
95: ; preds = %91
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %34
97: ; preds = %91
%98 = icmp sgt i32 %79, 1
br i1 %98, label %99, label %127
99: ; preds = %97
%100 = zext i32 %79 to i64
br label %101
101: ; preds = %99, %114
%102 = phi i8 [ 0, %99 ], [ %104, %114 ]
%103 = phi i64 [ 0, %99 ], [ %106, %114 ]
%104 = call signext i8 @pop(i8* %9)
%105 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %103
store i8 %104, i8* %105
%106 = add nuw nsw i64 %103, 1
switch i8 %102, label %114 [
i8 41, label %107
i8 125, label %109
]
107: ; preds = %101
%108 = icmp eq i8 %104, 123
br i1 %108, label %111, label %114
109: ; preds = %101
%110 = icmp eq i8 %104, 40
br i1 %110, label %111, label %114
111: ; preds = %109, %107
%112 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0), %107 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0), %109 ]
%113 = call i32 @puts(i8* dereferenceable(1) %112)
br label %114
114: ; preds = %111, %101, %107, %109
%115 = icmp eq i64 %106, %100
br i1 %115, label %116, label %101
116: ; preds = %114
%117 = load i8, i8* %8
switch i8 %117, label %120 [
i8 123, label %118
i8 40, label %118
]
118: ; preds = %116, %116
%119 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %34
120: ; preds = %116
%121 = add nsw i32 %79, -1
%122 = zext i32 %121 to i64
%123 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %122
%124 = load i8, i8* %123
switch i8 %124, label %127 [
i8 41, label %125
i8 125, label %125
]
125: ; preds = %120, %120
%126 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %34
127: ; preds = %120, %97
%128 = call i32 @make_empty(i8* %7, i32 %79)
br label %34
129: ; preds = %35
ret i32 0
}