#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 instr(char *, char *, int);
int /*<<< orphan*/ right_trim(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *dictionary_trim_double_bracked_string(char *string) {
  int start, end;
  int str_len;
  str_len = strlen(string);
  if (str_len && *(string + str_len - 1) == ']') {
    if ((start = instr("[", string, 1)) != -1 &&
        (end = instr("]", string, 1)) != -1) {
      strcpy(string + start, string + end + 1);
      right_trim(string);
    }
  }
  return string;
}


x86 assembly (clang, -O0):
<dictionary_trim_double_bracked_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11e7 <dictionary_trim_double_bracked_string+0xa7>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl -0x1(%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    11e7 <dictionary_trim_double_bracked_string+0xa7>
mov    -0x8(%rbp),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x1,%edx
call   1050 <instr@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
je     11e2 <dictionary_trim_double_bracked_string+0xa2>
mov    -0x8(%rbp),%rsi
lea    0xe5e(%rip),%rdi
mov    $0x1,%edx
call   1050 <instr@plt>
mov    %eax,-0x10(%rbp)
cmp    $0xffffffff,%eax
je     11e2 <dictionary_trim_double_bracked_string+0xa2>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1060 <right_trim@plt>
jmp    11e7 <dictionary_trim_double_bracked_string+0xa7>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dictionary_trim_double_bracked_string>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
test   %eax,%eax
je     11a9 <dictionary_trim_double_bracked_string+0x69>
cltq
cmpb   $0x5d,-0x1(%rbx,%rax,1)
jne    11a9 <dictionary_trim_double_bracked_string+0x69>
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <instr@plt>
cmp    $0xffffffff,%eax
je     11a9 <dictionary_trim_double_bracked_string+0x69>
mov    %eax,%ebp
lea    0xe88(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <instr@plt>
cmp    $0xffffffff,%eax
je     11a9 <dictionary_trim_double_bracked_string+0x69>
movslq %ebp,%rdi
add    %rbx,%rdi
cltq
lea    (%rbx,%rax,1),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <right_trim@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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