#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
void *strstr(char *, char const *);
int main(void) {
  char chld[] = "\r\n+CHLD: (0,1,1x,2,2x,3)\r\n\r\nOK\r\n\r\n+CIEV: "
                "1,1\r\n\r\n+CIEV: 3,0\r\n";
  const char cCiev[] = "\r\n+CIEV:";
  const char cOK[] = "OK";
  char *res;
  const char *cres;
  chld[26] = 0;
  chld[27] = 0;
  res = strstr(chld, cCiev);
  fprintf(stderr, "test 1: %s\n", res == NULL ? "OK" : "KO");
  res = strstr(chld, cOK);
  fprintf(stderr, "test 2: %s\n", res == NULL ? "OK" : "KO");
  res = strstr(&chld[28], cOK);
  fprintf(stderr, "test 3: %s\n", res == &chld[28] ? "OK" : "KO");
  cres = strstr("AAAAA\0 BBBB CCCC", "A B");
  fprintf(stderr, "test 4: %s\n", cres == NULL ? "OK" : "KO");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x3d,%edx
call   1040 <memcpy@plt>
mov    0xee2(%rip),%rax
mov    %rax,-0x59(%rbp)
mov    0xee0(%rip),%al
mov    %al,-0x51(%rbp)
mov    0xed7(%rip),%ax
mov    %ax,-0x5c(%rbp)
mov    0xecf(%rip),%al
mov    %al,-0x5a(%rbp)
movb   $0x0,-0x36(%rbp)
movb   $0x0,-0x35(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x59(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x68(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%rcx
lea    0xeac(%rip),%rdx
lea    0xe96(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rdx
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x5c(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x68(%rbp)
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%rcx
lea    0xe6c(%rip),%rdx
lea    0xe56(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rdx
lea    0xe59(%rip),%rsi
call   1030 <fprintf@plt>
lea    -0x50(%rbp),%rdi
add    $0x1c,%rdi
lea    -0x5c(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x68(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%rcx
lea    -0x50(%rbp),%rsi
add    $0x1c,%rsi
lea    0xe20(%rip),%rdx
lea    0xe0a(%rip),%rax
cmp    %rsi,%rcx
cmove  %rax,%rdx
lea    0xe1a(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe2a(%rip),%rdi
lea    0xe13(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x70(%rbp)
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
mov    -0x70(%rbp),%rcx
lea    0xddb(%rip),%rdx
lea    0xdc5(%rip),%rax
cmp    $0x0,%rcx
cmove  %rax,%rdx
lea    0xde4(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps 0xede(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xeef(%rip),%xmm0
movups %xmm0,0x2d(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x1a(%rsp)
lea    0xed5(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strstr@plt>
mov    0x2e66(%rip),%r12
mov    (%r12),%edi
test   %rax,%rax
lea    0xeca(%rip),%r14
lea    0xec6(%rip),%rbx
mov    %rbx,%rdx
cmove  %r14,%rdx
lea    0xea9(%rip),%rsi
call   1030 <fprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
mov    (%r12),%edi
test   %rax,%rax
mov    %rbx,%rdx
cmove  %r14,%rdx
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
movzwl 0x1c(%rsp),%eax
cmp    $0x4b4f,%eax
mov    (%r12),%edi
cmove  %r14,%rbx
lea    0xe84(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    (%r12),%edi
lea    0xe7d(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.chld = [61 x i8] c"\0D\0A+CHLD: (0,1,1x,2,2x,3)\0D\0A\0D\0AOK\0D\0A\0D\0A+CIEV: 1,1\0D\0A\0D\0A+CIEV: 3,0\0D\0A\00"
@__const.main.cCiev = [9 x i8] c"\0D\0A+CIEV:\00"
@__const.main.cOK = [3 x i8] c"OK\00"
@stderr = global i32 0
@.str = [12 x i8] c"test 1: %s\0A\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"KO\00"
@.str.3 = [12 x i8] c"test 2: %s\0A\00"
@.str.4 = [12 x i8] c"test 3: %s\0A\00"
@.str.5 = [17 x i8] c"AAAAA\00 BBBB CCCC\00"
@.str.6 = [4 x i8] c"A B\00"
@.str.7 = [12 x i8] c"test 4: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [61 x i8]
%3 = alloca [9 x i8]
%4 = alloca [3 x i8]
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = bitcast [61 x i8]* %2 to i8*
%8 = bitcast [9 x i8]* %3 to i8*
%9 = bitcast [3 x i8]* %4 to i8*
%10 = getelementptr inbounds [61 x i8], [61 x i8]* %2, i64 0, i64 26
store i8 0, i8* %10
%11 = getelementptr inbounds [61 x i8], [61 x i8]* %2, i64 0, i64 27
store i8 0, i8* %11
%12 = getelementptr inbounds [61 x i8], [61 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%14 = call i8* @strstr(i8* %12, i8* %13)
store i8* %14, i8** %5
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %5
%17 = icmp eq i8* %16, null
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%20 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [61 x i8], [61 x i8]* %2, i64 0, i64 0
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%23 = call i8* @strstr(i8* %21, i8* %22)
store i8* %23, i8** %5
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %5
%26 = icmp eq i8* %25, null
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%29 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [61 x i8], [61 x i8]* %2, i64 0, i64 28
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%32 = call i8* @strstr(i8* %30, i8* %31)
store i8* %32, i8** %5
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %5
%35 = getelementptr inbounds [61 x i8], [61 x i8]* %2, i64 0, i64 28
%36 = icmp eq i8* %34, %35
%37 = zext i1 %36 to i64
%38 = select i1 %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%39 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = call i8* @strstr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
store i8* %40, i8** %6
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %6
%43 = icmp eq i8* %42, null
%44 = zext i1 %43 to i64
%45 = select i1 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%46 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %45)
ret i32 0
}

LLVM IR (-O2):
@__const.main.chld = [61 x i8] c"\0D\0A+CHLD: (0,1,1x,2,2x,3)\0D\0A\0D\0AOK\0D\0A\0D\0A+CIEV: 1,1\0D\0A\0D\0A+CIEV: 3,0\0D\0A\00"
@__const.main.cCiev = [9 x i8] c"\0D\0A+CIEV:\00"
@stderr = global i32 0
@.str = [12 x i8] c"test 1: %s\0A\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [3 x i8] c"KO\00"
@.str.3 = [12 x i8] c"test 2: %s\0A\00"
@.str.4 = [12 x i8] c"test 3: %s\0A\00"
@.str.7 = [12 x i8] c"test 4: %s\0A\00"
define i32 @main() {
%1 = alloca [61 x i8]
%2 = getelementptr inbounds [61 x i8], [61 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [61 x i8], [61 x i8]* %1, i64 0, i64 26
store i8 0, i8* %3
%4 = getelementptr inbounds [61 x i8], [61 x i8]* %1, i64 0, i64 27
store i8 0, i8* %4
%5 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @__const.main.cCiev, i64 0, i64 0))
%6 = load i32, i32* @stderr
%7 = icmp eq i8* %5, null
%8 = select i1 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%9 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = icmp eq i8* %10, null
%13 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [61 x i8], [61 x i8]* %1, i64 0, i64 28
%16 = bitcast i8* %15 to i16*
%17 = load i16, i16* %16
%18 = icmp eq i16 %17, 19279
%19 = load i32, i32* @stderr
%20 = select i1 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}