#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*/ base64_decode(char **, char **);
int /*<<< orphan*/ quoted_printable_decode(char **, char **);
void DecodeMime(char *s) {
  char *buf = NULL;
  if (!s)
    return;
  buf = s;
  while (*buf) {
    if ((*buf == '=') && (*++buf == '?')) {
      char tmp;
      while (*++buf != '?')
        ;
      buf++;
      tmp = *buf;
      buf += 2;
      if ((tmp == 'Q') || (tmp == 'q'))
        quoted_printable_decode(&s, &buf);
      else if ((tmp == 'B') || (tmp == 'b'))
        base64_decode(&s, &buf);
    } else {
      *s++ = *buf++;
    }
  }
  *s = 0;
}


x86 assembly (clang, -O0):
<DecodeMime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1144 <DecodeMime+0x24>
jmp    1257 <DecodeMime+0x137>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1250 <DecodeMime+0x130>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    1229 <DecodeMime+0x109>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x3f,%eax
jne    1229 <DecodeMime+0x109>
jmp    118a <DecodeMime+0x6a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x3f,%eax
je     11ab <DecodeMime+0x8b>
jmp    118a <DecodeMime+0x6a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x51,%eax
je     11e6 <DecodeMime+0xc6>
movsbl -0x11(%rbp),%eax
cmp    $0x71,%eax
jne    11f8 <DecodeMime+0xd8>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <quoted_printable_decode@plt>
jmp    1224 <DecodeMime+0x104>
movsbl -0x11(%rbp),%eax
cmp    $0x42,%eax
je     1212 <DecodeMime+0xf2>
movsbl -0x11(%rbp),%eax
cmp    $0x62,%eax
jne    121f <DecodeMime+0xff>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <base64_decode@plt>
jmp    1224 <DecodeMime+0x104>
jmp    124b <DecodeMime+0x12b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    114c <DecodeMime+0x2c>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DecodeMime>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
test   %rdi,%rdi
je     11f4 <DecodeMime+0xd4>
mov    %rdi,0x8(%rsp)
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rbx
jmp    117b <DecodeMime+0x5b>
cs nopw 0x0(%rax,%rax,1)
mov    %rdi,%rax
test   %cl,%cl
je     11ec <DecodeMime+0xcc>
lea    0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    (%rax),%al
mov    0x10(%rsp),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,0x10(%rsp)
mov    %al,(%rcx)
mov    0x8(%rsp),%rdi
mov    (%rdi),%cl
cmp    $0x3d,%cl
jne    1150 <DecodeMime+0x30>
lea    0x1(%rdi),%rax
mov    %rax,0x8(%rsp)
cmpb   $0x3f,0x1(%rdi)
jne    115b <DecodeMime+0x3b>
add    $0x2,%rdi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rdi,0x8(%rsp)
cmpb   $0x3f,(%rdi)
lea    0x1(%rdi),%rdi
jne    11a0 <DecodeMime+0x80>
mov    %rdi,0x8(%rsp)
mov    (%rdi),%al
add    $0x2,%rdi
mov    %rdi,0x8(%rsp)
and    $0xdf,%al
cmp    $0x42,%al
je     11da <DecodeMime+0xba>
cmp    $0x51,%al
jne    11e5 <DecodeMime+0xc5>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <quoted_printable_decode@plt>
mov    0x8(%rsp),%rdi
jmp    117b <DecodeMime+0x5b>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <base64_decode@plt>
mov    0x8(%rsp),%rdi
jmp    117b <DecodeMime+0x5b>
mov    0x10(%rsp),%rax
movb   $0x0,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @DecodeMime(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
br label %70
8: ; preds = %1
%9 = load i8*, i8** %2
store i8* %9, i8** %3
br label %10
10: ; preds = %67, %8
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %68
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 61
br i1 %18, label %19, label %61
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 63
br i1 %24, label %25, label %61
25: ; preds = %19
br label %26
26: ; preds = %32, %25
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 63
br i1 %31, label %32, label %33
32: ; preds = %26
br label %26
33: ; preds = %26
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
%36 = load i8*, i8** %3
%37 = load i8, i8* %36
store i8 %37, i8* %4
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 2
store i8* %39, i8** %3
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 81
br i1 %42, label %47, label %43
43: ; preds = %33
%44 = load i8, i8* %4
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 113
br i1 %46, label %47, label %49
47: ; preds = %43, %33
%48 = call i32 @quoted_printable_decode(i8** %2, i8** %3)
br label %60
49: ; preds = %43
%50 = load i8, i8* %4
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 66
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i8, i8* %4
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 98
br i1 %56, label %57, label %59
57: ; preds = %53, %49
%58 = call i32 @base64_decode(i8** %2, i8** %3)
br label %59
59: ; preds = %57, %53
br label %60
60: ; preds = %59, %47
br label %67
61: ; preds = %19, %14
%62 = load i8*, i8** %3
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %3
%64 = load i8, i8* %62
%65 = load i8*, i8** %2
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %2
store i8 %64, i8* %65
br label %67
67: ; preds = %61, %60
br label %10
68: ; preds = %10
%69 = load i8*, i8** %2
store i8 0, i8* %69
br label %70
70: ; preds = %68, %7
ret void
}

LLVM IR (-O2):
define void @DecodeMime(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %38, label %6
6: ; preds = %1
store i8* %0, i8** %3
br label %7
7: ; preds = %34, %6
%8 = phi i8* [ %35, %34 ], [ %0, %6 ]
%9 = load i8, i8* %8
switch i8 %9, label %28 [
i8 0, label %36
i8 61, label %10
]
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %11, i8** %3
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 63
br i1 %13, label %14, label %28
14: ; preds = %10, %14
%15 = phi i8* [ %16, %14 ], [ %11, %10 ]
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %16, i8** %3
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 63
br i1 %18, label %19, label %14
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %15, i64 2
store i8* %20, i8** %3
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %15, i64 4
store i8* %22, i8** %3
%23 = and i8 %21, -33
switch i8 %23, label %34 [
i8 81, label %24
i8 66, label %26
]
24: ; preds = %19
%25 = call i32 @quoted_printable_decode(i8** %2, i8** %3)
br label %34
26: ; preds = %19
%27 = call i32 @base64_decode(i8** %2, i8** %3)
br label %34
28: ; preds = %7, %10
%29 = phi i8* [ %8, %7 ], [ %11, %10 ]
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8* %30, i8** %3
%31 = load i8, i8* %29
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8* %33, i8** %2
store i8 %31, i8* %32
br label %34
34: ; preds = %19, %24, %26, %28
%35 = load i8*, i8** %3
br label %7
36: ; preds = %7
%37 = load i8*, i8** %2
store i8 0, i8* %37
br label %38
38: ; preds = %1, %36
ret void
}