#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_words(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int failed = 0;
  char line[] = "hello this is easy\n";
  reverse_words(line);
  if (strcmp(line, "easy is this hello\n")) {
    failed = -1;
    printf("error, line %s not equal to 'easy is this hello\n'", line);
  }
  line[0] = '\0';
  reverse_words(line);
  if (strcmp(line, "")) {
    failed = -1;
    printf("error, line %s not equal to ''", line);
  }
  line[0] = '\n';
  line[1] = '\0';
  reverse_words(line);
  if (strcmp(line, "\n")) {
    failed = -1;
    printf("error, line %s not equal to '\n'", line);
  }
  return failed;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xeac(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea9(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xea7(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <reverse_words@plt>
lea    -0x30(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11a6 <main+0x76>
movl   $0xffffffff,-0x14(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
movb   $0x0,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <reverse_words@plt>
lea    -0x30(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11e4 <main+0xb4>
movl   $0xffffffff,-0x14(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
movb   $0xa,-0x30(%rbp)
movb   $0x0,-0x2f(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <reverse_words@plt>
lea    -0x30(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1226 <main+0xf6>
movl   $0xffffffff,-0x14(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movaps 0xec3(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xa7973,0x10(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <reverse_words@plt>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     117e <main+0x4e>
lea    0xeb9(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
jmp    1180 <main+0x50>
xor    %ebp,%ebp
movb   $0x0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <reverse_words@plt>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11b7 <main+0x87>
lea    0xeb0(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
movw   $0xa,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <reverse_words@plt>
lea    0xe57(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11f0 <main+0xc0>
lea    0xe96(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.line = [20 x i8] c"hello this is easy\0A\00"
@.str = [20 x i8] c"easy is this hello\0A\00"
@.str.1 = [50 x i8] c"error, line %s not equal to 'easy is this hello\0A'\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [31 x i8] c"error, line %s not equal to ''\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [32 x i8] c"error, line %s not equal to '\0A'\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = bitcast [20 x i8]* %7 to i8*
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%10 = call i32 @reverse_words(i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
store i32 -1, i32* %6
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %2
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
store i8 0, i8* %18
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%20 = call i32 @reverse_words(i8* %19)
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %17
store i32 -1, i32* %6
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %17
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
store i8 10, i8* %28
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 1
store i8 0, i8* %29
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%31 = call i32 @reverse_words(i8* %30)
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
store i32 -1, i32* %6
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %27
%39 = load i32, i32* %6
ret i32 %39
}

LLVM IR (-O2):
@__const.main.line = [20 x i8] c"hello this is easy\0A\00"
@.str = [20 x i8] c"easy is this hello\0A\00"
@.str.1 = [50 x i8] c"error, line %s not equal to 'easy is this hello\0A'\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [31 x i8] c"error, line %s not equal to ''\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [32 x i8] c"error, line %s not equal to '\0A'\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = call i32 @reverse_words(i8* %4)
%6 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %10
10: ; preds = %8, %2
%11 = phi i32 [ -1, %8 ], [ 0, %2 ]
store i8 0, i8* %4
%12 = call i32 @reverse_words(i8* %4)
%13 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %17
17: ; preds = %15, %10
%18 = phi i32 [ -1, %15 ], [ %11, %10 ]
store i8 10, i8* %4
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 1
store i8 0, i8* %19
%20 = call i32 @reverse_words(i8* %4)
%21 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %25
25: ; preds = %23, %17
%26 = phi i32 [ -1, %23 ], [ %18, %17 ]
ret i32 %26
}