#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 */
typedef int /*<<< orphan*/ string;

/* Variables and functions */
int /*<<< orphan*/ stringEquals(char *, char *);
int main() {
  char string[] = "reverseThis";
  char reverseTestString[] = "sihTesrever";
  char reverseString[sizeof(string)];
  int reverseI = 0;
  for (int i = sizeof(string) - 2; i >= 0; i--) {
    reverseString[reverseI++] = string[i];
  }
  reverseString[reverseI] = '\0';
  stringEquals(reverseTestString, reverseString);
  stringEquals(string, reverseString);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xed0(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0xa,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     1186 <main+0x76>
movslq -0x30(%rbp),%rax
mov    -0x10(%rbp,%rax,1),%cl
mov    -0x2c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
cltq
mov    %cl,-0x28(%rbp,%rax,1)
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    1155 <main+0x45>
movslq -0x2c(%rbp),%rax
movb   $0x0,-0x28(%rbp,%rax,1)
lea    -0x1c(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <stringEquals@plt>
lea    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <stringEquals@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movabs $0x5465737265766572,%rax
73 65 54
mov    %rax,0x18(%rsp)
movl   $0x736968,0x20(%rsp)
movabs $0x6572736554686973,%rax
73 72 65
mov    %rax,0x8(%rsp)
movl   $0x726576,0x10(%rsp)
mov    %rax,0x24(%rsp)
movl   $0x726576,0x2c(%rsp)
lea    0x8(%rsp),%rdi
lea    0x24(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <stringEquals@plt>
lea    0x18(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <stringEquals@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.string = [12 x i8] c"reverseThis\00"
@__const.main.reverseTestString = [12 x i8] c"sihTesrever\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca [12 x i8]
%4 = alloca [12 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [12 x i8]* %2 to i8*
%8 = bitcast [12 x i8]* %3 to i8*
store i32 0, i32* %5
store i32 10, i32* %6
br label %9
9: ; preds = %21, %0
%10 = load i32, i32* %6
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 %19
store i8 %16, i8* %20
br label %21
21: ; preds = %12
%22 = load i32, i32* %6
%23 = add nsw i32 %22, -1
store i32 %23, i32* %6
br label %9
24: ; preds = %9
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 %26
store i8 0, i8* %27
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%30 = call i32 @stringEquals(i8* %28, i8* %29)
%31 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%32 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%33 = call i32 @stringEquals(i8* %31, i8* %32)
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@__const.main.string = [12 x i8] c"reverseThis\00"
@__const.main.reverseTestString = [12 x i8] c"sihTesrever\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = alloca [12 x i8]
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
store i8 115, i8* %6
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 1
store i8 105, i8* %7
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 2
store i8 104, i8* %8
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 3
store i8 84, i8* %9
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 4
store i8 101, i8* %10
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 5
store i8 115, i8* %11
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 6
store i8 114, i8* %12
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 7
store i8 101, i8* %13
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 8
store i8 118, i8* %14
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 9
store i8 101, i8* %15
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 10
store i8 114, i8* %16
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 11
store i8 0, i8* %17
%18 = call i32 @stringEquals(i8* %5, i8* %6)
%19 = call i32 @stringEquals(i8* %4, i8* %6)
ret i32 0
}