#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 */
typedef int /*<<< orphan*/ check;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strlcpy(char *, char *, int);
char *strrstr(char *, char *);
char *strstr(char *, char *);
void strstr_test1() {
  char *buf =
      "SXX MSG ::                   {                      SXX/2.0 254 SESSION "
      "                     Require: COMPLETED 90000rel                      "
      "...                      COMPLETED                   }";
  char *ret;
  char check[256] = {
      0,
  };
  strlcpy(check, buf, sizeof(check));
  ret = strstr(check, "COMPLETED");
  printf("[1]%s\n", ret);
  ret = strrstr(check, "COMPLETED");
  printf("[2]%s\n", ret);
  return;
}


x86 assembly (clang, -O0):
<strstr_test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    0xe9e(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x100,%edx
call   1060 <strlcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xf29(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xf1f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
lea    0xf02(%rip),%rsi
call   1030 <strrstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeff(%rip),%rdi
call   1040 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strstr_test1>:
push   %r14
push   %rbx
sub    $0x108,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe45(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%edx
call   1050 <strlcpy@plt>
lea    0xef3(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strstr@plt>
lea    0xeeb(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strrstr@plt>
lea    0xed8(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [197 x i8] c"SXX MSG :: { SXX/2.0 254 SESSION Require: COMPLETED 90000rel ... COMPLETED }\00"
@.str.1 = [10 x i8] c"COMPLETED\00"
@.str.2 = [7 x i8] c"[1]%s\0A\00"
@.str.3 = [7 x i8] c"[2]%s\0A\00"
define void @strstr_test1() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca [256 x i8]
store i8* getelementptr inbounds ([197 x i8], [197 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = bitcast [256 x i8]* %3 to i8*
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = load i8*, i8** %1
%7 = call i32 @strlcpy(i8* %5, i8* %6, i32 256)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = call i8* @strstr(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %9, i8** %2
%10 = load i8*, i8** %2
%11 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = call i8* @strrstr(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %2
%14 = load i8*, i8** %2
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret void
}

LLVM IR (-O2):
@.str = [197 x i8] c"SXX MSG :: { SXX/2.0 254 SESSION Require: COMPLETED 90000rel ... COMPLETED }\00"
@.str.1 = [10 x i8] c"COMPLETED\00"
@.str.2 = [7 x i8] c"[1]%s\0A\00"
@.str.3 = [7 x i8] c"[2]%s\0A\00"
define void @strstr_test1() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlcpy(i8* %2, i8* getelementptr inbounds ([197 x i8], [197 x i8]* @.str, i64 0, i64 0), i32 256)
%4 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%6 = call i8* @strrstr(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %6)
ret void
}