#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 *strchrnul(char *, char);
int test_strchrnul(void) {
  char data[] = "xyz";
  do {
    if (!(&data[2] == strchrnul(data, 'z'))) {
      printf("expression '%s' untrue at %d\n",
             "&data[2] == strchrnul(data, 'z')", 246);
      return 0;
    }
  } while (0);
  do {
    if (!(&data[3] == strchrnul(data, '\0'))) {
      printf("expression '%s' untrue at %d\n",
             "&data[3] == strchrnul(data, '\\0')", 247);
      return 0;
    }
  } while (0);
  do {
    if (!(&data[3] == strchrnul(data, 'd'))) {
      printf("expression '%s' untrue at %d\n",
             "&data[3] == strchrnul(data, 'd')", 248);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_strchrnul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
lea    -0x8(%rbp),%rdi
mov    $0x7a,%esi
call   1030 <strchrnul@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
cmp    %rcx,%rax
je     117f <test_strchrnul+0x5f>
lea    0xea2(%rip),%rdi
lea    0xeb9(%rip),%rsi
mov    $0xf6,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1238 <test_strchrnul+0x118>
jmp    1184 <test_strchrnul+0x64>
jmp    1189 <test_strchrnul+0x69>
lea    -0x8(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchrnul@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
je     11d4 <test_strchrnul+0xb4>
lea    0xe4d(%rip),%rdi
lea    0xe85(%rip),%rsi
mov    $0xf7,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1238 <test_strchrnul+0x118>
jmp    11d9 <test_strchrnul+0xb9>
jmp    11de <test_strchrnul+0xbe>
lea    -0x8(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x20(%rbp)
lea    -0x8(%rbp),%rdi
mov    $0x64,%esi
call   1030 <strchrnul@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     122c <test_strchrnul+0x10c>
lea    0xdf5(%rip),%rdi
lea    0xe4f(%rip),%rsi
mov    $0xf8,%edx
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1238 <test_strchrnul+0x118>
jmp    1231 <test_strchrnul+0x111>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strchrnul>:
push   %r14
push   %rbx
push   %rax
movl   $0x7a7978,0x4(%rsp)
lea    0x6(%rsp),%rbx
lea    0x4(%rsp),%rdi
mov    $0x7a,%esi
call   1030 <strchrnul@plt>
cmp    %rax,%rbx
je     1161 <test_strchrnul+0x41>
lea    0xeb4(%rip),%rdi
lea    0xecb(%rip),%rsi
mov    $0xf6,%edx
call   1040 <printf@plt>
xor    %ebx,%ebx
jmp    11ba <test_strchrnul+0x9a>
lea    0x7(%rsp),%r14
lea    0x4(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <strchrnul@plt>
cmp    %rax,%r14
je     118e <test_strchrnul+0x6e>
lea    0xe80(%rip),%rdi
lea    0xeb8(%rip),%rsi
mov    $0xf7,%edx
jmp    11b5 <test_strchrnul+0x95>
lea    0x4(%rsp),%rdi
mov    $0x64,%esi
call   1030 <strchrnul@plt>
cmp    %rax,%r14
je     11c4 <test_strchrnul+0xa4>
lea    0xe57(%rip),%rdi
lea    0xeb1(%rip),%rsi
mov    $0xf8,%edx
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%ebx
jmp    11ba <test_strchrnul+0x9a>

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

LLVM IR (-O2):
@.str = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.1 = [33 x i8] c"&data[2] == strchrnul(data, 'z')\00"
@.str.2 = [34 x i8] c"&data[3] == strchrnul(data, '\\0')\00"
@.str.3 = [33 x i8] c"&data[3] == strchrnul(data, 'd')\00"
define i32 @test_strchrnul() {
%1 = alloca i32
%2 = bitcast i32* %1 to [4 x i8]*
%3 = bitcast i32* %1 to i8*
store i32 8026488, i32* %1
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%5 = call i8* @strchrnul(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 ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 246)
br label %20
9: ; preds = %0
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%11 = call i8* @strchrnul(i8* %3, i8 signext 0)
%12 = icmp eq i8* %10, %11
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 247)
br label %20
15: ; preds = %9
%16 = call i8* @strchrnul(i8* %3, i8 signext 100)
%17 = icmp eq i8* %10, %16
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 248)
br label %20
20: ; preds = %15, %18, %13, %7
%21 = phi i32 [ 0, %18 ], [ 0, %13 ], [ 0, %7 ], [ 1, %15 ]
ret i32 %21
}