#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 strlen(char *);
int clean_section(char *text) {
  int i;
  if (text[0] != '[')
    return 0;
  for (i = 0; i <= strlen(text); i++) {
    if (text[i + 1] == ']') {
      text[i] = '\0';
      return 1;
    }
    text[i] = text[i + 1];
  }
  return 1;
}


x86 assembly (clang, -O0):
<clean_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     1138 <clean_section+0x28>
movl   $0x0,-0x4(%rbp)
jmp    11bd <clean_section+0xad>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     11b6 <clean_section+0xa6>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    118d <clean_section+0x7d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
jmp    11bd <clean_section+0xad>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <clean_section+0x2f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_section>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
cmpb   $0x5b,(%rdi)
jne    1167 <clean_section+0x57>
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
js     1167 <clean_section+0x57>
mov    $0xffffffffffffffff,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x2(%rbx,%rbp,1),%eax
cmp    $0x5d,%al
je     1162 <clean_section+0x52>
mov    %al,0x1(%rbx,%rbp,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    $0x1,%rbp
cmp    %rax,%rbp
jl     1140 <clean_section+0x30>
jmp    1167 <clean_section+0x57>
movb   $0x0,0x1(%rbx,%rbp,1)
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @clean_section(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 91
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %46
11: ; preds = %1
store i32 0, i32* %4
br label %12
12: ; preds = %42, %11
%13 = load i32, i32* %4
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
%16 = icmp sle i32 %13, %15
br i1 %16, label %17, label %45
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 93
br i1 %25, label %26, label %31
26: ; preds = %17
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 0, i8* %30
store i32 1, i32* %2
br label %46
31: ; preds = %17
%32 = load i8*, i8** %3
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = load i8, i8* %36
%38 = load i8*, i8** %3
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 %37, i8* %41
br label %42
42: ; preds = %31
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %12
45: ; preds = %12
store i32 1, i32* %2
br label %46
46: ; preds = %45, %26, %10
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
define i32 @clean_section(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 91
br i1 %3, label %4, label %21
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %4, %16
%8 = phi i64 [ %9, %16 ], [ 0, %4 ]
%9 = add nuw nsw i64 %8, 1
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 93
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = and i64 %8, 4294967295
%15 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 0, i8* %15
br label %21
16: ; preds = %7
%17 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %11, i8* %17
%18 = tail call i32 @strlen(i8* %0)
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %8, %19
br i1 %20, label %7, label %21
21: ; preds = %16, %4, %1, %13
%22 = phi i32 [ 1, %13 ], [ 0, %1 ], [ 1, %4 ], [ 1, %16 ]
ret i32 %22
}