#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 *, ...);
int /*<<< orphan*/ reverse(char *);
scalar_t__ strlen(char *);
int main_2(int argc, const char *argv[]) {
  char str[] = "Yet another Hello World (YAHW)";
  printf("\nabout to reverse string: '%s'\n", str);
  printf("strlen %d\n", (unsigned)strlen(str));
  reverse(str);
  printf("reversed string: '%s'\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb2(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xeac(%rip),%ax
mov    %ax,-0x14(%rbp)
mov    0xea4(%rip),%al
mov    %al,-0x12(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x30(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_2>:
push   %rbx
sub    $0x20,%rsp
movups 0xed3(%rip),%xmm0
movups %xmm0,0xf(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xecc(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xed0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
lea    0xec3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main_2.str = [31 x i8] c"Yet another Hello World (YAHW)\00"
@.str = [32 x i8] c"\0Aabout to reverse string: '%s'\0A\00"
@.str.1 = [11 x i8] c"strlen %d\0A\00"
@.str.2 = [23 x i8] c"reversed string: '%s'\0A\00"
define i32 @main_2(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [31 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = bitcast [31 x i8]* %5 to i8*
%7 = getelementptr inbounds [31 x i8], [31 x i8]* %5, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [31 x i8], [31 x i8]* %5, i64 0, i64 0
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [31 x i8], [31 x i8]* %5, i64 0, i64 0
%14 = call i32 @reverse(i8* %13)
%15 = getelementptr inbounds [31 x i8], [31 x i8]* %5, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main_2.str = [31 x i8] c"Yet another Hello World (YAHW)\00"
@.str = [32 x i8] c"\0Aabout to reverse string: '%s'\0A\00"
@.str.1 = [11 x i8] c"strlen %d\0A\00"
@.str.2 = [23 x i8] c"reversed string: '%s'\0A\00"
define i32 @main_2(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [31 x i8]
%4 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i64 @strlen(i8* %4)
%7 = trunc i64 %6 to i32
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @reverse(i8* %4)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}