#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 strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
int MIMEH_is_valid_header_prefix(char *data, char *prefix_name) {
  int plen = strlen(prefix_name);
  if (strncasecmp(data, prefix_name, plen) != 0) {
    return 0;
  } else {
    char end_char;
    end_char = *(data + plen);
    switch (end_char) {
    case ':':
    case ' ':
    case '\t':
    case '\0':
      break;
    default:
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<MIMEH_is_valid_header_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
je     1162 <MIMEH_is_valid_header_prefix+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <MIMEH_is_valid_header_prefix+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     11b7 <MIMEH_is_valid_header_prefix+0x97>
jmp    1184 <MIMEH_is_valid_header_prefix+0x64>
mov    -0x24(%rbp),%eax
sub    $0x9,%eax
je     11b7 <MIMEH_is_valid_header_prefix+0x97>
jmp    1195 <MIMEH_is_valid_header_prefix+0x75>
mov    -0x24(%rbp),%eax
sub    $0x20,%eax
je     11b7 <MIMEH_is_valid_header_prefix+0x97>
jmp    11a6 <MIMEH_is_valid_header_prefix+0x86>
mov    -0x24(%rbp),%eax
sub    $0x3a,%eax
jne    11bc <MIMEH_is_valid_header_prefix+0x9c>
jmp    11b7 <MIMEH_is_valid_header_prefix+0x97>
jmp    11c8 <MIMEH_is_valid_header_prefix+0xa8>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <MIMEH_is_valid_header_prefix+0xb4>
jmp    11cd <MIMEH_is_valid_header_prefix+0xad>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MIMEH_is_valid_header_prefix>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    116d <MIMEH_is_valid_header_prefix+0x4d>
movslq %ebp,%rcx
movsbl (%r14,%rcx,1),%ecx
cmp    $0x3a,%ecx
ja     116d <MIMEH_is_valid_header_prefix+0x4d>
movabs $0x400000100000201,%rdx
bt     %rcx,%rdx
jae    116d <MIMEH_is_valid_header_prefix+0x4d>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @MIMEH_is_valid_header_prefix(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i64 @strncasecmp(i8* %10, i8* %11, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 0, i32* %3
br label %28
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %7
%22 = load i8, i8* %7
%23 = sext i8 %22 to i32
switch i32 %23, label %25 [
i32 58, label %24
i32 32, label %24
i32 9, label %24
i32 0, label %24
]
24: ; preds = %16, %16, %16, %16
br label %26
25: ; preds = %16
store i32 0, i32* %3
br label %28
26: ; preds = %24
br label %27
27: ; preds = %26
store i32 1, i32* %3
br label %28
28: ; preds = %27, %25, %15
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @MIMEH_is_valid_header_prefix(i8* nocapture %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i64 @strncasecmp(i8* %0, i8* %1, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %12 [
i32 58, label %11
i32 32, label %11
i32 9, label %11
i32 0, label %11
]
11: ; preds = %6, %6, %6, %6
br label %12
12: ; preds = %11, %6, %2
%13 = phi i32 [ 0, %2 ], [ 1, %11 ], [ 0, %6 ]
ret i32 %13
}