#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*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int /*<<< orphan*/ trim(char *);
int isLabel(char *line) {
  if (strlen(line) < 2) {
    return 0;
  }
  char *content = strtok(line, "#");
  strcpy(line, content);
  if (line == NULL) {
    return 0;
  }
  trim(line);
  int len = strlen(line);
  if (len < 2) {
    return 0;
  }
  if (line[0] == '[' && line[len - 1] == ']') {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<isLabel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jge    116a <isLabel+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    120a <isLabel+0xca>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11a2 <isLabel+0x62>
movl   $0x0,-0x4(%rbp)
jmp    120a <isLabel+0xca>
mov    -0x10(%rbp),%rdi
call   1050 <trim@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11cd <isLabel+0x8d>
movl   $0x0,-0x4(%rbp)
jmp    120a <isLabel+0xca>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    1203 <isLabel+0xc3>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    1203 <isLabel+0xc3>
movl   $0x1,-0x4(%rbp)
jmp    120a <isLabel+0xca>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isLabel>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x2,%eax
jl     119b <isLabel+0x5b>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
test   %rbx,%rbx
je     119b <isLabel+0x5b>
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     119b <isLabel+0x5b>
cmpb   $0x5b,(%rbx)
jne    1199 <isLabel+0x59>
add    $0xffffffff,%eax
mov    $0x1,%ebp
cmpb   $0x5d,(%rbx,%rax,1)
je     119b <isLabel+0x5b>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"#\00"
define i32 @isLabel(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 2
br i1 %3, label %22, label %4
4: ; preds = %1
%5 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @strcpy(i8* %0, i8* %5)
%7 = icmp eq i8* %0, null
br i1 %7, label %22, label %8
8: ; preds = %4
%9 = tail call i32 @trim(i8* %0)
%10 = tail call i32 @strlen(i8* %0)
%11 = icmp slt i32 %10, 2
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = load i8, i8* %0
%14 = icmp eq i8 %13, 91
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = add nsw i32 %10, -1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 93
br i1 %20, label %22, label %21
21: ; preds = %15, %12
br label %22
22: ; preds = %4, %15, %8, %21, %1
%23 = phi i32 [ 0, %1 ], [ 0, %4 ], [ 0, %21 ], [ 0, %8 ], [ 1, %15 ]
ret i32 %23
}