#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__ isspace(char);
char *strcasestr(char *, char *);
char *strchr(char *, char);
char *strprint(char *);
char *http_get_field(char *buf, char *name) {
  char *attr = 0;
  char *val = 0;
  attr = strcasestr(buf, name);
  if (!attr)
    return 0;
  val = strchr(attr, ':');
  if (!val)
    return 0;
  val++;
  if (isspace(*val))
    val = strprint(val);
  return val;
}


x86 assembly (clang, -O0):
<http_get_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcasestr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1189 <http_get_field+0x49>
movq   $0x0,-0x8(%rbp)
jmp    11ea <http_get_field+0xaa>
mov    -0x20(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b3 <http_get_field+0x73>
movq   $0x0,-0x8(%rbp)
jmp    11ea <http_get_field+0xaa>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11e2 <http_get_field+0xa2>
mov    -0x28(%rbp),%rdi
call   1050 <strprint@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_get_field>:
push   %rbx
call   1060 <strcasestr@plt>
test   %rax,%rax
je     117b <http_get_field+0x3b>
mov    %rax,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     117b <http_get_field+0x3b>
mov    %rax,%rbx
add    $0x1,%rbx
movsbl 0x1(%rax),%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     117d <http_get_field+0x3d>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <strprint@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @http_get_field(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
store i8* null, i8** %7
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i8* @strcasestr(i8* %8, i8* %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %2
store i8* null, i8** %3
br label %32
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = call i8* @strchr(i8* %15, i8 signext 58)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %14
store i8* null, i8** %3
br label %32
20: ; preds = %14
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = load i8, i8* %23
%25 = call i64 @isspace(i8 signext %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i8*, i8** %7
%29 = call i8* @strprint(i8* %28)
store i8* %29, i8** %7
br label %30
30: ; preds = %27, %20
%31 = load i8*, i8** %7
store i8* %31, i8** %3
br label %32
32: ; preds = %30, %19, %13
%33 = load i8*, i8** %3
ret i8* %33
}

LLVM IR (-O2):
define i8* @http_get_field(i8* %0, i8* %1) {
%3 = tail call i8* @strcasestr(i8* %0, i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i8* @strchr(i8* %3, i8 signext 58)
%7 = icmp eq i8* %6, null
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = tail call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = tail call i8* @strprint(i8* %9)
br label %15
15: ; preds = %8, %13, %5, %2
%16 = phi i8* [ null, %2 ], [ null, %5 ], [ %14, %13 ], [ %9, %8 ]
ret i8* %16
}