#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 */
scalar_t__ char_array_ident(char *, char *, int);
int char_array_find(char *b, int nb, char *a, int na) {
  if (nb <= na) {
    int i;
    for (i = 0; i <= na - nb; i++) {
      if (char_array_ident(a + i, b, nb))
        return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<char_array_find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     118e <char_array_find+0x7e>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jg     1189 <char_array_find+0x79>
mov    -0x20(%rbp),%rdi
movslq -0x28(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <char_array_ident@plt>
cmp    $0x0,%rax
je     1176 <char_array_find+0x66>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1195 <char_array_find+0x85>
jmp    117b <char_array_find+0x6b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1139 <char_array_find+0x29>
jmp    118e <char_array_find+0x7e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_array_find>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    $0xffffffff,%r14d
sub    %esi,%ebx
jl     1162 <char_array_find+0x52>
mov    %rdx,%r15
mov    %esi,%r13d
mov    %rdi,%r12
add    $0x1,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r15,%rbp,1),%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1030 <char_array_ident@plt>
test   %rax,%rax
jne    115f <char_array_find+0x4f>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1140 <char_array_find+0x30>
jmp    1162 <char_array_find+0x52>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @char_array_find(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = icmp slt i32 %3, %1
br i1 %5, label %20, label %6
6: ; preds = %4
%7 = add i32 %3, 1
%8 = sub i32 %7, %1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %6, %15
%11 = phi i64 [ 0, %6 ], [ %16, %15 ]
%12 = getelementptr inbounds i8, i8* %2, i64 %11
%13 = tail call i64 @char_array_ident(i8* %12, i8* %0, i32 %1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %20, label %10
18: ; preds = %10
%19 = trunc i64 %11 to i32
br label %20
20: ; preds = %15, %18, %4
%21 = phi i32 [ -1, %4 ], [ %19, %18 ], [ -1, %15 ]
ret i32 %21
}