#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__ strncasecmp(char const *, char *, int);
int smellslike_http_response(const unsigned char *data, unsigned length) {
  if (length >= 8) {
    if (strncasecmp((const char *)&data[0], "HTTP/1.0", 8) == 0)
      return 1;
    if (strncasecmp((const char *)&data[0], "HTTP/1.1", 8) == 0)
      return 1;
    if (strncasecmp((const char *)&data[0], "HTTP/0.9", 8) == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<smellslike_http_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jb     11af <smellslike_http_response+0x9f>
mov    -0x10(%rbp),%rdi
lea    0xecc(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1154 <smellslike_http_response+0x44>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <smellslike_http_response+0xa6>
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    117f <smellslike_http_response+0x6f>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <smellslike_http_response+0xa6>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11aa <smellslike_http_response+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <smellslike_http_response+0xa6>
jmp    11af <smellslike_http_response+0x9f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smellslike_http_response>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x8,%esi
jb     1168 <smellslike_http_response+0x58>
mov    %rdi,%rbx
lea    0xede(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     116a <smellslike_http_response+0x5a>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
test   %rax,%rax
je     116a <smellslike_http_response+0x5a>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncasecmp@plt>
test   %rax,%rax
je     116a <smellslike_http_response+0x5a>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"HTTP/1.0\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@.str.2 = [9 x i8] c"HTTP/0.9\00"
define i32 @smellslike_http_response(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp uge i32 %6, 8
br i1 %7, label %8, label %27
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = call i64 @strncasecmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 1, i32* %3
br label %28
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = call i64 @strncasecmp(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 1, i32* %3
br label %28
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = call i64 @strncasecmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 1, i32* %3
br label %28
26: ; preds = %20
br label %27
27: ; preds = %26, %2
store i32 0, i32* %3
br label %28
28: ; preds = %27, %25, %19, %13
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [9 x i8] c"HTTP/1.0\00"
@.str.1 = [9 x i8] c"HTTP/1.1\00"
@.str.2 = [9 x i8] c"HTTP/0.9\00"
define i32 @smellslike_http_response(i8* nocapture %0, i32 %1) {
%3 = icmp ugt i32 %1, 7
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %10, %2
br label %14
14: ; preds = %10, %7, %4, %13
%15 = phi i32 [ 0, %13 ], [ 1, %4 ], [ 1, %7 ], [ 1, %10 ]
ret i32 %15
}