#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 *realloc(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int remove_char(int pos, char **edit_buffer, char **temp_buffer, int alloc_size,
                int *fail) {
  if ((int)strlen(*edit_buffer) * 4 <= alloc_size) {
    char *realloc_buffer;
    alloc_size /= 2;
    *edit_buffer = (realloc_buffer = realloc(*edit_buffer, alloc_size));
    *temp_buffer = (realloc_buffer = realloc(*temp_buffer, alloc_size));
  }
  if (*edit_buffer != NULL && *temp_buffer != NULL) {
    strcpy(*temp_buffer, *edit_buffer + pos);
    strncat(*temp_buffer, *edit_buffer, pos - 1);
    strcpy(*edit_buffer, *temp_buffer + (strlen(*temp_buffer) - (pos - 1)));
    strncat(*edit_buffer, *temp_buffer, (strlen(*temp_buffer) - (pos + 1)));
  } else {
    *fail = 0;
  }
  return alloc_size;
}


x86 assembly (clang, -O0):
<remove_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
shl    $0x2,%eax
cmp    -0x1c(%rbp),%eax
jg     11ba <remove_char+0x7a>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <realloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <realloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1283 <remove_char+0x143>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1283 <remove_char+0x143>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
movslq -0x4(%rbp),%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x4(%rbp),%edx
sub    $0x1,%edx
call   1050 <strncat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdi
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
sub    %ecx,%eax
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
mov    -0x4(%rbp),%eax
add    $0x1,%eax
sub    %eax,%edx
call   1050 <strncat@plt>
jmp    128d <remove_char+0x14d>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r15
mov    %ecx,%r13d
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r12d
mov    (%rsi),%rdi
call   1040 <strlen@plt>
shl    $0x2,%eax
cmp    %r13d,%eax
jg     1192 <remove_char+0x52>
mov    %r13d,%ebp
shr    $0x1f,%ebp
add    %r13d,%ebp
sar    %ebp
mov    (%rbx),%rdi
mov    %ebp,%esi
call   1060 <realloc@plt>
mov    %rax,(%rbx)
mov    (%r14),%rdi
mov    %ebp,%esi
call   1060 <realloc@plt>
mov    %rax,(%r14)
mov    %ebp,%r13d
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1204 <remove_char+0xc4>
mov    (%r14),%rdi
test   %rdi,%rdi
je     1204 <remove_char+0xc4>
movslq %r12d,%rbp
add    %rbp,%rsi
call   1030 <strcpy@plt>
mov    (%r14),%rdi
mov    (%rbx),%rsi
lea    -0x1(%rbp),%r15d
mov    %r15d,%edx
call   1050 <strncat@plt>
mov    (%rbx),%rax
mov    %rax,(%rsp)
mov    (%r14),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
sub    %r15d,%eax
movslq %eax,%rsi
add    %r12,%rsi
mov    (%rsp),%rdi
call   1030 <strcpy@plt>
mov    (%rbx),%r15
mov    (%r14),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
not    %ebp
add    %eax,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <strncat@plt>
jmp    120b <remove_char+0xcb>
movl   $0x0,(%r15)
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @remove_char(i32 %0, i8** %1, i8** %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%12 = load i8**, i8*** %7
%13 = load i8*, i8** %12
%14 = call i32 @strlen(i8* %13)
%15 = mul nsw i32 %14, 4
%16 = load i32, i32* %9
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %31
18: ; preds = %5
%19 = load i32, i32* %9
%20 = sdiv i32 %19, 2
store i32 %20, i32* %9
%21 = load i8**, i8*** %7
%22 = load i8*, i8** %21
%23 = load i32, i32* %9
%24 = call i8* @realloc(i8* %22, i32 %23)
store i8* %24, i8** %11
%25 = load i8**, i8*** %7
store i8* %24, i8** %25
%26 = load i8**, i8*** %8
%27 = load i8*, i8** %26
%28 = load i32, i32* %9
%29 = call i8* @realloc(i8* %27, i32 %28)
store i8* %29, i8** %11
%30 = load i8**, i8*** %8
store i8* %29, i8** %30
br label %31
31: ; preds = %18, %5
%32 = load i8**, i8*** %7
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %79
35: ; preds = %31
%36 = load i8**, i8*** %8
%37 = load i8*, i8** %36
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %79
39: ; preds = %35
%40 = load i8**, i8*** %8
%41 = load i8*, i8** %40
%42 = load i8**, i8*** %7
%43 = load i8*, i8** %42
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = call i32 @strcpy(i8* %41, i8* %46)
%48 = load i8**, i8*** %8
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %7
%51 = load i8*, i8** %50
%52 = load i32, i32* %6
%53 = sub nsw i32 %52, 1
%54 = call i32 @strncat(i8* %49, i8* %51, i32 %53)
%55 = load i8**, i8*** %7
%56 = load i8*, i8** %55
%57 = load i8**, i8*** %8
%58 = load i8*, i8** %57
%59 = load i8**, i8*** %8
%60 = load i8*, i8** %59
%61 = call i32 @strlen(i8* %60)
%62 = load i32, i32* %6
%63 = sub nsw i32 %62, 1
%64 = sub nsw i32 %61, %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %58, i64 %65
%67 = call i32 @strcpy(i8* %56, i8* %66)
%68 = load i8**, i8*** %7
%69 = load i8*, i8** %68
%70 = load i8**, i8*** %8
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %8
%73 = load i8*, i8** %72
%74 = call i32 @strlen(i8* %73)
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
%77 = sub nsw i32 %74, %76
%78 = call i32 @strncat(i8* %69, i8* %71, i32 %77)
br label %81
79: ; preds = %35, %31
%80 = load i32*, i32** %10
store i32 0, i32* %80
br label %81
81: ; preds = %79, %39
%82 = load i32, i32* %9
ret i32 %82
}

LLVM IR (-O2):
define i32 @remove_char(i32 %0, i8** nocapture %1, i8** nocapture %2, i32 %3, i32* nocapture writeonly %4) {
%6 = load i8*, i8** %1
%7 = tail call i32 @strlen(i8* %6)
%8 = shl nsw i32 %7, 2
%9 = icmp sgt i32 %8, %3
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = sdiv i32 %3, 2
%12 = load i8*, i8** %1
%13 = tail call i8* @realloc(i8* %12, i32 %11)
store i8* %13, i8** %1
%14 = load i8*, i8** %2
%15 = tail call i8* @realloc(i8* %14, i32 %11)
store i8* %15, i8** %2
br label %16
16: ; preds = %10, %5
%17 = phi i32 [ %11, %10 ], [ %3, %5 ]
%18 = load i8*, i8** %1
%19 = icmp eq i8* %18, null
br i1 %19, label %44, label %20
20: ; preds = %16
%21 = load i8*, i8** %2
%22 = icmp eq i8* %21, null
br i1 %22, label %44, label %23
23: ; preds = %20
%24 = sext i32 %0 to i64
%25 = getelementptr inbounds i8, i8* %18, i64 %24
%26 = tail call i32 @strcpy(i8* %21, i8* %25)
%27 = load i8*, i8** %2
%28 = load i8*, i8** %1
%29 = add nsw i32 %0, -1
%30 = tail call i32 @strncat(i8* %27, i8* %28, i32 %29)
%31 = load i8*, i8** %1
%32 = load i8*, i8** %2
%33 = tail call i32 @strlen(i8* %32)
%34 = sub nsw i32 %33, %29
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = tail call i32 @strcpy(i8* %31, i8* %36)
%38 = load i8*, i8** %1
%39 = load i8*, i8** %2
%40 = tail call i32 @strlen(i8* %39)
%41 = xor i32 %0, -1
%42 = add i32 %40, %41
%43 = tail call i32 @strncat(i8* %38, i8* %39, i32 %42)
br label %45
44: ; preds = %20, %16
store i32 0, i32* %4
br label %45
45: ; preds = %44, %23
ret i32 %17
}