#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__ hskip_lws(char const *);
scalar_t__ strncasecmp(char const *, char *, int const);
scalar_t__ strstr(char const *, char *);
int hgetaccept_ranges(const char *hdr) {
  const int l = 14;
  if (strncasecmp(hdr, "accept-ranges:", l))
    return -1;
  hdr += (l + hskip_lws(hdr + l));
  if (strstr(hdr, "none"))
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<hgetaccept_ranges>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0xe,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0xe,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
je     116e <hgetaccept_ranges+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <hgetaccept_ranges+0x84>
mov    -0x10(%rbp),%rdi
add    $0xe,%rdi
call   1030 <hskip_lws@plt>
add    $0xe,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     11ad <hgetaccept_ranges+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <hgetaccept_ranges+0x84>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hgetaccept_ranges>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
mov    $0xe,%edx
call   1040 <strncasecmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     1154 <hgetaccept_ranges+0x24>
pop    %rbx
ret
lea    0xe(%rbx),%rdi
call   1030 <hskip_lws@plt>
lea    (%rax,%rbx,1),%rdi
add    $0xe,%rdi
lea    0xea3(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"accept-ranges:\00"
@.str.1 = [5 x i8] c"none\00"
define i32 @hgetaccept_ranges(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 14, i32* %4
%5 = load i8*, i8** %3
%6 = call i64 @strncasecmp(i8* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %21
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 14
%12 = call i64 @hskip_lws(i8* %11)
%13 = add nsw i64 14, %12
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 %13
store i8* %15, i8** %3
%16 = load i8*, i8** %3
%17 = call i64 @strstr(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %9
store i32 0, i32* %2
br label %21
20: ; preds = %9
store i32 1, i32* %2
br label %21
21: ; preds = %20, %19, %8
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [15 x i8] c"accept-ranges:\00"
@.str.1 = [5 x i8] c"none\00"
define i32 @hgetaccept_ranges(i8* %0) {
%2 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 14
%6 = tail call i64 @hskip_lws(i8* %5)
%7 = add nsw i64 %6, 14
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = tail call i64 @strstr(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %4, %1
%13 = phi i32 [ -1, %1 ], [ %11, %4 ]
ret i32 %13
}