#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);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int i, j, k, len, b[1000], c[1000];
  char a[10000];
  scanf("%s", a);
  len = strlen(a);
  j = 0, k = 0;
  for (i = 0; i < len; i++) {
    if (a[i] == '[') {
      b[j] = i;
      printf("%d\n", b[j]);
      j++;
    } else if (a[i] == ']') {
      c[k] = i;
      printf("%d\n", c[k]);
      k++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4670,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x4670(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x4670(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1228 <main+0xf8>
movslq -0x8(%rbp),%rax
movsbl -0x4670(%rbp,%rax,1),%eax
ff
cmp    $0x5b,%eax
jne    11cd <main+0x9d>
mov    -0x8(%rbp),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0xfc0(%rbp,%rax,4)
movslq -0xc(%rbp),%rax
mov    -0xfc0(%rbp,%rax,4),%esi
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1215 <main+0xe5>
movslq -0x8(%rbp),%rax
movsbl -0x4670(%rbp,%rax,1),%eax
ff
cmp    $0x5d,%eax
jne    1210 <main+0xe0>
mov    -0x8(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x1f60(%rbp,%rax,4)
movslq -0x10(%rbp),%rax
mov    -0x1f60(%rbp,%rax,4),%esi
lea    0xe01(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1215 <main+0xe5>
jmp    121a <main+0xea>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1179 <main+0x49>
xor    %eax,%eax
add    $0x4670,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x2710,%rsp
lea    0xebd(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1191 <main+0x61>
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0xe9d(%rip),%r14
jmp    1183 <main+0x53>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     1191 <main+0x61>
movzbl (%rsp,%rbx,1),%eax
cmp    $0x5d,%al
je     1170 <main+0x40>
cmp    $0x5b,%al
je     1170 <main+0x40>
jmp    117a <main+0x4a>
xor    %eax,%eax
add    $0x2710,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1000 x i32]
%7 = alloca [1000 x i32]
%8 = alloca [10000 x i8]
store i32 0, i32* %1
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %5
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %2
br label %13
13: ; preds = %57, %0
%14 = load i32, i32* %2
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %60
17: ; preds = %13
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 91
br i1 %23, label %24, label %36
24: ; preds = %17
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1000 x i32], [1000 x i32]* %6, i64 0, i64 %27
store i32 %25, i32* %28
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1000 x i32], [1000 x i32]* %6, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %56
36: ; preds = %17
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 93
br i1 %42, label %43, label %55
43: ; preds = %36
%44 = load i32, i32* %2
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [1000 x i32], [1000 x i32]* %7, i64 0, i64 %46
store i32 %44, i32* %47
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1000 x i32], [1000 x i32]* %7, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
br label %55
55: ; preds = %43, %36
br label %56
56: ; preds = %55, %24
br label %57
57: ; preds = %56
%58 = load i32, i32* %2
%59 = add nsw i32 %58, 1
store i32 %59, i32* %2
br label %13
60: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = getelementptr inbounds [10000 x i8], [10000 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 %18
6: ; preds = %0
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %15
%9 = phi i64 [ 0, %6 ], [ %16, %15 ]
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %15 [
i8 91, label %12
i8 93, label %12
]
12: ; preds = %8, %8
%13 = trunc i64 %9 to i32
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %8
%16 = add nuw nsw i64 %9, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %18, label %8
18: ; preds = %15, %0
ret i32 0
}