#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() {
  char foo[40] = "Learning C is fun and challenging.";
  printf("Before: %s\n", foo);
  reverse(foo);
  printf(" After: %s\n", foo);
  char bar[30] = "Hello out there!";
  printf("Before: %s\n", bar);
  reverse(bar);
  printf(" After: %s\n", bar);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rsi
lea    0xeef(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x30(%rbp),%rsi
lea    0xee2(%rip),%rdi
call   1040 <printf@plt>
mov    0xeac(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea9(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xea6(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xea4(%rip),%eax
mov    %eax,-0x38(%rbp)
mov    0xe9e(%rip),%ax
mov    %ax,-0x34(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x50(%rbp),%rsi
lea    0xe84(%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    $0x50,%rsp
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x2e67,0x40(%rsp)
lea    0xefd(%rip),%r14
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xeea(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
movups 0xebc(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %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    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.foo = [40 x i8] c"Learning C is fun and challenging.\00\00\00\00\00\00"
@.str = [12 x i8] c"Before: %s\0A\00"
@.str.1 = [12 x i8] c" After: %s\0A\00"
@__const.main.bar = [30 x i8] c"Hello out there!\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [40 x i8]
%3 = alloca [30 x i8]
store i32 0, i32* %1
%4 = bitcast [40 x i8]* %2 to i8*
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%8 = call i32 @reverse(i8* %7)
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = bitcast [30 x i8]* %3 to i8*
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%15 = call i32 @reverse(i8* %14)
%16 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.foo = [40 x i8] c"Learning C is fun and challenging.\00\00\00\00\00\00"
@.str = [12 x i8] c"Before: %s\0A\00"
@.str.1 = [12 x i8] c" After: %s\0A\00"
@__const.main.bar = [30 x i8] c"Hello out there!\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%4 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @reverse(i8* %3)
%6 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i32 @reverse(i8* %7)
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %7)
ret i32 0
}