#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 /*<<< orphan*/ free(char *);
char *get_header_dup(char *, char const *);
int /*<<< orphan*/ io_err(char *);
scalar_t__ strstr(char *, char *);
int is_html(const char *header) {
  int r = 0;
  char *type;
  if (header == NULL) {
    io_err("FIX THIS BUG:  NULL HEADER!!\n"
           "LOOK UP ABOVE TO FIND THE URL THAT IS GIVING US "
           "THIS PROBLEM!!\n");
    return 0;
  }
  type = get_header_dup("Content-type", header);
  if (type == NULL)
    return 0;
  if (strstr(type, "html"))
    r = 1;
  do {
    if ((type) != NULL) {
      free(type);
      (type) = NULL;
    }
  } while (0);
  return r;
}


x86 assembly (clang, -O0):
<is_html>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1176 <is_html+0x36>
lea    0xe9b(%rip),%rdi
call   1040 <io_err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ee <is_html+0xae>
mov    -0x10(%rbp),%rsi
lea    0xedc(%rip),%rdi
call   1050 <get_header_dup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a1 <is_html+0x61>
movl   $0x0,-0x4(%rbp)
jmp    11ee <is_html+0xae>
mov    -0x20(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11c2 <is_html+0x82>
movl   $0x1,-0x14(%rbp)
jmp    11c7 <is_html+0x87>
cmpq   $0x0,-0x20(%rbp)
je     11e3 <is_html+0xa3>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
jmp    11e8 <is_html+0xa8>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_html>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1181 <is_html+0x41>
mov    %rdi,%rsi
lea    0xf0b(%rip),%rdi
call   1050 <get_header_dup@plt>
test   %rax,%rax
je     118d <is_html+0x4d>
mov    %rax,%rbx
lea    0xf04(%rip),%rsi
mov    %rax,%rdi
call   1060 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    118f <is_html+0x4f>
lea    0xe78(%rip),%rdi
call   1040 <io_err@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [93 x i8] c"FIX THIS BUG: NULL HEADER!!\0ALOOK UP ABOVE TO FIND THE URL THAT IS GIVING US THIS PROBLEM!!\0A\00"
@.str.1 = [13 x i8] c"Content-type\00"
@.str.2 = [5 x i8] c"html\00"
define i32 @is_html(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @io_err(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %31
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @get_header_dup(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 0, i32* %2
br label %31
16: ; preds = %10
%17 = load i8*, i8** %5
%18 = call i64 @strstr(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 1, i32* %4
br label %21
21: ; preds = %20, %16
br label %22
22: ; preds = %21
%23 = load i8*, i8** %5
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
store i8* null, i8** %5
br label %28
28: ; preds = %25, %22
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
store i32 %30, i32* %2
br label %31
31: ; preds = %29, %15, %8
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [93 x i8] c"FIX THIS BUG: NULL HEADER!!\0ALOOK UP ABOVE TO FIND THE URL THAT IS GIVING US THIS PROBLEM!!\0A\00"
@.str.1 = [13 x i8] c"Content-type\00"
@.str.2 = [5 x i8] c"html\00"
define i32 @is_html(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @io_err(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0))
br label %13
5: ; preds = %1
%6 = tail call i8* @get_header_dup(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i64 @strstr(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @free(i8* %6)
br label %13
13: ; preds = %5, %8, %3
%14 = phi i32 [ 0, %3 ], [ %11, %8 ], [ 0, %5 ]
ret i32 %14
}