#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 /*<<< orphan*/ bt_postprocess_string(char *, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
void postprocess(char *string) {
  char *buf;
  buf = (char *)malloc(strlen(string) + 1);
  strcpy(buf, string);
  bt_postprocess_string(buf, 0);
  printf("[%s] -> [%s] (no collapse)\n", string, buf);
  bt_postprocess_string(buf, 8);
  printf("[%s] -> [%s] (collapse)\n", string, buf);
  free(buf);
}


x86 assembly (clang, -O0):
<postprocess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <bt_postprocess_string@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe54(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1050 <bt_postprocess_string@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe4e(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<postprocess>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <bt_postprocess_string@plt>
lea    0xe6c(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1050 <bt_postprocess_string@plt>
lea    0xe69(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <printf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"[%s] -> [%s] (no collapse)\0A\00"
@.str.1 = [25 x i8] c"[%s] -> [%s] (collapse)\0A\00"
define void @postprocess(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strlen(i8* %4)
%6 = add nsw i64 %5, 1
%7 = call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = load i8*, i8** %2
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = load i8*, i8** %3
%13 = call i32 @bt_postprocess_string(i8* %12, i32 0)
%14 = load i8*, i8** %2
%15 = load i8*, i8** %3
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
%17 = load i8*, i8** %3
%18 = call i32 @bt_postprocess_string(i8* %17, i32 8)
%19 = load i8*, i8** %2
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
%22 = load i8*, i8** %3
%23 = call i32 @free(i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"[%s] -> [%s] (no collapse)\0A\00"
@.str.1 = [25 x i8] c"[%s] -> [%s] (collapse)\0A\00"
define void @postprocess(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i64 @malloc(i64 %3)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @strcpy(i8* %5, i8* %0)
%7 = tail call i32 @bt_postprocess_string(i8* %5, i32 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %5)
%9 = tail call i32 @bt_postprocess_string(i8* %5, i32 8)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %5)
%11 = tail call i32 @free(i8* %5)
ret void
}