#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 */
char *StrSearch(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
char *strstr(char *, char *);
void TestStrSearch() {
  char str1[] = "test StrSearch StrStrStr";
  char str2[] = "StrSearch with Null\0 Following character "
                "should not be searched";
  char str_empty[] = "";
  char *res1, *res2;
  printf("===========================\n"
         "Test StrSearch\n"
         "===========================\n");
  printf("Test1:\n");
  res1 = StrSearch(str1, "Str");
  res2 = strstr(str1, "Str");
  ((strcmp(res1, res2) == 0)) ? printf("Correct!\n") : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  printf("\nTest2:\n");
  res1 = StrSearch(str2, " with");
  res2 = strstr(str2, " with");
  ((strcmp(res1, res2) == 0)) ? printf("Correct!\n") : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  printf("\nTest3:\n");
  res1 = StrSearch(str2, "should");
  res2 = strstr(str2, "should");
  ((res1 == NULL) && (res2 == NULL)) ? printf("Correct!\n")
                                     : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  printf("\nTest4:\n");
  res1 = StrSearch(str2, "should");
  res2 = strstr(str2, "should");
  ((res1 == NULL) && (res2 == NULL)) ? printf("Correct!\n")
                                     : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  printf("\nTest5:\n");
  res1 = StrSearch(str2, str_empty);
  res2 = strstr(str2, str_empty);
  ((strcmp(res1, res2) == 0)) ? printf("Correct!\n") : printf("Wrong!\n");
  printf("Your     Answer: [%s]\n", res1);
  printf("String.h Answer: [%s]\n", res2);
  return;
}


x86 assembly (clang, -O0):
<TestStrSearch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0xe8e(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe8b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe88(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe86(%rip),%al
mov    %al,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe80(%rip),%rsi
mov    $0x40,%edx
call   1070 <memcpy@plt>
lea    -0x61(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xecf(%rip),%rsi
call   1040 <StrSearch@plt>
mov    %rax,-0x70(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xebb(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1228 <TestStrSearch+0xc8>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1236 <TestStrSearch+0xd6>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1040 <StrSearch@plt>
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ba <TestStrSearch+0x15a>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c8 <TestStrSearch+0x168>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1040 <StrSearch@plt>
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    134b <TestStrSearch+0x1eb>
cmpq   $0x0,-0x78(%rbp)
jne    134b <TestStrSearch+0x1eb>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1359 <TestStrSearch+0x1f9>
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xd76(%rip),%rsi
call   1040 <StrSearch@plt>
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xd62(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    13dc <TestStrSearch+0x27c>
cmpq   $0x0,-0x78(%rbp)
jne    13dc <TestStrSearch+0x27c>
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13ea <TestStrSearch+0x28a>
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x61(%rbp),%rsi
call   1040 <StrSearch@plt>
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x61(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1468 <TestStrSearch+0x308>
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1476 <TestStrSearch+0x316>
lea    0xc4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xc4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestStrSearch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movups 0xea4(%rip),%xmm0
movups %xmm0,0x19(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeb7(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movb   $0x0,0xf(%rsp)
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
lea    0xe96(%rip),%r14
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <StrSearch@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <strstr@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
lea    0xf14(%rip),%r15
lea    0xf06(%rip),%r14
mov    %r14,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
lea    0xe4a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe50(%rip),%r13
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xe47(%rip),%rbx
lea    0x30(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <StrSearch@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <strstr@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
mov    %r14,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
lea    0xdd7(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
lea    0xde1(%rip),%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <StrSearch@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <strstr@plt>
mov    %rax,%rbp
mov    %rbx,%rax
or     %rbp,%rax
mov    %r14,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
lea    0xd78(%rip),%rdi
mov    %rdi,%r15
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd7b(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <StrSearch@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <strstr@plt>
mov    %rax,%rbp
mov    %rbx,%rax
or     %rbp,%rax
mov    %r14,%rdi
lea    0xdd2(%rip),%rax
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd1c(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd95(%rip),%rdi
call   1030 <puts@plt>
lea    0xf(%rsp),%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <StrSearch@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <strstr@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
lea    0xd69(%rip),%rax
cmove  %rax,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcb0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.TestStrSearch.str1 = [25 x i8] c"test StrSearch StrStrStr\00"
@__const.TestStrSearch.str2 = [64 x i8] c"StrSearch with Null\00 Following character should not be searched\00"
@.str = [72 x i8] c"===========================\0ATest StrSearch\0A===========================\0A\00"
@.str.1 = [8 x i8] c"Test1:\0A\00"
@.str.2 = [4 x i8] c"Str\00"
@.str.3 = [10 x i8] c"Correct!\0A\00"
@.str.4 = [8 x i8] c"Wrong!\0A\00"
@.str.5 = [23 x i8] c"Your Answer: [%s]\0A\00"
@.str.6 = [23 x i8] c"String.h Answer: [%s]\0A\00"
@.str.7 = [9 x i8] c"\0ATest2:\0A\00"
@.str.8 = [6 x i8] c" with\00"
@.str.9 = [9 x i8] c"\0ATest3:\0A\00"
@.str.10 = [7 x i8] c"should\00"
@.str.11 = [9 x i8] c"\0ATest4:\0A\00"
@.str.12 = [9 x i8] c"\0ATest5:\0A\00"
define void @TestStrSearch() {
%1 = alloca [25 x i8]
%2 = alloca [64 x i8]
%3 = alloca [1 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast [25 x i8]* %1 to i8*
%7 = bitcast [64 x i8]* %2 to i8*
%8 = bitcast [1 x i8]* %3 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%12 = call i8* @StrSearch(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %12, i8** %4
%13 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %14, i8** %5
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %23
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = phi i32 [ %20, %19 ], [ %22, %21 ]
%25 = load i8*, i8** %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%31 = call i8* @StrSearch(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
store i8* %31, i8** %4
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%33 = call i8* @strstr(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
store i8* %33, i8** %5
%34 = load i8*, i8** %4
%35 = load i8*, i8** %5
%36 = call i64 @strcmp(i8* %34, i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %23
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %42
40: ; preds = %23
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
%43 = phi i32 [ %39, %38 ], [ %41, %40 ]
%44 = load i8*, i8** %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%50 = call i8* @StrSearch(i8* %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i8* %50, i8** %4
%51 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%52 = call i8* @strstr(i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i8* %52, i8** %5
%53 = load i8*, i8** %4
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %60
55: ; preds = %42
%56 = load i8*, i8** %5
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %62
60: ; preds = %55, %42
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %58
%63 = phi i32 [ %59, %58 ], [ %61, %60 ]
%64 = load i8*, i8** %4
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %64)
%66 = load i8*, i8** %5
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%69 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%70 = call i8* @StrSearch(i8* %69, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i8* %70, i8** %4
%71 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%72 = call i8* @strstr(i8* %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i8* %72, i8** %5
%73 = load i8*, i8** %4
%74 = icmp eq i8* %73, null
br i1 %74, label %75, label %80
75: ; preds = %62
%76 = load i8*, i8** %5
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %82
80: ; preds = %75, %62
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %80, %78
%83 = phi i32 [ %79, %78 ], [ %81, %80 ]
%84 = load i8*, i8** %4
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %84)
%86 = load i8*, i8** %5
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%89 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%90 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%91 = call i8* @StrSearch(i8* %89, i8* %90)
store i8* %91, i8** %4
%92 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%93 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%94 = call i8* @strstr(i8* %92, i8* %93)
store i8* %94, i8** %5
%95 = load i8*, i8** %4
%96 = load i8*, i8** %5
%97 = call i64 @strcmp(i8* %95, i8* %96)
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %82
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %103
101: ; preds = %82
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %103
103: ; preds = %101, %99
%104 = phi i32 [ %100, %99 ], [ %102, %101 ]
%105 = load i8*, i8** %4
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %105)
%107 = load i8*, i8** %5
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %107)
ret void
}

LLVM IR (-O2):
@__const.TestStrSearch.str1 = [25 x i8] c"test StrSearch StrStrStr\00"
@__const.TestStrSearch.str2 = [64 x i8] c"StrSearch with Null\00 Following character should not be searched\00"
@.str.2 = [4 x i8] c"Str\00"
@.str.5 = [23 x i8] c"Your Answer: [%s]\0A\00"
@.str.6 = [23 x i8] c"String.h Answer: [%s]\0A\00"
@.str.8 = [6 x i8] c" with\00"
@.str.10 = [7 x i8] c"should\00"
@str = [71 x i8] c"===========================\0ATest StrSearch\0A===========================\00"
@str.13 = [7 x i8] c"Test1:\00"
@str.15 = [8 x i8] c"\0ATest2:\00"
@str.17 = [8 x i8] c"\0ATest3:\00"
@str.19 = [8 x i8] c"\0ATest4:\00"
@str.21 = [8 x i8] c"\0ATest5:\00"
@str.22 = [7 x i8] c"Wrong!\00"
@str.27 = [9 x i8] c"Correct!\00"
define void @TestStrSearch() {
%1 = alloca [25 x i8]
%2 = alloca [64 x i8]
%3 = alloca [1 x i8]
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 0, i8* %6
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.13, i64 0, i64 0))
%9 = call i8* @StrSearch(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = call i8* @strstr(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = call i64 @strcmp(i8* %9, i8* %10)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.22, i64 0, i64 0)
%14 = call i32 @puts(i8* dereferenceable(1) %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.15, i64 0, i64 0))
%18 = call i8* @StrSearch(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%19 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%20 = call i64 @strcmp(i8* %18, i8* %19)
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.22, i64 0, i64 0)
%23 = call i32 @puts(i8* dereferenceable(1) %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %18)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %19)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.17, i64 0, i64 0))
%27 = call i8* @StrSearch(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%28 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%29 = icmp eq i8* %27, null
%30 = icmp eq i8* %28, null
%31 = select i1 %29, i1 %30, i1 false
%32 = select i1 %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.22, i64 0, i64 0)
%33 = call i32 @puts(i8* dereferenceable(1) %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %27)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %28)
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.19, i64 0, i64 0))
%37 = call i8* @StrSearch(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%38 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%39 = icmp eq i8* %37, null
%40 = icmp eq i8* %38, null
%41 = select i1 %39, i1 %40, i1 false
%42 = select i1 %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.22, i64 0, i64 0)
%43 = call i32 @puts(i8* dereferenceable(1) %42)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %38)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.21, i64 0, i64 0))
%47 = call i8* @StrSearch(i8* %5, i8* %6)
%48 = call i8* @strstr(i8* %5, i8* %6)
%49 = call i64 @strcmp(i8* %47, i8* %48)
%50 = icmp eq i64 %49, 0
%51 = select i1 %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.27, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.22, i64 0, i64 0)
%52 = call i32 @puts(i8* dereferenceable(1) %51)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %47)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %48)
ret void
}