#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*/ assert(int);
char const *memchr(char const *, char, int);
int main() {
  const char *test = "blubber";
  assert(memchr("aaaa", 'x', 4) == 0);
  assert(memchr(0, 'x', 0) == 0);
  assert(memchr(test, 'u', 7) == test + 2);
  assert(memchr(test, 'b', 7) == test);
  assert(memchr(test + 6, 'r', 1) == test + 6);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x78,%esi
mov    $0x4,%edx
call   1030 <memchr@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %edx,%edx
mov    %edx,%edi
mov    $0x78,%esi
call   1030 <memchr@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x75,%esi
mov    $0x7,%edx
call   1030 <memchr@plt>
mov    -0x10(%rbp),%rcx
add    $0x2,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x62,%esi
mov    $0x7,%edx
call   1030 <memchr@plt>
cmp    -0x10(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
add    $0x6,%rdi
mov    $0x72,%esi
mov    $0x1,%edx
call   1030 <memchr@plt>
mov    -0x10(%rbp),%rcx
add    $0x6,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee0(%rip),%rdi
mov    $0x78,%esi
mov    $0x4,%edx
call   1030 <memchr@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
mov    $0x78,%esi
xor    %edx,%edx
call   1030 <memchr@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe98(%rip),%rbx
mov    %rbx,%rdi
mov    $0x75,%esi
mov    $0x7,%edx
call   1030 <memchr@plt>
lea    0xe81(%rip),%rcx
xor    %edi,%edi
cmp    %rcx,%rax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x62,%esi
mov    $0x7,%edx
call   1030 <memchr@plt>
xor    %edi,%edi
cmp    %rbx,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe50(%rip),%rbx
mov    %rbx,%rdi
mov    $0x72,%esi
mov    $0x1,%edx
call   1030 <memchr@plt>
xor    %edi,%edi
cmp    %rbx,%rax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"blubber\00"
@.str.1 = [5 x i8] c"aaaa\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = call i8* @memchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 signext 120, i32 4)
%4 = icmp eq i8* %3, null
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = call i8* @memchr(i8* null, i8 signext 120, i32 0)
%8 = icmp eq i8* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %2
%12 = call i8* @memchr(i8* %11, i8 signext 117, i32 7)
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 2
%15 = icmp eq i8* %12, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %2
%19 = call i8* @memchr(i8* %18, i8 signext 98, i32 7)
%20 = load i8*, i8** %2
%21 = icmp eq i8* %19, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 6
%26 = call i8* @memchr(i8* %25, i8 signext 114, i32 1)
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 6
%29 = icmp eq i8* %26, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"blubber\00"
@.str.1 = [5 x i8] c"aaaa\00"
define i32 @main() {
%1 = tail call i8* @memchr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 signext 120, i32 4)
%2 = icmp eq i8* %1, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i8* @memchr(i8* null, i8 signext 120, i32 0)
%6 = icmp eq i8* %5, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i8* @memchr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext 117, i32 7)
%10 = icmp eq i8* %9, getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 2)
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i8* @memchr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext 98, i32 7)
%14 = icmp eq i8* %13, getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0)
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i8* @memchr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 6), i8 signext 114, i32 1)
%18 = icmp eq i8* %17, getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 6)
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
ret i32 0
}