#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 *str_chr(char const *);
char *strchr(char const *, char);
int strlen(char const *);
short is_section_(const char *s) {
  char *p;
  if (!s || strlen(s) < 3) {
    return 0;
  }
  p = str_chr(s);
  if (p != NULL && *p == '[' && *(p + 1) != ']') {
    p = strchr(s, ']');
    if (p != NULL) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_section_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1159 <is_section_+0x29>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jge    1164 <is_section_+0x34>
movw   $0x0,-0x2(%rbp)
jmp    11d0 <is_section_+0xa0>
mov    -0x10(%rbp),%rdi
call   1050 <str_chr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ca <is_section_+0x9a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    11ca <is_section_+0x9a>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5d,%eax
je     11ca <is_section_+0x9a>
mov    -0x10(%rbp),%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c5 <is_section_+0x95>
movw   $0x1,-0x2(%rbp)
jmp    11d0 <is_section_+0xa0>
jmp    11ca <is_section_+0x9a>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_section_>:
push   %rbx
test   %rdi,%rdi
je     1174 <is_section_+0x44>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     1174 <is_section_+0x44>
mov    %rbx,%rdi
call   1050 <str_chr@plt>
test   %rax,%rax
je     1174 <is_section_+0x44>
cmpb   $0x5b,(%rax)
jne    1174 <is_section_+0x44>
cmpb   $0x5d,0x1(%rax)
je     1174 <is_section_+0x44>
mov    %rbx,%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
mov    $0x1,%ax
test   %rcx,%rcx
jne    1176 <is_section_+0x46>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i16 @is_section_(i8* %0) {
%2 = alloca i16
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i16 0, i16* %2
br label %36
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i8* @str_chr(i8* %13)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %35
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 91
br i1 %21, label %22, label %35
22: ; preds = %17
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 93
br i1 %27, label %28, label %35
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = call i8* @strchr(i8* %29, i8 signext 93)
store i8* %30, i8** %4
%31 = load i8*, i8** %4
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %34
33: ; preds = %28
store i16 1, i16* %2
br label %36
34: ; preds = %28
br label %35
35: ; preds = %34, %22, %17, %12
store i16 0, i16* %2
br label %36
36: ; preds = %35, %33, %11
%37 = load i16, i16* %2
ret i16 %37
}

LLVM IR (-O2):
define signext i16 @is_section_(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 3
br i1 %5, label %20, label %6
6: ; preds = %3
%7 = tail call i8* @str_chr(i8* %0)
%8 = icmp eq i8* %7, null
br i1 %8, label %19, label %9
9: ; preds = %6
%10 = load i8, i8* %7
%11 = icmp eq i8 %10, 91
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %7, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 93
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = tail call i8* @strchr(i8* %0, i8 signext 93)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %16, %12, %9, %6
br label %20
20: ; preds = %16, %1, %3, %19
%21 = phi i16 [ 0, %19 ], [ 0, %3 ], [ 0, %1 ], [ 1, %16 ]
ret i16 %21
}