#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 */
unsigned int mz_base64_decode_step(char const *, unsigned int, unsigned char *,
                                   int *, unsigned int *);
char *mz_utils_get_attachment_body_place(char const *, char const *,
                                         unsigned int *);
char *mz_utils_get_content_transfer_encoding(char const *);
int /*<<< orphan*/ strncasecmp(char *, char *, int);
const char *mz_utils_get_decoded_attachment_body(const char *contents,
                                                 const char *boundary,
                                                 unsigned int *size) {
  const char *body;
  char *encoding;
  unsigned int encoded_body_length = 0;
  int state = 0;
  unsigned int save = 0;
  *size = 0;
  body = mz_utils_get_attachment_body_place(contents, boundary,
                                            &encoded_body_length);
  if (!body)
    return NULL;
  encoding = mz_utils_get_content_transfer_encoding(contents);
  if (!strncasecmp(encoding, "base64", 6)) {
    *size = mz_base64_decode_step(body, encoded_body_length,
                                  (unsigned char *)body, &state, &save);
  } else if (!strncasecmp(encoding, "7bit", 4) ||
             !strncasecmp(encoding, "8bit", 4)) {
    *size = encoded_body_length;
  } else {
  }
  return body;
}


x86 assembly (clang, -O0):
<mz_utils_get_decoded_attachment_body>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   1030 <mz_utils_get_attachment_body_place@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a0 <mz_utils_get_decoded_attachment_body+0x60>
movq   $0x0,-0x8(%rbp)
jmp    124c <mz_utils_get_decoded_attachment_body+0x10c>
mov    -0x10(%rbp),%rdi
call   1060 <mz_utils_get_content_transfer_encoding@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe48(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    11f0 <mz_utils_get_decoded_attachment_body+0xb0>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x28(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1050 <mz_base64_decode_step@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    1244 <mz_utils_get_decoded_attachment_body+0x104>
mov    -0x30(%rbp),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
je     122c <mz_utils_get_decoded_attachment_body+0xec>
mov    -0x30(%rbp),%rdi
lea    0xdf3(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%eax
jne    123a <mz_utils_get_decoded_attachment_body+0xfa>
mov    -0x34(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    123f <mz_utils_get_decoded_attachment_body+0xff>
jmp    123f <mz_utils_get_decoded_attachment_body+0xff>
jmp    1244 <mz_utils_get_decoded_attachment_body+0x104>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mz_utils_get_decoded_attachment_body>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,(%rdx)
lea    0xc(%rsp),%rdx
call   1030 <mz_utils_get_attachment_body_place@plt>
mov    %rax,%r12
test   %rax,%rax
je     11f6 <mz_utils_get_decoded_attachment_body+0xb6>
mov    %rbx,%rdi
call   1060 <mz_utils_get_content_transfer_encoding@plt>
mov    %rax,%r15
lea    0xe6d(%rip),%rsi
mov    %rax,%rdi
mov    $0x6,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11da <mz_utils_get_decoded_attachment_body+0x9a>
lea    0xe5c(%rip),%rsi
mov    %r15,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
je     11d4 <mz_utils_get_decoded_attachment_body+0x94>
lea    0xe49(%rip),%rsi
mov    %r15,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %eax,%eax
jne    11f6 <mz_utils_get_decoded_attachment_body+0xb6>
mov    0xc(%rsp),%eax
jmp    11f3 <mz_utils_get_decoded_attachment_body+0xb3>
mov    0xc(%rsp),%esi
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %r12,%rdi
mov    %r12,%rdx
call   1050 <mz_base64_decode_step@plt>
mov    %eax,(%r14)
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"base64\00"
@.str.1 = [5 x i8] c"7bit\00"
@.str.2 = [5 x i8] c"8bit\00"
define i8* @mz_utils_get_decoded_attachment_body(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load i32*, i32** %7
store i32 0, i32* %13
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = call i8* @mz_utils_get_attachment_body_place(i8* %14, i8* %15, i32* %10)
store i8* %16, i8** %8
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %3
store i8* null, i8** %4
br label %47
20: ; preds = %3
%21 = load i8*, i8** %5
%22 = call i8* @mz_utils_get_content_transfer_encoding(i8* %21)
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = call i32 @strncasecmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%25 = icmp ne i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %20
%27 = load i8*, i8** %8
%28 = load i32, i32* %10
%29 = load i8*, i8** %8
%30 = call i32 @mz_base64_decode_step(i8* %27, i32 %28, i8* %29, i32* %11, i32* %12)
%31 = load i32*, i32** %7
store i32 %30, i32* %31
br label %45
32: ; preds = %20
%33 = load i8*, i8** %9
%34 = call i32 @strncasecmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i8*, i8** %9
%38 = call i32 @strncasecmp(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %36, %32
%41 = load i32, i32* %10
%42 = load i32*, i32** %7
store i32 %41, i32* %42
br label %44
43: ; preds = %36
br label %44
44: ; preds = %43, %40
br label %45
45: ; preds = %44, %26
%46 = load i8*, i8** %8
store i8* %46, i8** %4
br label %47
47: ; preds = %45, %19
%48 = load i8*, i8** %4
ret i8* %48
}

LLVM IR (-O2):
@.str = [7 x i8] c"base64\00"
@.str.1 = [5 x i8] c"7bit\00"
@.str.2 = [5 x i8] c"8bit\00"
define i8* @mz_utils_get_decoded_attachment_body(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = bitcast i32* %6 to i8*
store i32 0, i32* %6
store i32 0, i32* %2
%10 = call i8* @mz_utils_get_attachment_body_place(i8* %0, i8* %1, i32* %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %29, label %12
12: ; preds = %3
%13 = call i8* @mz_utils_get_content_transfer_encoding(i8* %0)
%14 = call i32 @strncasecmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %4
%18 = call i32 @mz_base64_decode_step(i8* %10, i32 %17, i8* %10, i32* %5, i32* %6)
br label %27
19: ; preds = %12
%20 = call i32 @strncasecmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%21 = icmp eq i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = call i32 @strncasecmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22, %19
%26 = load i32, i32* %4
br label %27
27: ; preds = %25, %16
%28 = phi i32 [ %18, %16 ], [ %26, %25 ]
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %22, %3
ret i8* %10
}