#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 */
struct sabir {
  int dummy;
};

/* Variables and functions */
scalar_t__ SIZE_MAX;
char const *sb_finish(struct sabir *);
int /*<<< orphan*/ sb_init(struct sabir *);
int /*<<< orphan*/ sb_process(struct sabir *, void const *, size_t);
const char *sb_detect(struct sabir *sb, const void *text, size_t len) {
  sb_init(sb);
  sb_process(sb, text,
             len < ((size_t)SIZE_MAX / 2) ? len : ((size_t)SIZE_MAX / 2));
  return sb_finish(sb);
}


x86 assembly (clang, -O0):
<sb_detect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <sb_init@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2e70(%rip),%rcx
mov    (%rcx),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    1185 <sb_detect+0x55>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1197 <sb_detect+0x67>
mov    0x2e4c(%rip),%rax
mov    (%rax),%rax
shr    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
call   1030 <sb_process@plt>
mov    -0x8(%rbp),%rdi
call   1040 <sb_finish@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sb_detect>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <sb_init@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%rdx
shr    %rdx
cmp    %r15,%rdx
cmova  %r15,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <sb_process@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <sb_finish@plt>

LLVM IR (-O0):
%struct.sabir = type { i32 }
@SIZE_MAX = global i64 0
define i8* @sb_detect(%struct.sabir* %0, i8* %1, i64 %2) {
%4 = alloca %struct.sabir*
%5 = alloca i8*
%6 = alloca i64
store %struct.sabir* %0, %struct.sabir** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load %struct.sabir*, %struct.sabir** %4
%8 = call i32 @sb_init(%struct.sabir* %7)
%9 = load %struct.sabir*, %struct.sabir** %4
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = load i64, i64* @SIZE_MAX
%13 = udiv i64 %12, 2
%14 = icmp ult i64 %11, %13
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i64, i64* %6
br label %20
17: ; preds = %3
%18 = load i64, i64* @SIZE_MAX
%19 = udiv i64 %18, 2
br label %20
20: ; preds = %17, %15
%21 = phi i64 [ %16, %15 ], [ %19, %17 ]
%22 = call i32 @sb_process(%struct.sabir* %9, i8* %10, i64 %21)
%23 = load %struct.sabir*, %struct.sabir** %4
%24 = call i8* @sb_finish(%struct.sabir* %23)
ret i8* %24
}

LLVM IR (-O2):
%struct.sabir = type { i32 }
@SIZE_MAX = global i64 0
define i8* @sb_detect(%struct.sabir* %0, i8* %1, i64 %2) {
%4 = tail call i32 @sb_init(%struct.sabir* %0)
%5 = load i64, i64* @SIZE_MAX
%6 = lshr i64 %5, 1
%7 = icmp ugt i64 %6, %2
%8 = select i1 %7, i64 %2, i64 %6
%9 = tail call i32 @sb_process(%struct.sabir* %0, i8* %1, i64 %8)
%10 = tail call i8* @sb_finish(%struct.sabir* %0)
ret i8* %10
}