#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_string(char *, char *);
int /*<<< orphan*/ reverse_words(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  char str[1024];
  str[0] = '\0';
  strcpy(str, "the world is so small");
  int front = 0;
  int back = strlen(str) - 1;
  printf("%s\n", str);
  reverse_string(&str[front], &str[back]);
  printf("%s\n", str);
  reverse_words(&str[front], &str[back]);
  printf("%s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x410(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x414(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x418(%rbp)
lea    -0x410(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1060 <printf@plt>
movslq -0x414(%rbp),%rax
lea    -0x410(%rbp),%rdi
add    %rax,%rdi
movslq -0x418(%rbp),%rax
lea    -0x410(%rbp),%rsi
add    %rax,%rsi
call   1030 <reverse_string@plt>
lea    -0x410(%rbp),%rsi
lea    0xe2c(%rip),%rdi
call   1060 <printf@plt>
movslq -0x414(%rbp),%rax
lea    -0x410(%rbp),%rdi
add    %rax,%rdi
movslq -0x418(%rbp),%rax
lea    -0x410(%rbp),%rsi
add    %rax,%rsi
call   1070 <reverse_words@plt>
lea    -0x410(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
movb   $0x0,(%rsp)
lea    0xe9a(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
lea    0xe94(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
movslq %ebp,%rax
lea    (%rax,%rbx,1),%rbp
add    $0xffffffffffffffff,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <reverse_string@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <reverse_words@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"the world is so small\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 [1024 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
store i8 0, i8* %9
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %8
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %18
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %21
%23 = call i32 @reverse_string(i8* %19, i8* %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %27
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %30
%32 = call i32 @reverse_words(i8* %28, i8* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"the world is so small\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strlen(i8* %4)
%7 = add nsw i32 %6, -1
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %9
%11 = call i32 @reverse_string(i8* %4, i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%13 = call i32 @reverse_words(i8* %4, i8* %10)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}