#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 /*<<< orphan*/ reverse2(char *, int /*<<< orphan*/, scalar_t__);
scalar_t__ strlen(char *);
int main(void) {
  char s[] = "!ynnuf skool sihT";
  printf("%s\n\n", s);
  reverse(s);
  printf("%s\n", s);
  char t[] = "!ynnuf skool sihT";
  reverse2(t, 0, strlen(t) - 1);
  printf("%s\n", t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea4(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1060 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x20(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1060 <printf@plt>
mov    0xe60(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe5d(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe5a(%rip),%ax
mov    %ax,-0x30(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1040 <reverse2@plt>
lea    -0x40(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movw   $0x54,0x30(%rsp)
lea    0xe9f(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xe88(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
movaps 0xe81(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x54,0x10(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <reverse2@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s = [18 x i8] c"!ynnuf skool sihT\00"
@.str = [5 x i8] c"%s\0A\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@__const.main.t = [18 x i8] c"!ynnuf skool sihT\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = alloca [18 x i8]
store i32 0, i32* %1
%4 = bitcast [18 x i8]* %2 to i8*
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%8 = call i32 @reverse(i8* %7)
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = bitcast [18 x i8]* %3 to i8*
%12 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%14 = call i64 @strlen(i8* %13)
%15 = sub nsw i64 %14, 1
%16 = call i32 @reverse2(i8* %12, i32 0, i64 %15)
%17 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s\0A\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@__const.main.t = [18 x i8] c"!ynnuf skool sihT\00"
define i32 @main() {
%1 = alloca [18 x i8]
%2 = alloca [18 x i8]
%3 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%4 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @reverse(i8* %3)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %8, -1
%10 = call i32 @reverse2(i8* %7, i32 0, i64 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
ret i32 0
}