#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 */
scalar_t__ compareStrings(char *, char *);
char *get_last_word(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char const *argv[]) {
  {
    char str[] = "I will do this without using String Library";
    if (compareStrings("Library", get_last_word(str))) {
      printf("Test1 Passed\n");
    } else {
      printf("Test2 Failed\n");
    }
  }
  {
    char str[] = "";
    if (compareStrings("", get_last_word(str))) {
      printf("Test2 Passed\n");
    } else {
      printf("Test2 Failed\n");
    }
  }
  {
    char str[] = "a";
    if (compareStrings("a", get_last_word(str))) {
      printf("Test3 Passed\n");
    } else {
      printf("Test3 Failed, required = %s, Actual = %s\n", "a",
             get_last_word(str));
    }
  }
  {
    char str[] = "	asd";
    char req[] = "asd";
    char *actual = get_last_word(str);
    if (compareStrings(req, actual)) {
      printf("Test4 Passed\n");
    } else {
      printf("Test4 Failed \nActual   = %s \nrequired = %s\n", actual, req);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x2c,%edx
call   1070 <memcpy@plt>
lea    -0x40(%rbp),%rdi
call   1030 <get_last_word@plt>
mov    %rax,%rsi
lea    0xe9e(%rip),%rdi
call   1040 <compareStrings@plt>
cmp    $0x0,%rax
je     11b0 <main+0x60>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11be <main+0x6e>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x41(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <memset@plt>
lea    -0x41(%rbp),%rdi
call   1030 <get_last_word@plt>
mov    %rax,%rsi
lea    0xe6e(%rip),%rdi
call   1040 <compareStrings@plt>
cmp    $0x0,%rax
je     1203 <main+0xb3>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1211 <main+0xc1>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0xe46(%rip),%ax
mov    %ax,-0x43(%rbp)
lea    -0x43(%rbp),%rdi
call   1030 <get_last_word@plt>
mov    %rax,%rsi
lea    0xe2f(%rip),%rdi
call   1040 <compareStrings@plt>
cmp    $0x0,%rax
je     1251 <main+0x101>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1272 <main+0x122>
lea    -0x43(%rbp),%rdi
call   1030 <get_last_word@plt>
mov    %rax,%rdx
lea    0xe0a(%rip),%rdi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0xe20(%rip),%eax
mov    %eax,-0x48(%rbp)
mov    0xe1b(%rip),%al
mov    %al,-0x44(%rbp)
mov    0xe0f(%rip),%eax
mov    %eax,-0x4c(%rbp)
lea    -0x48(%rbp),%rdi
call   1030 <get_last_word@plt>
mov    %rax,-0x58(%rbp)
lea    -0x4c(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1040 <compareStrings@plt>
cmp    $0x0,%rax
je     12c4 <main+0x174>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12da <main+0x18a>
mov    -0x58(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movups 0xed0(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <get_last_word@plt>
lea    0xeb2(%rip),%rdi
mov    %rax,%rsi
call   1040 <compareStrings@plt>
test   %rax,%rax
lea    0xf05(%rip),%rbx
lea    0xf32(%rip),%rdi
cmove  %rbx,%rdi
call   1050 <puts@plt>
movb   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <get_last_word@plt>
lea    0xede(%rip),%rdi
mov    %rax,%rsi
call   1040 <compareStrings@plt>
test   %rax,%rax
lea    0xef4(%rip),%rdi
cmove  %rbx,%rdi
call   1050 <puts@plt>
movw   $0x61,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <get_last_word@plt>
lea    0xe4f(%rip),%rdi
mov    %rax,%rsi
call   1040 <compareStrings@plt>
test   %rax,%rax
je     1200 <main+0xc0>
lea    0xeb2(%rip),%rdi
call   1050 <puts@plt>
jmp    1222 <main+0xe2>
lea    0x10(%rsp),%rdi
call   1030 <get_last_word@plt>
lea    0xe25(%rip),%rdi
lea    0xe1c(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
movb   $0x0,0x14(%rsp)
movl   $0x64736109,0x10(%rsp)
64
movl   $0x647361,0xc(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <get_last_word@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    %rax,%rsi
call   1040 <compareStrings@plt>
test   %rax,%rax
je     1264 <main+0x124>
lea    0xe41(%rip),%rdi
call   1050 <puts@plt>
jmp    127a <main+0x13a>
lea    0xdfa(%rip),%rdi
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str = [44 x i8] c"I will do this without using String Library\00"
@.str = [8 x i8] c"Library\00"
@.str.1 = [14 x i8] c"Test1 Passed\0A\00"
@.str.2 = [14 x i8] c"Test2 Failed\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [14 x i8] c"Test2 Passed\0A\00"
@__const.main.str.5 = [2 x i8] c"a\00"
@.str.6 = [2 x i8] c"a\00"
@.str.7 = [14 x i8] c"Test3 Passed\0A\00"
@.str.8 = [42 x i8] c"Test3 Failed, required = %s, Actual = %s\0A\00"
@__const.main.str.9 = [5 x i8] c"\09asd\00"
@__const.main.req = [4 x i8] c"asd\00"
@.str.10 = [14 x i8] c"Test4 Passed\0A\00"
@.str.11 = [44 x i8] c"Test4 Failed \0AActual = %s \0Arequired = %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [44 x i8]
%7 = alloca [1 x i8]
%8 = alloca [2 x i8]
%9 = alloca [5 x i8]
%10 = alloca [4 x i8]
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [44 x i8]* %6 to i8*
%13 = getelementptr inbounds [44 x i8], [44 x i8]* %6, i64 0, i64 0
%14 = call i8* @get_last_word(i8* %13)
%15 = call i64 @compareStrings(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = bitcast [1 x i8]* %7 to i8*
%23 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%24 = call i8* @get_last_word(i8* %23)
%25 = call i64 @compareStrings(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %31
29: ; preds = %21
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
%32 = bitcast [2 x i8]* %8 to i8*
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%34 = call i8* @get_last_word(i8* %33)
%35 = call i64 @compareStrings(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %43
39: ; preds = %31
%40 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%41 = call i8* @get_last_word(i8* %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %39, %37
%44 = bitcast [5 x i8]* %9 to i8*
%45 = bitcast [4 x i8]* %10 to i8*
%46 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%47 = call i8* @get_last_word(i8* %46)
store i8* %47, i8** %11
%48 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%49 = load i8*, i8** %11
%50 = call i64 @compareStrings(i8* %48, i8* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %43
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
br label %58
54: ; preds = %43
%55 = load i8*, i8** %11
%56 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0), i8* %55, i8* %56)
br label %58
58: ; preds = %54, %52
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [44 x i8] c"I will do this without using String Library\00"
@.str = [8 x i8] c"Library\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.6 = [2 x i8] c"a\00"
@.str.8 = [42 x i8] c"Test3 Failed, required = %s, Actual = %s\0A\00"
@__const.main.str.9 = [5 x i8] c"\09asd\00"
@.str.11 = [44 x i8] c"Test4 Failed \0AActual = %s \0Arequired = %s\0A\00"
@str.12 = [13 x i8] c"Test2 Failed\00"
@str.13 = [13 x i8] c"Test4 Passed\00"
@str.14 = [13 x i8] c"Test3 Passed\00"
@str.15 = [13 x i8] c"Test2 Passed\00"
@str.16 = [13 x i8] c"Test1 Passed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [44 x i8]
%4 = alloca [1 x i8]
%5 = alloca i16
%6 = alloca [5 x i8]
%7 = alloca i32
%8 = getelementptr inbounds [44 x i8], [44 x i8]* %3, i64 0, i64 0
%9 = call i8* @get_last_word(i8* %8)
%10 = call i64 @compareStrings(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.16, i64 0, i64 0)
%13 = call i32 @puts(i8* dereferenceable(1) %12)
%14 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
store i8 0, i8* %14
%15 = call i8* @get_last_word(i8* %14)
%16 = call i64 @compareStrings(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.15, i64 0, i64 0)
%19 = call i32 @puts(i8* dereferenceable(1) %18)
%20 = bitcast i16* %5 to i8*
store i16 97, i16* %5
%21 = call i8* @get_last_word(i8* %20)
%22 = call i64 @compareStrings(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %2
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.14, i64 0, i64 0))
br label %29
26: ; preds = %2
%27 = call i8* @get_last_word(i8* %20)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %24
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%31 = bitcast i32* %7 to i8*
store i32 6583137, i32* %7
%32 = call i8* @get_last_word(i8* %30)
%33 = call i64 @compareStrings(i8* %31, i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %29
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
br label %39
37: ; preds = %29
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i64 0, i64 0), i8* %32, i32* %7)
br label %39
39: ; preds = %37, %35
ret i32 0
}