#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
char *reverse(char *);
int /*<<< orphan*/ reverse_in_place(char *);
int /*<<< orphan*/ reverse_zero_additional_memory(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char *test = "testing";
  printf("%s ", test);
  char *first = reverse(test);
  printf(":: %s\n", first);
  char *empty = "";
  printf("%s\n", reverse(empty));
  char *test_mutable = (char *)malloc(14 * sizeof(char));
  strcpy(test_mutable, "more testing!");
  printf("%s ", test_mutable);
  reverse_in_place(test_mutable);
  printf(":: %s\n", test_mutable);
  printf("%s ", test_mutable);
  reverse_zero_additional_memory(test_mutable);
  printf(":: %s\n", test_mutable);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <reverse@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe64(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <reverse@plt>
mov    %rax,%rsi
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
mov    $0xe,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rsi
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1080 <reverse_in_place@plt>
mov    -0x28(%rbp),%rsi
lea    0xe00(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdec(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1070 <reverse_zero_additional_memory@plt>
mov    -0x28(%rbp),%rsi
lea    0xdd7(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xe9c(%rip),%r14
lea    0xe8d(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xe7f(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe73(%rip),%rdi
call   1030 <reverse@plt>
lea    0xe64(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    $0xe,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe4c(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <reverse_in_place@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1070 <reverse_zero_additional_memory@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"testing\00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [7 x i8] c":: %s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [14 x i8] c"more testing!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %2
%9 = call i8* @reverse(i8* %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %10)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8** %4
%12 = load i8*, i8** %4
%13 = call i8* @reverse(i8* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = call i64 @malloc(i32 14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%19 = load i8*, i8** %5
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %5
%22 = call i32 @reverse_in_place(i8* %21)
%23 = load i8*, i8** %5
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %5
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %5
%28 = call i32 @reverse_zero_additional_memory(i8* %27)
%29 = load i8*, i8** %5
%30 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"testing\00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [7 x i8] c":: %s\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [14 x i8] c"more testing!\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @reverse(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%4 = tail call i8* @reverse(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%6 = tail call i64 @malloc(i32 14)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%10 = tail call i32 @reverse_in_place(i8* %7)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%13 = tail call i32 @reverse_zero_additional_memory(i8* %7)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %7)
ret i32 0
}