#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*/ rev_string(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **args) {
  char test1[] = "wonderful";
  char test2[] = "racecar";
  char test3[] = "1";
  char test4[] = "extremelylong string with spaces";
  rev_string(test1, strlen(test1));
  rev_string(test2, strlen(test2));
  rev_string(test3, strlen(test3));
  rev_string(test4, strlen(test4));
  printf("%s\n", test1);
  printf("%s\n", test2);
  printf("%s\n", test3);
  printf("%s\n", test4);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x22(%rbp)
mov    0xe9b(%rip),%ax
mov    %ax,-0x24(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe9a(%rip),%rsi
mov    $0x21,%edx
call   1060 <memcpy@plt>
lea    -0x1a(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x1a(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    -0x22(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x22(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    -0x24(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    -0x1a(%rbp),%rsi
lea    0xe09(%rip),%rdi
call   1050 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
lea    -0x24(%rbp),%rsi
lea    0xde9(%rip),%rdi
call   1050 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
movabs $0x75667265646e6f77,%rax
72 66 75
mov    %rax,0x8(%rsp)
movw   $0x6c,0x10(%rsp)
movabs $0x72616365636172,%rax
mov    %rax,0x18(%rsp)
movw   $0x31,0x6(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movb   $0x0,0x40(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    0x18(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    0x6(%rsp),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    0x20(%rsp),%r13
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <rev_string@plt>
lea    0xe21(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.test1 = [10 x i8] c"wonderful\00"
@__const.main.test2 = [8 x i8] c"racecar\00"
@__const.main.test3 = [2 x i8] c"1\00"
@__const.main.test4 = [33 x i8] c"extremelylong string with spaces\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [10 x i8]
%6 = alloca [8 x i8]
%7 = alloca [2 x i8]
%8 = alloca [33 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = bitcast [10 x i8]* %5 to i8*
%10 = bitcast [8 x i8]* %6 to i8*
%11 = bitcast [2 x i8]* %7 to i8*
%12 = bitcast [33 x i8]* %8 to i8*
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @rev_string(i8* %13, i32 %15)
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @rev_string(i8* %17, i32 %19)
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @rev_string(i8* %21, i32 %23)
%25 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%26 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = call i32 @rev_string(i8* %25, i32 %27)
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %35)
ret i32 0
}

LLVM IR (-O2):
@__const.main.test1 = [10 x i8] c"wonderful\00"
@__const.main.test4 = [33 x i8] c"extremelylong string with spaces\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = alloca i64
%5 = alloca i16
%6 = alloca [33 x i8]
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%8 = bitcast i64* %4 to i8*
store i64 32195226875683186, i64* %4
%9 = bitcast i16* %5 to i8*
store i16 49, i16* %5
%10 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%11 = call i32 @strlen(i8* %7)
%12 = call i32 @rev_string(i8* %7, i32 %11)
%13 = call i32 @strlen(i8* %8)
%14 = call i32 @rev_string(i8* %8, i32 %13)
%15 = call i32 @strlen(i8* %9)
%16 = call i32 @rev_string(i8* %9, i32 %15)
%17 = call i32 @strlen(i8* %10)
%18 = call i32 @rev_string(i8* %10, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
ret i32 0
}