#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 *strchr(char *, char);
int test_strchr(void) {
  char data[] = "xyz\0abc";
  do {
    if (!(&data[2] == strchr(data, 'z'))) {
      printf("expression '%s' untrue at %d\n", "&data[2] == strchr(data, 'z')",
             235);
      return 0;
    }
  } while (0);
  do {
    if (!(&data[3] == strchr(data, '\0'))) {
      printf("expression '%s' untrue at %d\n",
             "&data[3] == strchr(data, '\\0')", 236);
      return 0;
    }
  } while (0);
  do {
    if (!(NULL == strchr(data, 'd'))) {
      printf("expression '%s' untrue at %d\n", "NULL == strchr(data, 'd')",
             237);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_strchr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xc(%rbp)
lea    -0xc(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x7a,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
je     1181 <test_strchr+0x61>
lea    0xea4(%rip),%rdi
lea    0xebb(%rip),%rsi
mov    $0xeb,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122c <test_strchr+0x10c>
jmp    1186 <test_strchr+0x66>
jmp    118b <test_strchr+0x6b>
lea    -0xc(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x20(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11d6 <test_strchr+0xb6>
lea    0xe4f(%rip),%rdi
lea    0xe84(%rip),%rsi
mov    $0xec,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122c <test_strchr+0x10c>
jmp    11db <test_strchr+0xbb>
jmp    11e0 <test_strchr+0xc0>
lea    -0xc(%rbp),%rdi
mov    $0x64,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1220 <test_strchr+0x100>
lea    0xe05(%rip),%rdi
lea    0xe59(%rip),%rsi
mov    $0xed,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122c <test_strchr+0x10c>
jmp    1225 <test_strchr+0x105>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strchr>:
push   %rbx
sub    $0x10,%rsp
movabs $0x636261007a7978,%rax
mov    %rax,0x8(%rsp)
lea    0xa(%rsp),%rbx
lea    0x8(%rsp),%rdi
mov    $0x7a,%esi
call   1040 <strchr@plt>
cmp    %rax,%rbx
je     1172 <test_strchr+0x42>
lea    0xe9c(%rip),%rdi
lea    0xeb3(%rip),%rsi
mov    $0xeb,%edx
jmp    11be <test_strchr+0x8e>
lea    0x8(%rsp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%rax
je     1197 <test_strchr+0x67>
lea    0xe77(%rip),%rdi
lea    0xeac(%rip),%rsi
mov    $0xec,%edx
jmp    11be <test_strchr+0x8e>
lea    0x8(%rsp),%rdi
mov    $0x64,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11cb <test_strchr+0x9b>
lea    0xe4e(%rip),%rdi
lea    0xea2(%rip),%rsi
mov    $0xed,%edx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    $0x1,%eax
jmp    11c5 <test_strchr+0x95>

LLVM IR (-O0):
@__const.test_strchr.data = [8 x i8] c"xyz\00abc\00"
@.str = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.1 = [30 x i8] c"&data[2] == strchr(data, 'z')\00"
@.str.2 = [31 x i8] c"&data[3] == strchr(data, '\\0')\00"
@.str.3 = [26 x i8] c"NULL == strchr(data, 'd')\00"
define i32 @test_strchr() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = bitcast [8 x i8]* %2 to i8*
br label %4
4: ; preds = %0
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%7 = call i8* @strchr(i8* %6, i8 signext 122)
%8 = icmp eq i8* %5, %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, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 235)
store i32 0, i32* %1
br label %30
11: ; preds = %4
br label %12
12: ; preds = %11
br label %13
13: ; preds = %12
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%16 = call i8* @strchr(i8* %15, i8 signext 0)
%17 = icmp eq i8* %14, %16
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 236)
store i32 0, i32* %1
br label %30
20: ; preds = %13
br label %21
21: ; preds = %20
br label %22
22: ; preds = %21
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%24 = call i8* @strchr(i8* %23, i8 signext 100)
%25 = icmp eq i8* null, %24
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 237)
store i32 0, i32* %1
br label %30
28: ; preds = %22
br label %29
29: ; preds = %28
store i32 1, i32* %1
br label %30
30: ; preds = %29, %26, %18, %9
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.1 = [30 x i8] c"&data[2] == strchr(data, 'z')\00"
@.str.2 = [31 x i8] c"&data[3] == strchr(data, '\\0')\00"
@.str.3 = [26 x i8] c"NULL == strchr(data, 'd')\00"
define i32 @test_strchr() {
%1 = alloca i64
%2 = bitcast i64* %1 to [8 x i8]*
%3 = bitcast i64* %1 to i8*
store i64 27974191453731192, i64* %1
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
%5 = call i8* @strchr(i8* %3, i8 signext 122)
%6 = icmp eq i8* %4, %5
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 235)
br label %21
9: ; preds = %0
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
%11 = call i64 @strlen(i8* %3)
%12 = getelementptr i8, i8* %3, i64 %11
%13 = icmp eq i8* %10, %12
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 236)
br label %21
16: ; preds = %9
%17 = call i8* @strchr(i8* %3, i8 signext 100)
%18 = icmp eq i8* %17, null
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 237)
br label %21
21: ; preds = %16, %19, %14, %7
%22 = phi i32 [ 0, %19 ], [ 0, %14 ], [ 0, %7 ], [ 1, %16 ]
ret i32 %22
}