#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*/ printf(char *, char *);
int /*<<< orphan*/ reverse(char *);
int main(int argc, char **argv) {
  char s[] = ".esrever rof tset elpmis a si sihT";
  char t[] = "KO";
  printf("Reversing '%s': ", s);
  reverse(s);
  printf("%s\n", s);
  printf("Reversing '%s': ", t);
  reverse(t);
  printf("%s\n", t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x23,%edx
call   1050 <memcpy@plt>
mov    0xec1(%rip),%ax
mov    %ax,-0x43(%rbp)
mov    0xeb9(%rip),%al
mov    %al,-0x41(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x40(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    -0x43(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
lea    -0x43(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x43(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x546869,0x2f(%rsp)
movb   $0x0,0xe(%rsp)
movw   $0x4f4b,0xc(%rsp)
lea    0xeca(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xebc(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s = [35 x i8] c".esrever rof tset elpmis a si sihT\00"
@__const.main.t = [3 x i8] c"KO\00"
@.str = [17 x i8] c"Reversing '%s': \00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [35 x i8]
%7 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [35 x i8]* %6 to i8*
%9 = bitcast [3 x i8]* %7 to i8*
%10 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%13 = call i32 @reverse(i8* %12)
%14 = getelementptr inbounds [35 x i8], [35 x i8]* %6, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%19 = call i32 @reverse(i8* %18)
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [35 x i8] c".esrever rof tset elpmis a si sihT\00"
@__const.main.t = [3 x i8] c"KO\00"
@.str = [17 x i8] c"Reversing '%s': \00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [35 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [35 x i8], [35 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = call i32 @reverse(i8* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
%11 = call i32 @reverse(i8* %6)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
ret i32 0
}