#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__ strcasecmp(char *, char *);
char *strstr(char *, char *);
int ParseMimeHeaders(char *message, char **mimeInfo, char **im) {
  char *place;
  *mimeInfo = strstr(message, "MIME-Version: ");
  place = strstr(message, "\r\n\r\n");
  if (place == NULL)
    return -1;
  *place = '\0';
  *im = place + 4;
  if (strcasecmp(*im, "\r\n") == 0)
    *im += 2;
  return 0;
}


x86 assembly (clang, -O0):
<ParseMimeHeaders>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1179 <ParseMimeHeaders+0x59>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c1 <ParseMimeHeaders+0xa1>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rcx
add    $0x4,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xe74(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11ba <ParseMimeHeaders+0x9a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0x2,%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParseMimeHeaders>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xecb(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,(%r15)
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     117d <ParseMimeHeaders+0x5d>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x4(%rax),%rdi
mov    %rdi,(%r14)
lea    0xeac(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1182 <ParseMimeHeaders+0x62>
add    $0x6,%rbx
mov    %rbx,(%r14)
jmp    1182 <ParseMimeHeaders+0x62>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"MIME-Version: \00"
@.str.1 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define i32 @ParseMimeHeaders(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i8*, i8** %5
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%11 = load i8**, i8*** %6
store i8* %10, i8** %11
%12 = load i8*, i8** %5
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 -1, i32* %4
br label %31
17: ; preds = %3
%18 = load i8*, i8** %8
store i8 0, i8* %18
%19 = load i8*, i8** %8
%20 = getelementptr inbounds i8, i8* %19, i64 4
%21 = load i8**, i8*** %7
store i8* %20, i8** %21
%22 = load i8**, i8*** %7
%23 = load i8*, i8** %22
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %17
%27 = load i8**, i8*** %7
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 2
store i8* %29, i8** %27
br label %30
30: ; preds = %26, %17
store i32 0, i32* %4
br label %31
31: ; preds = %30, %16
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@.str = [15 x i8] c"MIME-Version: \00"
@.str.1 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.2 = [3 x i8] c"\0D\0A\00"
define i32 @ParseMimeHeaders(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
%5 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %3
store i8 0, i8* %5
%8 = getelementptr inbounds i8, i8* %5, i64 4
store i8* %8, i8** %2
%9 = tail call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %5, i64 6
store i8* %12, i8** %2
br label %13
13: ; preds = %7, %11, %3
%14 = phi i32 [ -1, %3 ], [ 0, %11 ], [ 0, %7 ]
ret i32 %14
}