#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 getchar();
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  char c;
  int clb, crb;
  clb = 0;
  crb = 0;
  while (1) {
    if ((c = getchar()) == '\n') {
      if (clb == crb)
        printf("match\n");
      else
        printf("dis match\n");
      break;
    }
    if ('(' == c)
      clb++;
    if (')' == c)
      crb++;
    if (crb > clb) {
      printf("dis match\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
jne    1188 <main+0x68>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1177 <main+0x57>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
jmp    1183 <main+0x63>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    11de <main+0xbe>
movsbl -0x11(%rbp),%ecx
mov    $0x28,%eax
cmp    %ecx,%eax
jne    11a2 <main+0x82>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movsbl -0x11(%rbp),%ecx
mov    $0x29,%eax
cmp    %ecx,%eax
jne    11bc <main+0x9c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11d9 <main+0xb9>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
jmp    11de <main+0xbe>
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xed5(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1150 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %ecx,%ecx
cmp    $0x29,%al
sete   %cl
add    %ecx,%ebx
cmp    %ebp,%ebx
jg     1173 <main+0x53>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x28,%al
je     1140 <main+0x20>
cmp    $0xa,%al
jne    1143 <main+0x23>
cmp    %ebx,%ebp
lea    0xe9c(%rip),%rax
lea    0xe91(%rip),%r14
cmove  %rax,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"match\0A\00"
@.str.1 = [11 x i8] c"dis match\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %2, %42
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %6
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
br label %43
22: ; preds = %9
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = icmp eq i32 40, %24
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %29
29: ; preds = %26, %22
%30 = load i8, i8* %6
%31 = sext i8 %30 to i32
%32 = icmp eq i32 41, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %36
36: ; preds = %33, %29
%37 = load i32, i32* %8
%38 = load i32, i32* %7
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %43
42: ; preds = %36
br label %9
43: ; preds = %40, %21
ret i32 0
}

LLVM IR (-O2):
@str.2 = [10 x i8] c"dis match\00"
@str.3 = [6 x i8] c"match\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %12, %2
%4 = phi i32 [ 0, %2 ], [ %13, %12 ]
%5 = phi i32 [ 0, %2 ], [ %16, %12 ]
%6 = tail call signext i8 (...) @getchar()
switch i8 %6, label %12 [
i8 10, label %7
i8 40, label %10
]
7: ; preds = %3
%8 = icmp eq i32 %4, %5
%9 = select i1 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.2, i64 0, i64 0)
br label %18
10: ; preds = %3
%11 = add nsw i32 %4, 1
br label %12
12: ; preds = %3, %10
%13 = phi i32 [ %11, %10 ], [ %4, %3 ]
%14 = icmp eq i8 %6, 41
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %5, %15
%17 = icmp sgt i32 %16, %13
br i1 %17, label %18, label %3
18: ; preds = %12, %7
%19 = phi i8* [ %9, %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.2, i64 0, i64 0), %12 ]
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
ret i32 0
}