#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 atoi(char *);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strn_casecmp(char *, char *, int);
int has_content_length(char *inp, int *len) {
  int l;
  char *p;
  l = strlen(inp);
  if (l < 16)
    return 0;
  if (strn_casecmp(inp, "content-length", 14) != 0)
    return 0;
  p = strchr(inp, ':');
  p++;
  while (*p && (*p == ' '))
    p++;
  if (p) {
    *len = atoi(p);
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<has_content_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    1172 <has_content_length+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1230 <has_content_length+0xf0>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0xe,%edx
call   1030 <strn_casecmp@plt>
cmp    $0x0,%rax
je     119d <has_content_length+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    1230 <has_content_length+0xf0>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11e0 <has_content_length+0xa0>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11f0 <has_content_length+0xb0>
jmp    1201 <has_content_length+0xc1>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11bb <has_content_length+0x7b>
cmpq   $0x0,-0x28(%rbp)
je     1229 <has_content_length+0xe9>
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1230 <has_content_length+0xf0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_content_length>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x10,%eax
jl     119a <has_content_length+0x5a>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
mov    $0xe,%edx
call   1030 <strn_casecmp@plt>
test   %rax,%rax
jne    119a <has_content_length+0x5a>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
nopl   0x0(%rax)
cmpb   $0x20,0x1(%rax)
lea    0x1(%rax),%rax
je     1180 <has_content_length+0x40>
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"content-length\00"
define i32 @has_content_length(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 16
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %46
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @strn_casecmp(i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %3
br label %46
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = call i8* @strchr(i8* %19, i8 signext 58)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %7
br label %23
23: ; preds = %35, %18
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i8*, i8** %7
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br label %33
33: ; preds = %28, %23
%34 = phi i1 [ false, %23 ], [ %32, %28 ]
br i1 %34, label %35, label %38
35: ; preds = %33
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %7
br label %23
38: ; preds = %33
%39 = load i8*, i8** %7
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i8*, i8** %7
%43 = call i32 @atoi(i8* %42)
%44 = load i32*, i32** %5
store i32 %43, i32* %44
store i32 1, i32* %3
br label %46
45: ; preds = %38
store i32 0, i32* %3
br label %46
46: ; preds = %45, %41, %17, %12
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [15 x i8] c"content-length\00"
define i32 @has_content_length(i8* %0, i32* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp slt i32 %3, 16
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = tail call i64 @strn_casecmp(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
br label %10
10: ; preds = %10, %8
%11 = phi i8* [ %9, %8 ], [ %12, %10 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
br i1 %14, label %10, label %15
15: ; preds = %10
%16 = tail call i32 @atoi(i8* %12)
store i32 %16, i32* %1
br label %17
17: ; preds = %5, %2, %15
%18 = phi i32 [ 1, %15 ], [ 0, %2 ], [ 0, %5 ]
ret i32 %18
}