#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_length(char const *);
int __infer_nondet_int();
int /*<<< orphan*/ __require_allocated_array(char const *);
char *strchr(const char *s, int c) {
  int size;
  int nondet;
  int offset;
  nondet = __infer_nondet_int();
  offset = __infer_nondet_int();
  __require_allocated_array(s);
  size = __get_array_length(s);
  if (nondet)
    return 0;
  if (offset < 0 || offset >= size)
    while (1)
      ;
  return (char *)s + offset;
}


x86 assembly (clang, -O0):
<strchr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    $0x0,%al
call   1030 <__infer_nondet_int@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <__infer_nondet_int@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <__require_allocated_array@plt>
mov    -0x10(%rbp),%rdi
call   1050 <__get_array_length@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117f <strchr+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    11ae <strchr+0x7e>
cmpl   $0x0,-0x20(%rbp)
jl     1195 <strchr+0x65>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     119f <strchr+0x6f>
jmp    119a <strchr+0x6a>
jmp    119a <strchr+0x6a>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strchr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %r14d,%r14d
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 <__require_allocated_array@plt>
mov    %rbx,%rdi
call   1050 <__get_array_length@plt>
test   %ebp,%ebp
jne    1177 <strchr+0x47>
test   %r15d,%r15d
js     1190 <strchr+0x60>
cmp    %eax,%r15d
jge    1190 <strchr+0x60>
mov    %r15d,%eax
add    %rax,%rbx
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
cs nopw 0x0(%rax,%rax,1)
nop
jmp    1190 <strchr+0x60>

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

LLVM IR (-O2):
define i8* @strchr(i8* %0, i32 %1) {
%3 = tail call i32 (...) @__infer_nondet_int()
%4 = tail call i32 (...) @__infer_nondet_int()
%5 = tail call i32 @__require_allocated_array(i8* %0)
%6 = tail call i32 @__get_array_length(i8* %0)
%7 = icmp eq i32 %3, 0
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = icmp sgt i32 %4, -1
%10 = icmp slt i32 %4, %6
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %13, label %12
12: ; preds = %8, %12
br label %12
13: ; preds = %8
%14 = zext i32 %4 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
br label %16
16: ; preds = %2, %13
%17 = phi i8* [ %15, %13 ], [ null, %2 ]
ret i8* %17
}