#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 *);
int /*<<< orphan*/ strncat(char *, char *, int);
char *strstr(char *, char *);
int /*<<< orphan*/ xfree(char *);
scalar_t__ zalloc(int);
int extract_content_length(char *buffer, int size) {
  char *clen = strstr(buffer, "Content-Length:");
  char *content_buffer = NULL;
  char *buf_len;
  int inc = 0;
  int i;
  buf_len = (char *)(zalloc(40));
  if (!clen)
    return 0;
  while (*(clen++) != ':')
    ;
  content_buffer = clen;
  while (*(clen++) != '\r' && *clen != '\n')
    inc++;
  for (i = 0; i < inc; i++)
    strncat(buf_len, content_buffer + i, 1);
  i = atoi(buf_len);
  (xfree(buf_len));
  return i;
}


x86 assembly (clang, -O0):
<extract_content_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x28,%edi
call   1060 <zalloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a7 <extract_content_length+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1277 <extract_content_length+0x127>
jmp    11ac <extract_content_length+0x5c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     11cc <extract_content_length+0x7c>
jmp    11ac <extract_content_length+0x5c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xd,%ecx
mov    %al,-0x39(%rbp)
je     1204 <extract_content_length+0xb4>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1214 <extract_content_length+0xc4>
jmp    1222 <extract_content_length+0xd2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d4 <extract_content_length+0x84>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    125c <extract_content_length+0x10c>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x38(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1229 <extract_content_length+0xd9>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <xfree@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_content_length>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,%r12
mov    $0x28,%edi
call   1060 <zalloc@plt>
test   %r12,%r12
je     11b6 <extract_content_length+0x66>
mov    %rax,%r14
nopl   0x0(%rax)
cmpb   $0x3a,(%r12)
lea    0x1(%r12),%r12
jne    1180 <extract_content_length+0x30>
cmpb   $0xd,(%r12)
je     11ea <extract_content_length+0x9a>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x1(%r12,%rax,1),%ecx
cmp    $0xa,%cl
je     11ba <extract_content_length+0x6a>
add    $0x1,%rax
cmp    $0xd,%cl
jne    11a0 <extract_content_length+0x50>
jmp    11be <extract_content_length+0x6e>
xor    %eax,%eax
jmp    11fe <extract_content_length+0xae>
test   %eax,%eax
je     11ea <extract_content_length+0x9a>
mov    %eax,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r12,%rbx,1),%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1040 <strncat@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11d0 <extract_content_length+0x80>
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <xfree@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Content-Length:\00"
define i32 @extract_content_length(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%11 = load i8*, i8** %4
%12 = call i8* @strstr(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %6
store i8* null, i8** %7
store i32 0, i32* %9
%13 = call i64 @zalloc(i32 40)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %8
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %2
store i32 0, i32* %3
br label %65
18: ; preds = %2
br label %19
19: ; preds = %25, %18
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %6
%22 = load i8, i8* %20
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 58
br i1 %24, label %25, label %26
25: ; preds = %19
br label %19
26: ; preds = %19
%27 = load i8*, i8** %6
store i8* %27, i8** %7
br label %28
28: ; preds = %41, %26
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
%31 = load i8, i8* %29
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 13
br i1 %33, label %34, label %39
34: ; preds = %28
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 10
br label %39
39: ; preds = %34, %28
%40 = phi i1 [ false, %28 ], [ %38, %34 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %28
44: ; preds = %39
store i32 0, i32* %10
br label %45
45: ; preds = %56, %44
%46 = load i32, i32* %10
%47 = load i32, i32* %9
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %59
49: ; preds = %45
%50 = load i8*, i8** %8
%51 = load i8*, i8** %7
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = call i32 @strncat(i8* %50, i8* %54, i32 1)
br label %56
56: ; preds = %49
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %45
59: ; preds = %45
%60 = load i8*, i8** %8
%61 = call i32 @atoi(i8* %60)
store i32 %61, i32* %10
%62 = load i8*, i8** %8
%63 = call i32 @xfree(i8* %62)
%64 = load i32, i32* %10
store i32 %64, i32* %3
br label %65
65: ; preds = %59, %17
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [16 x i8] c"Content-Length:\00"
define i32 @extract_content_length(i8* %0, i32 %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @zalloc(i32 40)
%5 = inttoptr i64 %4 to i8*
%6 = icmp eq i8* %3, null
br i1 %6, label %40, label %7
7: ; preds = %2, %7
%8 = phi i8* [ %9, %7 ], [ %3, %2 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %8
%11 = icmp eq i8 %10, 58
br i1 %11, label %12, label %7
12: ; preds = %7
%13 = load i8, i8* %9
%14 = icmp eq i8 %13, 13
br i1 %14, label %37, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %8, i64 2
br label %17
17: ; preds = %15, %22
%18 = phi i8* [ %24, %22 ], [ %16, %15 ]
%19 = phi i32 [ %23, %22 ], [ 0, %15 ]
%20 = load i8, i8* %18
%21 = icmp eq i8 %20, 10
br i1 %21, label %26, label %22
22: ; preds = %17
%23 = add nuw nsw i32 %19, 1
%24 = getelementptr inbounds i8, i8* %18, i64 1
%25 = icmp eq i8 %20, 13
br i1 %25, label %28, label %17
26: ; preds = %17
%27 = icmp eq i32 %19, 0
br i1 %27, label %37, label %28
28: ; preds = %22, %26
%29 = phi i32 [ %19, %26 ], [ %23, %22 ]
%30 = zext i32 %29 to i64
br label %31
31: ; preds = %28, %31
%32 = phi i64 [ 0, %28 ], [ %35, %31 ]
%33 = getelementptr inbounds i8, i8* %9, i64 %32
%34 = tail call i32 @strncat(i8* %5, i8* %33, i32 1)
%35 = add nuw nsw i64 %32, 1
%36 = icmp eq i64 %35, %30
br i1 %36, label %37, label %31
37: ; preds = %31, %12, %26
%38 = tail call i32 @atoi(i8* %5)
%39 = tail call i32 @xfree(i8* %5)
br label %40
40: ; preds = %2, %37
%41 = phi i32 [ %38, %37 ], [ 0, %2 ]
ret i32 %41
}