#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
char *reverse_string(char *);
void test_reverse_string_again() {
  char *buffer = malloc(400);
  for (int i = 0; i < 400; i++) {
    buffer[i] = i;
  }
  free(buffer);
  char *reversed = reverse_string("123");
  printf("%s\n", reversed);
}


x86 assembly (clang, -O0):
<test_reverse_string_again>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x190,%edi
call   1060 <malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x190,-0xc(%rbp)
jge    1188 <test_reverse_string_again+0x48>
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <test_reverse_string_again+0x1d>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
lea    0xe68(%rip),%rdi
call   1040 <reverse_string@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_reverse_string_again>:
push   %rax
mov    $0x190,%edi
call   1060 <malloc@plt>
movaps 0xead(%rip),%xmm8
movups %xmm8,(%rax)
movaps 0xeb1(%rip),%xmm9
movups %xmm9,0x10(%rax)
movaps 0xeb5(%rip),%xmm2
movups %xmm2,0x20(%rax)
movaps 0xeba(%rip),%xmm3
movups %xmm3,0x30(%rax)
movaps 0xebf(%rip),%xmm4
movups %xmm4,0x40(%rax)
movaps 0xec4(%rip),%xmm5
movups %xmm5,0x50(%rax)
movaps 0xec9(%rip),%xmm6
movups %xmm6,0x60(%rax)
movaps 0xece(%rip),%xmm7
movups %xmm7,0x70(%rax)
movaps 0xed3(%rip),%xmm0
movups %xmm0,0x80(%rax)
movaps 0xed5(%rip),%xmm1
movups %xmm1,0x90(%rax)
movaps 0xed7(%rip),%xmm1
movups %xmm1,0xa0(%rax)
movaps 0xed9(%rip),%xmm1
movups %xmm1,0xb0(%rax)
movaps 0xedb(%rip),%xmm1
movups %xmm1,0xc0(%rax)
movaps 0xedd(%rip),%xmm1
movups %xmm1,0xd0(%rax)
movaps 0xedf(%rip),%xmm1
movups %xmm1,0xe0(%rax)
movaps 0xee1(%rip),%xmm1
movups %xmm1,0xf0(%rax)
movups %xmm8,0x100(%rax)
movups %xmm9,0x110(%rax)
movups %xmm2,0x120(%rax)
movups %xmm3,0x130(%rax)
movups %xmm4,0x140(%rax)
movups %xmm5,0x150(%rax)
movups %xmm6,0x160(%rax)
movups %xmm7,0x170(%rax)
movups %xmm0,0x180(%rax)
mov    %rax,%rdi
call   1030 <free@plt>
lea    0xe9a(%rip),%rdi
call   1040 <reverse_string@plt>
lea    0xe92(%rip),%rdi
mov    %rax,%rsi
pop    %rax
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"123\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @test_reverse_string_again() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = call i8* @malloc(i32 400)
store i8* %4, i8** %1
store i32 0, i32* %2
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 400
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = trunc i32 %9 to i8
%11 = load i8*, i8** %1
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8 %10, i8* %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %5
18: ; preds = %5
%19 = load i8*, i8** %1
%20 = call i32 @free(i8* %19)
%21 = call i8* @reverse_string(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"123\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @test_reverse_string_again() {
%1 = tail call dereferenceable_or_null(400) i8* @malloc(i32 400)
%2 = bitcast i8* %1 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %2
%3 = getelementptr inbounds i8, i8* %1, i64 16
%4 = bitcast i8* %3 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %4
%5 = getelementptr inbounds i8, i8* %1, i64 32
%6 = bitcast i8* %5 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %6
%7 = getelementptr inbounds i8, i8* %1, i64 48
%8 = bitcast i8* %7 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %8
%9 = getelementptr inbounds i8, i8* %1, i64 64
%10 = bitcast i8* %9 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %10
%11 = getelementptr inbounds i8, i8* %1, i64 80
%12 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %12
%13 = getelementptr inbounds i8, i8* %1, i64 96
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %14
%15 = getelementptr inbounds i8, i8* %1, i64 112
%16 = bitcast i8* %15 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %16
%17 = getelementptr inbounds i8, i8* %1, i64 128
%18 = bitcast i8* %17 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %18
%19 = getelementptr inbounds i8, i8* %1, i64 144
%20 = bitcast i8* %19 to <16 x i8>*
store <16 x i8> <i8 -112, i8 -111, i8 -110, i8 -109, i8 -108, i8 -107, i8 -106, i8 -105, i8 -104, i8 -103, i8 -102, i8 -101, i8 -100, i8 -99, i8 -98, i8 -97>, <16 x i8>* %20
%21 = getelementptr inbounds i8, i8* %1, i64 160
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> <i8 -96, i8 -95, i8 -94, i8 -93, i8 -92, i8 -91, i8 -90, i8 -89, i8 -88, i8 -87, i8 -86, i8 -85, i8 -84, i8 -83, i8 -82, i8 -81>, <16 x i8>* %22
%23 = getelementptr inbounds i8, i8* %1, i64 176
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> <i8 -80, i8 -79, i8 -78, i8 -77, i8 -76, i8 -75, i8 -74, i8 -73, i8 -72, i8 -71, i8 -70, i8 -69, i8 -68, i8 -67, i8 -66, i8 -65>, <16 x i8>* %24
%25 = getelementptr inbounds i8, i8* %1, i64 192
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> <i8 -64, i8 -63, i8 -62, i8 -61, i8 -60, i8 -59, i8 -58, i8 -57, i8 -56, i8 -55, i8 -54, i8 -53, i8 -52, i8 -51, i8 -50, i8 -49>, <16 x i8>* %26
%27 = getelementptr inbounds i8, i8* %1, i64 208
%28 = bitcast i8* %27 to <16 x i8>*
store <16 x i8> <i8 -48, i8 -47, i8 -46, i8 -45, i8 -44, i8 -43, i8 -42, i8 -41, i8 -40, i8 -39, i8 -38, i8 -37, i8 -36, i8 -35, i8 -34, i8 -33>, <16 x i8>* %28
%29 = getelementptr inbounds i8, i8* %1, i64 224
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> <i8 -32, i8 -31, i8 -30, i8 -29, i8 -28, i8 -27, i8 -26, i8 -25, i8 -24, i8 -23, i8 -22, i8 -21, i8 -20, i8 -19, i8 -18, i8 -17>, <16 x i8>* %30
%31 = getelementptr inbounds i8, i8* %1, i64 240
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> <i8 -16, i8 -15, i8 -14, i8 -13, i8 -12, i8 -11, i8 -10, i8 -9, i8 -8, i8 -7, i8 -6, i8 -5, i8 -4, i8 -3, i8 -2, i8 -1>, <16 x i8>* %32
%33 = getelementptr inbounds i8, i8* %1, i64 256
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %34
%35 = getelementptr inbounds i8, i8* %1, i64 272
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %36
%37 = getelementptr inbounds i8, i8* %1, i64 288
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %38
%39 = getelementptr inbounds i8, i8* %1, i64 304
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %40
%41 = getelementptr inbounds i8, i8* %1, i64 320
%42 = bitcast i8* %41 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %42
%43 = getelementptr inbounds i8, i8* %1, i64 336
%44 = bitcast i8* %43 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %44
%45 = getelementptr inbounds i8, i8* %1, i64 352
%46 = bitcast i8* %45 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %46
%47 = getelementptr inbounds i8, i8* %1, i64 368
%48 = bitcast i8* %47 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %48
%49 = getelementptr inbounds i8, i8* %1, i64 384
%50 = bitcast i8* %49 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %50
%51 = tail call i32 @free(i8* %1)
%52 = tail call i8* @reverse_string(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%53 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %52)
ret void
}