#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 strlen(char const *);
char *strstr(char const *, char const *);
int strbcmp(const char *haystack, const char *needle) {
  int length;
  char *sub;
  if (haystack && needle && strlen(haystack) >= (length = strlen(needle)) &&
      (sub = strstr(haystack, needle)) && strlen(sub) == length)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<strbcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a4 <strbcmp+0x84>
cmpq   $0x0,-0x18(%rbp)
je     11a4 <strbcmp+0x84>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
mov    %ecx,-0x1c(%rbp)
cmp    %ecx,%eax
jl     11a4 <strbcmp+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11a4 <strbcmp+0x84>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jne    11a4 <strbcmp+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11ab <strbcmp+0x8b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strbcmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     116e <strbcmp+0x4e>
mov    %rsi,%r14
test   %rsi,%rsi
je     116e <strbcmp+0x4e>
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jl     116e <strbcmp+0x4e>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     116e <strbcmp+0x4e>
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %r15d,%ecx
je     1173 <strbcmp+0x53>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @strbcmp(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %1)
%9 = icmp slt i32 %7, %8
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = tail call i8* @strstr(i8* %0, i8* %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @strlen(i8* %11)
%15 = icmp eq i32 %14, %8
br i1 %15, label %17, label %16
16: ; preds = %13, %10, %6, %2
br label %17
17: ; preds = %13, %16
%18 = phi i32 [ 1, %16 ], [ 0, %13 ]
ret i32 %18
}