#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char str[101];
  int i, len, count = 0;
  scanf("%s", str);
  len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == '(')
      count = count + 1;
    else if (str[i] == ')')
      count = count - 1;
    else
      printf("%d ", count);
  }
  printf("#");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7c(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    11e1 <main+0xb1>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x28,%eax
jne    1198 <main+0x68>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11ce <main+0x9e>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x29,%eax
jne    11b8 <main+0x88>
mov    -0x7c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11c9 <main+0x99>
mov    -0x7c(%rbp),%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ce <main+0x9e>
jmp    11d3 <main+0xa3>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    116c <main+0x3c>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xeaf(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11b5 <main+0x75>
mov    %eax,%r15d
lea    0xe91(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1195 <main+0x55>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     11b5 <main+0x75>
movzbl (%rsp,%rbx,1),%eax
cmp    $0x29,%al
je     11b0 <main+0x70>
cmp    $0x28,%al
jne    1180 <main+0x40>
add    $0x1,%ebp
jmp    118c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
jmp    118c <main+0x4c>
mov    $0x23,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %23
6: ; preds = %0
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %19
%9 = phi i64 [ 0, %6 ], [ %21, %19 ]
%10 = phi i32 [ 0, %6 ], [ %20, %19 ]
%11 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %9
%12 = load i8, i8* %11
switch i8 %12, label %17 [
i8 40, label %13
i8 41, label %15
]
13: ; preds = %8
%14 = add nsw i32 %10, 1
br label %19
15: ; preds = %8
%16 = add nsw i32 %10, -1
br label %19
17: ; preds = %8
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %19
19: ; preds = %13, %17, %15
%20 = phi i32 [ %14, %13 ], [ %16, %15 ], [ %10, %17 ]
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %23, label %8
23: ; preds = %19, %0
%24 = call i32 @putchar(i32 35)
ret i32 0
}