#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 *);
void remove_brakets(char **buffer) {
  (*buffer)++;
  int i = 0, len = strlen(*buffer);
  while ((*buffer)[len - ++i] != ']')
    ;
  (*buffer)[len - i] = '\0';
}


x86 assembly (clang, -O0):
<remove_brakets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
sub    %edx,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
je     116a <remove_brakets+0x5a>
jmp    1140 <remove_brakets+0x30>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_brakets>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
add    $0x1,%rdi
mov    %rdi,(%rbx)
call   1030 <strlen@plt>
cltq
add    (%rbx),%rax
nopl   0x0(%rax,%rax,1)
cmpb   $0x5d,-0x1(%rax)
lea    -0x1(%rax),%rax
jne    1130 <remove_brakets+0x20>
movb   $0x0,(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define void @remove_brakets(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %5
store i32 0, i32* %3
%8 = load i8**, i8*** %2
%9 = load i8*, i8** %8
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %4
br label %11
11: ; preds = %23, %1
%12 = load i8**, i8*** %2
%13 = load i8*, i8** %12
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
%17 = sub nsw i32 %14, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %13, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 93
br i1 %22, label %23, label %24
23: ; preds = %11
br label %11
24: ; preds = %11
%25 = load i8**, i8*** %2
%26 = load i8*, i8** %25
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = sub nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %26, i64 %30
store i8 0, i8* %31
ret void
}

LLVM IR (-O2):
define void @remove_brakets(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = getelementptr inbounds i8, i8* %2, i64 1
store i8* %3, i8** %0
%4 = tail call i32 @strlen(i8* %3)
%5 = load i8*, i8** %0
%6 = sext i32 %4 to i64
br label %7
7: ; preds = %7, %1
%8 = phi i64 [ %9, %7 ], [ 0, %1 ]
%9 = add nuw nsw i64 %8, 1
%10 = sub nsw i64 %6, %9
%11 = getelementptr inbounds i8, i8* %5, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 93
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = getelementptr inbounds i8, i8* %5, i64 %10
store i8 0, i8* %15
ret void
}