#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 */
char const *__rksearch(char const *, char const *, int, int);
scalar_t__ strlen(char const *);
const char *strsearch_rk(const char *pattern, const char *str) {
  if (pattern == NULL || str == NULL)
    return NULL;
  if (strlen(pattern) > strlen(str))
    return NULL;
  return __rksearch(pattern, str, 2, 524287);
}


x86 assembly (clang, -O0):
<strsearch_rk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <strsearch_rk+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1153 <strsearch_rk+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <strsearch_rk+0x81>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jle    1186 <strsearch_rk+0x66>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <strsearch_rk+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x2,%edx
mov    $0x7ffff,%ecx
call   1040 <__rksearch@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strsearch_rk>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     114a <strsearch_rk+0x2a>
mov    %rsi,%r14
test   %rsi,%rsi
je     114a <strsearch_rk+0x2a>
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r15
jle    1152 <strsearch_rk+0x32>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
mov    $0x7ffff,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <__rksearch@plt>

LLVM IR (-O0):
define i8* @strsearch_rk(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store i8* null, i8** %3
br label %23
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = call i64 @strlen(i8* %13)
%15 = load i8*, i8** %5
%16 = call i64 @strlen(i8* %15)
%17 = icmp sgt i64 %14, %16
br i1 %17, label %18, label %19
18: ; preds = %12
store i8* null, i8** %3
br label %23
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = call i8* @__rksearch(i8* %20, i8* %21, i32 2, i32 524287)
store i8* %22, i8** %3
br label %23
23: ; preds = %19, %18, %11
%24 = load i8*, i8** %3
ret i8* %24
}

LLVM IR (-O2):
define i8* @strsearch_rk(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%9 = icmp sgt i64 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i8* @__rksearch(i8* %0, i8* %1, i32 2, i32 524287)
br label %12
12: ; preds = %6, %2, %10
%13 = phi i8* [ %11, %10 ], [ null, %2 ], [ null, %6 ]
ret i8* %13
}