#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', 2) == NULL);
  assert(memchr(test, 'u', 7) == test + 2);
  assert(memchr(test, 'b', 7) == test);
  assert(memchr(test + 6, 'r', 1) == test + 6);
  assert(memchr(test + 7, 0, 100) == test + 7);
  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    $0x2,%edx
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>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1030 <memchr@plt>
mov    -0x10(%rbp),%rcx
add    $0x7,%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    $0x2,%edx
call   1030 <memchr@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x75,%esi
mov    $0x7,%edx
call   1030 <memchr@plt>
lea    0xe61(%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    0xe30(%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>
lea    0xe0a(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x64,%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 2)
%13 = icmp eq i8* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %2
%17 = call i8* @memchr(i8* %16, i8 signext 117, i32 7)
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = icmp eq i8* %17, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i8*, i8** %2
%24 = call i8* @memchr(i8* %23, i8 signext 98, i32 7)
%25 = load i8*, i8** %2
%26 = icmp eq i8* %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 6
%31 = call i8* @memchr(i8* %30, i8 signext 114, i32 1)
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 6
%34 = icmp eq i8* %31, %33
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i64 7
%39 = call i8* @memchr(i8* %38, i8 signext 0, i32 100)
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 7
%42 = icmp eq i8* %39, %41
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
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 2)
%10 = icmp eq i8* %9, null
%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 117, i32 7)
%14 = icmp eq i8* %13, getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 2)
%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 0), i8 signext 98, i32 7)
%18 = icmp eq i8* %17, getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0)
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i8* @memchr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 6), i8 signext 114, i32 1)
%22 = icmp eq i8* %21, getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 6)
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i8* @memchr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 7), i8 signext 0, i32 100)
%26 = icmp eq i8* %25, getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 7)
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
ret i32 0
}