#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 *);
int str_cmp(char *, char *);
int str_len(char *);
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage: ./test <word1> <word2>\n");
    return 1;
  }
  char *w1 = *(argv + 1);
  char *w2 = *(argv + 2);
  printf("word 1: %s\n", w1);
  printf("word 2: %s\n", w2);
  printf("str_len %s: %d\n", w1, str_len(w1));
  printf("str_len %s: %d\n", w2, str_len(w2));
  printf("str_cmp %s %s: %d\n", w1, w2, str_cmp(w1, w2));
  printf("reverse %s: ", w1);
  reverse(w1);
  printf("%s\n", w1);
  printf("reverse %s: ", w2);
  reverse(w2);
  printf("%s\n", w2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1296 <main+0x156>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <str_len@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <str_len@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <str_cmp@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <reverse@plt>
mov    -0x18(%rbp),%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <reverse@plt>
mov    -0x20(%rbp),%rsi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    121e <main+0xce>
mov    0x8(%rsi),%rbp
mov    0x10(%rsi),%rbx
lea    0xe91(%rip),%rdi
xor    %r14d,%r14d
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1070 <str_len@plt>
lea    0xe7c(%rip),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <str_len@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <str_cmp@plt>
lea    0xe54(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe51(%rip),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1030 <reverse@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
jmp    122b <main+0xdb>
mov    $0x1,%r14d
lea    0xe1d(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: ./test <word1> <word2>\0A\00"
@.str.1 = [12 x i8] c"word 1: %s\0A\00"
@.str.2 = [12 x i8] c"word 2: %s\0A\00"
@.str.3 = [16 x i8] c"str_len %s: %d\0A\00"
@.str.4 = [19 x i8] c"str_cmp %s %s: %d\0A\00"
@.str.5 = [13 x i8] c"reverse %s: \00"
@.str.6 = [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 i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %49
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
store i8* %18, i8** %7
%19 = load i8*, i8** %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %6
%24 = load i8*, i8** %6
%25 = call i32 @str_len(i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %23, i32 %25)
%27 = load i8*, i8** %7
%28 = load i8*, i8** %7
%29 = call i32 @str_len(i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %27, i32 %29)
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = call i32 @str_cmp(i8* %33, i8* %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* %32, i32 %35)
%37 = load i8*, i8** %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = load i8*, i8** %6
%40 = call i32 @reverse(i8* %39)
%41 = load i8*, i8** %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = load i8*, i8** %7
%46 = call i32 @reverse(i8* %45)
%47 = load i8*, i8** %7
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %47)
store i32 0, i32* %3
br label %49
49: ; preds = %12, %10
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"word 1: %s\0A\00"
@.str.2 = [12 x i8] c"word 2: %s\0A\00"
@.str.3 = [16 x i8] c"str_len %s: %d\0A\00"
@.str.4 = [19 x i8] c"str_cmp %s %s: %d\0A\00"
@.str.5 = [13 x i8] c"reverse %s: \00"
@str = [30 x i8] c"Usage: ./test <word1> <word2>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%11 = tail call i32 @str_len(i8* %6)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %6, i32 %11)
%13 = tail call i32 @str_len(i8* %8)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %8, i32 %13)
%15 = tail call i32 @str_cmp(i8* %6, i8* %8)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %6, i8* %8, i32 %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %6)
%18 = tail call i32 @reverse(i8* %6)
%19 = tail call i32 @puts(i8* dereferenceable(1) %6)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%21 = tail call i32 @reverse(i8* %8)
br label %22
22: ; preds = %2, %4
%23 = phi i8* [ %8, %4 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0), %2 ]
%24 = phi i32 [ 0, %4 ], [ 1, %2 ]
%25 = tail call i32 @puts(i8* dereferenceable(1) %23)
ret i32 %24
}