#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 __get_array_size(void const *);
int __infer_nondet_int();
void *memchr(const void *s, int c, size_t n) {
  int size;
  int nondet;
  int offset;
  nondet = __infer_nondet_int();
  offset = __infer_nondet_int();
  size = __get_array_size(s);
  if (n > size)
    while (1)
      ;
  if (nondet)
    return 0;
  if (offset < 0 || offset >= n)
    while (1)
      ;
  return (void *)s + offset;
}


x86 assembly (clang, -O0):
<memchr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   1030 <__infer_nondet_int@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <__infer_nondet_int@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <__get_array_size@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmp    %rcx,%rax
jbe    116e <memchr+0x4e>
jmp    1169 <memchr+0x49>
jmp    1169 <memchr+0x49>
cmpl   $0x0,-0x28(%rbp)
je     1185 <memchr+0x65>
movq   $0x0,-0x8(%rbp)
jmp    11b6 <memchr+0x96>
cmpl   $0x0,-0x2c(%rbp)
jl     119d <memchr+0x7d>
movslq -0x2c(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     11a7 <memchr+0x87>
jmp    11a2 <memchr+0x82>
jmp    11a2 <memchr+0x82>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memchr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <__infer_nondet_int@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <__infer_nondet_int@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <__get_array_size@plt>
cltq
cmp    %r14,%rax
jae    1152 <memchr+0x32>
nop
jmp    1150 <memchr+0x30>
test   %ebp,%ebp
je     1166 <memchr+0x46>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15d,%r15d
js     1180 <memchr+0x60>
mov    %r15d,%eax
cmp    %r14,%rax
jae    1180 <memchr+0x60>
add    %rax,%rbx
jmp    1158 <memchr+0x38>
nopl   0x0(%rax,%rax,1)
jmp    1180 <memchr+0x60>

LLVM IR (-O0):
define i8* @memchr(i8* %0, i32 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i64 %2, i64* %7
%11 = call i32 (...) @__infer_nondet_int()
store i32 %11, i32* %9
%12 = call i32 (...) @__infer_nondet_int()
store i32 %12, i32* %10
%13 = load i8*, i8** %5
%14 = call i32 @__get_array_size(i8* %13)
store i32 %14, i32* %8
%15 = load i64, i64* %7
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = icmp ugt i64 %15, %17
br i1 %18, label %19, label %21
19: ; preds = %3
br label %20
20: ; preds = %19, %20
br label %20
21: ; preds = %3
%22 = load i32, i32* %9
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i8* null, i8** %4
br label %40
25: ; preds = %21
%26 = load i32, i32* %10
%27 = icmp slt i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %25
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = load i64, i64* %7
%32 = icmp uge i64 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %28, %25
br label %34
34: ; preds = %33, %34
br label %34
35: ; preds = %28
%36 = load i8*, i8** %5
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr i8, i8* %36, i64 %38
store i8* %39, i8** %4
br label %40
40: ; preds = %35, %24
%41 = load i8*, i8** %4
ret i8* %41
}

LLVM IR (-O2):
define i8* @memchr(i8* %0, i32 %1, i64 %2) {
%4 = tail call i32 (...) @__infer_nondet_int()
%5 = tail call i32 (...) @__infer_nondet_int()
%6 = tail call i32 @__get_array_size(i8* %0)
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, %2
br i1 %8, label %9, label %10
9: ; preds = %3, %9
br label %9
10: ; preds = %3
%11 = icmp eq i32 %4, 0
br i1 %11, label %12, label %21
12: ; preds = %10
%13 = icmp slt i32 %5, 0
br i1 %13, label %17, label %14
14: ; preds = %12
%15 = zext i32 %5 to i64
%16 = icmp ult i64 %15, %2
br i1 %16, label %19, label %17
17: ; preds = %14, %12
br label %18
18: ; preds = %17, %18
br label %18
19: ; preds = %14
%20 = getelementptr i8, i8* %0, i64 %15
br label %21
21: ; preds = %10, %19
%22 = phi i8* [ %20, %19 ], [ null, %10 ]
ret i8* %22
}