#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*/ gets(char *);
int len(char *);
int /*<<< orphan*/ puts(char *);
int main() {
  char string[80];
  int count = 0;
  puts("Enter the expression with () brackets:");
  gets(string);
  for (int i = 0; i < len(string); i++) {
    if (string[i] == '(')
      count++;
    if (string[i] == ')') {
      count--;
      if (count < 0)
        break;
    }
  }
  if (count == 0)
    puts("No error in the expression.");
  else
    puts("The expression has error(s).");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x64(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
lea    -0x60(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x6c(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <len@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    11db <main+0xab>
movslq -0x68(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x28,%eax
jne    1199 <main+0x69>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
movslq -0x68(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x29,%eax
jne    11c8 <main+0x98>
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    11c3 <main+0x93>
jmp    11db <main+0xab>
jmp    11c8 <main+0x98>
jmp    11cd <main+0x9d>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1162 <main+0x32>
cmpl   $0x0,-0x64(%rbp)
jne    11f6 <main+0xc6>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
jmp    1202 <main+0xd2>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xebf(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <len@plt>
lea    0xec7(%rip),%r14
test   %eax,%eax
jle    11ad <main+0x7d>
xor    %ebx,%ebx
mov    %rsp,%r15
xor    %ebp,%ebp
jmp    1183 <main+0x53>
nopl   (%rax)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <len@plt>
cltq
cmp    %rax,%rbx
jge    11a2 <main+0x72>
mov    %ebp,%eax
movzbl (%rsp,%rbx,1),%ecx
xor    %ebp,%ebp
cmp    $0x28,%cl
sete   %bpl
add    %eax,%ebp
cmp    $0x29,%cl
jne    1170 <main+0x40>
test   %ebp,%ebp
jle    11a6 <main+0x76>
add    $0xffffffff,%ebp
jmp    1170 <main+0x40>
test   %ebp,%ebp
je     11ad <main+0x7d>
lea    0xe96(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Enter the expression with () brackets:\00"
@.str.1 = [28 x i8] c"No error in the expression.\00"
@.str.2 = [29 x i8] c"The expression has error(s).\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
store i32 0, i32* %4
br label %8
8: ; preds = %38, %0
%9 = load i32, i32* %4
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%11 = call i32 @len(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %41
13: ; preds = %8
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 40
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %23
23: ; preds = %20, %13
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 41
br i1 %29, label %30, label %37
30: ; preds = %23
%31 = load i32, i32* %3
%32 = add nsw i32 %31, -1
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
br label %41
36: ; preds = %30
br label %37
37: ; preds = %36, %23
br label %38
38: ; preds = %37
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %8
41: ; preds = %35, %8
%42 = load i32, i32* %3
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %48
46: ; preds = %41
%47 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Enter the expression with () brackets:\00"
@.str.1 = [28 x i8] c"No error in the expression.\00"
@.str.2 = [29 x i8] c"The expression has error(s).\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @len(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %28
7: ; preds = %0, %19
%8 = phi i64 [ %21, %19 ], [ 0, %0 ]
%9 = phi i32 [ %20, %19 ], [ 0, %0 ]
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %8
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 40
%13 = zext i1 %12 to i32
%14 = add nsw i32 %9, %13
%15 = icmp eq i8 %11, 41
br i1 %15, label %16, label %19
16: ; preds = %7
%17 = add nsw i32 %14, -1
%18 = icmp slt i32 %14, 1
br i1 %18, label %27, label %19
19: ; preds = %7, %16
%20 = phi i32 [ %17, %16 ], [ %14, %7 ]
%21 = add nuw nsw i64 %8, 1
%22 = call i32 @len(i8* %2)
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %7, label %25
25: ; preds = %19
%26 = icmp eq i32 %20, 0
br i1 %26, label %28, label %27
27: ; preds = %16, %25
br label %28
28: ; preds = %25, %0, %27
%29 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), %27 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), %25 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
ret i32 0
}