#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);
char *strstr(char *, char *);
int test_strstr(void) {
  char x[] = "test";
  do {
    if (!(strstr(x, "") == x)) {
      printf("expression '%s' untrue at %d\n", "strstr(x, \"\") == x", 313);
      return 0;
    }
  } while (0);
  do {
    if (!(strstr(x, "x") == NULL)) {
      printf("expression '%s' untrue at %d\n", "strstr(x, \"x\") == NULL", 314);
      return 0;
    }
  } while (0);
  do {
    if (!(strstr(x, "t") == x)) {
      printf("expression '%s' untrue at %d\n", "strstr(x, \"t\") == x", 315);
      return 0;
    }
  } while (0);
  do {
    if (!(strstr(x, "test") == x)) {
      printf("expression '%s' untrue at %d\n", "strstr(x, \"test\") == x", 316);
      return 0;
    }
  } while (0);
  do {
    if (!(strstr(x, "test1") == NULL)) {
      printf("expression '%s' untrue at %d\n", "strstr(x, \"test1\") == NULL",
             317);
      return 0;
    }
  } while (0);
  do {
    if (!(strstr(x, "st") == &x[2])) {
      printf("expression '%s' untrue at %d\n", "strstr(x, \"st\") == &x[2]",
             318);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_strstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xecd(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x9(%rbp),%rdi
lea    0xedd(%rip),%rsi
call   1040 <strstr@plt>
lea    -0x9(%rbp),%rcx
cmp    %rcx,%rax
je     117b <test_strstr+0x5b>
lea    0xea7(%rip),%rdi
lea    0xebe(%rip),%rsi
mov    $0x139,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <test_strstr+0x1dc>
jmp    1180 <test_strstr+0x60>
jmp    1185 <test_strstr+0x65>
lea    -0x9(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11c3 <test_strstr+0xa3>
lea    0xe5f(%rip),%rdi
lea    0xe89(%rip),%rsi
mov    $0x13a,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <test_strstr+0x1dc>
jmp    11c8 <test_strstr+0xa8>
jmp    11cd <test_strstr+0xad>
lea    -0x9(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1040 <strstr@plt>
lea    -0x9(%rbp),%rcx
cmp    %rcx,%rax
je     120e <test_strstr+0xee>
lea    0xe14(%rip),%rdi
lea    0xe55(%rip),%rsi
mov    $0x13b,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <test_strstr+0x1dc>
jmp    1213 <test_strstr+0xf3>
jmp    1218 <test_strstr+0xf8>
lea    -0x9(%rbp),%rdi
lea    0xddd(%rip),%rsi
call   1040 <strstr@plt>
lea    -0x9(%rbp),%rcx
cmp    %rcx,%rax
je     1259 <test_strstr+0x139>
lea    0xdc9(%rip),%rdi
lea    0xe1e(%rip),%rsi
mov    $0x13c,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <test_strstr+0x1dc>
jmp    125e <test_strstr+0x13e>
jmp    1263 <test_strstr+0x143>
lea    -0x9(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     12a1 <test_strstr+0x181>
lea    0xd81(%rip),%rdi
lea    0xdf3(%rip),%rsi
mov    $0x13d,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <test_strstr+0x1dc>
jmp    12a6 <test_strstr+0x186>
jmp    12ab <test_strstr+0x18b>
lea    -0x9(%rbp),%rdi
lea    0xd4c(%rip),%rsi
call   1040 <strstr@plt>
lea    -0x9(%rbp),%rcx
add    $0x2,%rcx
cmp    %rcx,%rax
je     12f0 <test_strstr+0x1d0>
lea    0xd32(%rip),%rdi
lea    0xdbf(%rip),%rsi
mov    $0x13e,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fc <test_strstr+0x1dc>
jmp    12f5 <test_strstr+0x1d5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strstr>:
push   %rax
movb   $0x0,0x4(%rsp)
movl   $0x74736574,(%rsp)
mov    %rsp,%rdi
mov    $0x78,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1164 <test_strstr+0x34>
lea    0xeaa(%rip),%rdi
lea    0xec1(%rip),%rsi
mov    $0x13a,%edx
jmp    11d7 <test_strstr+0xa7>
cmpl   $0x74736574,(%rsp)
je     1182 <test_strstr+0x52>
lea    0xe8c(%rip),%rdi
lea    0xebf(%rip),%rsi
mov    $0x13c,%edx
jmp    11d7 <test_strstr+0xa7>
lea    0xec8(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     11ab <test_strstr+0x7b>
lea    0xe63(%rip),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x13d,%edx
jmp    11d7 <test_strstr+0xa7>
lea    0xe85(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strstr@plt>
lea    0x2(%rsp),%rcx
cmp    %rcx,%rax
je     11e0 <test_strstr+0xb0>
lea    0xe35(%rip),%rdi
lea    0xea0(%rip),%rsi
mov    $0x13e,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.test_strstr.x = [5 x i8] c"test\00"
@.str = [1 x i8] zeroinitializer
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.2 = [19 x i8] c"strstr(x, \22\22) == x\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [23 x i8] c"strstr(x, \22x\22) == NULL\00"
@.str.5 = [2 x i8] c"t\00"
@.str.6 = [20 x i8] c"strstr(x, \22t\22) == x\00"
@.str.7 = [5 x i8] c"test\00"
@.str.8 = [23 x i8] c"strstr(x, \22test\22) == x\00"
@.str.9 = [6 x i8] c"test1\00"
@.str.10 = [27 x i8] c"strstr(x, \22test1\22) == NULL\00"
@.str.11 = [3 x i8] c"st\00"
@.str.12 = [25 x i8] c"strstr(x, \22st\22) == &x[2]\00"
define i32 @test_strstr() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = bitcast [5 x i8]* %2 to i8*
br label %4
4: ; preds = %0
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = icmp eq i8* %6, %7
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 313)
store i32 0, i32* %1
br label %56
11: ; preds = %4
br label %12
12: ; preds = %11
br label %13
13: ; preds = %12
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%15 = call i8* @strstr(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 314)
store i32 0, i32* %1
br label %56
19: ; preds = %13
br label %20
20: ; preds = %19
br label %21
21: ; preds = %20
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%23 = call i8* @strstr(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%25 = icmp eq i8* %23, %24
br i1 %25, label %28, label %26
26: ; preds = %21
%27 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 315)
store i32 0, i32* %1
br label %56
28: ; preds = %21
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%32 = call i8* @strstr(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%34 = icmp eq i8* %32, %33
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 316)
store i32 0, i32* %1
br label %56
37: ; preds = %30
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%41 = call i8* @strstr(i8* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%42 = icmp eq i8* %41, null
br i1 %42, label %45, label %43
43: ; preds = %39
%44 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 317)
store i32 0, i32* %1
br label %56
45: ; preds = %39
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46
%48 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%49 = call i8* @strstr(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%50 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
%51 = icmp eq i8* %49, %50
br i1 %51, label %54, label %52
52: ; preds = %47
%53 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 318)
store i32 0, i32* %1
br label %56
54: ; preds = %47
br label %55
55: ; preds = %54
store i32 1, i32* %1
br label %56
56: ; preds = %55, %52, %43, %35, %26, %17, %9
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.4 = [23 x i8] c"strstr(x, \22x\22) == NULL\00"
@.str.7 = [5 x i8] c"test\00"
@.str.8 = [23 x i8] c"strstr(x, \22test\22) == x\00"
@.str.9 = [6 x i8] c"test1\00"
@.str.10 = [27 x i8] c"strstr(x, \22test1\22) == NULL\00"
@.str.11 = [3 x i8] c"st\00"
@.str.12 = [25 x i8] c"strstr(x, \22st\22) == &x[2]\00"
define i32 @test_strstr() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i8* @strchr(i8* %2, i32 120)
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 314)
br label %23
7: ; preds = %0
%8 = call i32 @bcmp(i8* dereferenceable(4) %2, i8* dereferenceable(4) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64 4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 316)
br label %23
12: ; preds = %7
%13 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i32 317)
br label %23
17: ; preds = %12
%18 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
%20 = icmp eq i8* %18, %19
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i32 318)
br label %23
23: ; preds = %17, %21, %15, %10, %5
%24 = phi i32 [ 0, %21 ], [ 0, %15 ], [ 0, %10 ], [ 0, %5 ], [ 1, %17 ]
ret i32 %24
}