#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int decode_block(unsigned char *, unsigned char *);
int decode_hex(char *, int, int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ remove(char *);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
char *strrchr(char *, char);
int main(int argc, char **argv) {
  char *c = NULL, *d = NULL, *data = NULL, *dest = NULL, *lastslash = NULL;
  unsigned char out[4];
  FILE *file = NULL;
  int base64 = 0, rval = -1;
  if (argc == 2 && strcmp(argv[1], "-classad") == 0) {
    printf("%s", "PluginVersion = \"0.1\"\n"
                 "PluginType = \"FileTransfer\"\n"
                 "SupportedMethods = \"data\"\n");
    return 0;
  }
  if (argc != 3) {
    return -1;
  }
  data = strchr(argv[1], ',');
  lastslash = strrchr(argv[1], '/');
  dest = argv[2];
  if (data && lastslash && (file = fopen(dest, "w"))) {
    rval = 4;
    c = argv[1];
    d = NULL;
    do {
      d = strchr(c, ';');
      if (d && d < data) {
        base64 = !strncmp(d, ";base64,", 7);
        c = d + 1;
      } else {
        break;
      }
    } while (!base64);
    c = data + 1;
    if (base64) {
      out[3] = '\0';
      while (c && *c && c + 3 < lastslash && rval >= 4) {
        rval = decode_block((unsigned char *)c, out);
        fputs((char *)out, file);
        c += rval;
      }
      if (c < lastslash) {
        rval = -1;
      }
    } else {
      while (c && *c && *c != '/') {
        if (*c == '%') {
          int valid = 0, ch;
          c++;
          ch = decode_hex(c, 2, &valid);
          if (!valid) {
            rval = -1;
            break;
          }
          fputc(ch, file);
          c++;
        } else {
          fputc(*c, file);
        }
        c++;
      }
    }
    fclose(file);
    if (rval < 4) {
      remove(dest);
    } else {
      rval = 0;
    }
  }
  return rval;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0xffffffff,-0x50(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    125b <main+0x9b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd3(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    125b <main+0x9b>
lea    0xdc6(%rip),%rdi
lea    0xdc2(%rip),%rsi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1544 <main+0x384>
cmpl   $0x3,-0x8(%rbp)
je     1271 <main+0xb1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1544 <main+0x384>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2f,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     153e <main+0x37e>
cmpq   $0x0,-0x38(%rbp)
je     153e <main+0x37e>
mov    -0x30(%rbp),%rdi
lea    0xd8f(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     153e <main+0x37e>
movl   $0x4,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3b,%esi
call   1060 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1359 <main+0x199>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1359 <main+0x199>
mov    -0x20(%rbp),%rdi
lea    0xd2d(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    135e <main+0x19e>
jmp    1374 <main+0x1b4>
jmp    1363 <main+0x1a3>
cmpl   $0x0,-0x4c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12f8 <main+0x138>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1431 <main+0x271>
movb   $0x0,-0x39(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x59(%rbp)
je     13d4 <main+0x214>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x59(%rbp)
je     13d4 <main+0x214>
mov    -0x18(%rbp),%rcx
add    $0x3,%rcx
xor    %eax,%eax
cmp    -0x38(%rbp),%rcx
mov    %al,-0x59(%rbp)
jae    13d4 <main+0x214>
cmpl   $0x4,-0x50(%rbp)
setge  %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    13e4 <main+0x224>
jmp    1417 <main+0x257>
mov    -0x18(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
call   10b0 <decode_block@plt>
mov    %eax,-0x50(%rbp)
lea    -0x3c(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   10a0 <fputs@plt>
mov    -0x50(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    138e <main+0x1ce>
mov    -0x18(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    142c <main+0x26c>
movl   $0xffffffff,-0x50(%rbp)
jmp    1511 <main+0x351>
jmp    1436 <main+0x276>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x5a(%rbp)
je     146b <main+0x2ab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x5a(%rbp)
je     146b <main+0x2ab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x5a(%rbp)
mov    -0x5a(%rbp),%al
test   $0x1,%al
jne    147b <main+0x2bb>
jmp    150c <main+0x34c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    14e9 <main+0x329>
movl   $0x0,-0x54(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2,%esi
lea    -0x54(%rbp),%rdx
call   1090 <decode_hex@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    14c9 <main+0x309>
movl   $0xffffffff,-0x50(%rbp)
jmp    150c <main+0x34c>
mov    -0x58(%rbp),%eax
mov    -0x48(%rbp),%rsi
movsbl %al,%edi
call   10c0 <fputc@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    14fb <main+0x33b>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x48(%rbp),%rsi
movsbl %al,%edi
call   10c0 <fputc@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1436 <main+0x276>
jmp    1511 <main+0x351>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
cmpl   $0x4,-0x50(%rbp)
jge    1532 <main+0x372>
mov    -0x30(%rbp),%rdi
call   1030 <remove@plt>
jmp    1539 <main+0x379>
movl   $0x0,-0x50(%rbp)
jmp    153e <main+0x37e>
mov    -0x50(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    $0xffffffff,%r13d
cmp    $0x3,%edi
je     1216 <main+0x56>
cmp    $0x2,%edi
jne    13e3 <main+0x223>
mov    0x8(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    13e3 <main+0x223>
lea    0xe04(%rip),%rdi
lea    0xe00(%rip),%rsi
call   1070 <printf@plt>
jmp    139b <main+0x1db>
mov    0x8(%rbp),%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1060 <strchr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1080 <strrchr@plt>
test   %r14,%r14
je     13e3 <main+0x223>
mov    %rax,%r15
test   %rax,%rax
je     13e3 <main+0x223>
mov    0x10(%rbp),%rbx
lea    0xe02(%rip),%rsi
mov    %rbx,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     13e3 <main+0x223>
mov    %rax,%r12
mov    %rbx,0x10(%rsp)
mov    %r14,%rbx
mov    0x8(%rbp),%rbp
lea    0xddd(%rip),%r13
xchg   %ax,%ax
mov    %rbp,%rdi
mov    $0x3b,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     133f <main+0x17f>
mov    %rax,%rbp
cmp    %r14,%rax
jae    133f <main+0x17f>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
add    $0x1,%rbp
test   %eax,%eax
jne    1280 <main+0xc0>
add    $0x1,%r14
movb   $0x0,0xf(%rsp)
cmpb   $0x0,0x1(%rbx)
je     13a0 <main+0x1e0>
mov    $0x4,%ebp
lea    0xc(%rsp),%r13
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
lea    0x3(%rbx),%rax
cmp    %r15,%rax
jae    13a7 <main+0x1e7>
cmp    $0x4,%ebp
jl     13a7 <main+0x1e7>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <decode_block@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r12,%rsi
call   10a0 <fputs@plt>
movslq %ebp,%rax
lea    (%rbx,%rax,1),%r14
cmpb   $0x0,(%rbx,%rax,1)
mov    %r14,%rbx
jne    12e0 <main+0x120>
jmp    13aa <main+0x1ea>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
movsbl %al,%edi
mov    %r12,%rsi
call   10c0 <fputc@plt>
movzbl 0x1(%rbx),%eax
cmp    $0x25,%al
je     1360 <main+0x1a0>
test   %al,%al
je     1393 <main+0x1d3>
cmp    $0x2f,%al
jne    1330 <main+0x170>
jmp    1393 <main+0x1d3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0x0,0x8(%rsp)
lea    0x2(%rbx),%rdi
lea    0x8(%rsp),%rdx
mov    $0x2,%esi
call   1090 <decode_hex@plt>
cmpl   $0x0,0x8(%rsp)
je     13c6 <main+0x206>
movsbl %al,%edi
mov    %r12,%rsi
call   10c0 <fputc@plt>
add    $0x3,%rbx
jmp    133f <main+0x17f>
mov    %r12,%rdi
call   1050 <fclose@plt>
xor    %r13d,%r13d
jmp    13e3 <main+0x223>
mov    $0x4,%ebp
jmp    13aa <main+0x1ea>
mov    %rbx,%r14
cmp    %r15,%r14
mov    0x10(%rsp),%rbx
jb     13cb <main+0x20b>
mov    %r12,%rdi
call   1050 <fclose@plt>
xor    %r13d,%r13d
cmp    $0x3,%ebp
jg     13e3 <main+0x223>
jmp    13d8 <main+0x218>
mov    0x10(%rsp),%rbx
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1030 <remove@plt>
mov    %ebp,%r13d
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"-classad\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [77 x i8] c"PluginVersion = \220.1\22\0APluginType = \22FileTransfer\22\0ASupportedMethods = \22data\22\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c";base64,\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [4 x i8]
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i32* null, i32** %12
store i32 0, i32* %13
store i32 -1, i32* %14
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %27
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %178
27: ; preds = %19, %2
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 3
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 -1, i32* %3
br label %178
31: ; preds = %27
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i8* @strchr(i8* %34, i8 signext 44)
store i8* %35, i8** %8
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i8* @strrchr(i8* %38, i8 signext 47)
store i8* %39, i8** %10
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
store i8* %42, i8** %9
%43 = load i8*, i8** %8
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %176
45: ; preds = %31
%46 = load i8*, i8** %10
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %176
48: ; preds = %45
%49 = load i8*, i8** %9
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %50, i32** %12
%51 = icmp ne i32* %50, null
br i1 %51, label %52, label %176
52: ; preds = %48
store i32 4, i32* %14
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
store i8* %55, i8** %6
store i8* null, i8** %7
br label %56
56: ; preds = %75, %52
%57 = load i8*, i8** %6
%58 = call i8* @strchr(i8* %57, i8 signext 59)
store i8* %58, i8** %7
%59 = load i8*, i8** %7
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %73
61: ; preds = %56
%62 = load i8*, i8** %7
%63 = load i8*, i8** %8
%64 = icmp ult i8* %62, %63
br i1 %64, label %65, label %73
65: ; preds = %61
%66 = load i8*, i8** %7
%67 = call i32 @strncmp(i8* %66, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 7)
%68 = icmp ne i32 %67, 0
%69 = xor i1 %68, true
%70 = zext i1 %69 to i32
store i32 %70, i32* %13
%71 = load i8*, i8** %7
%72 = getelementptr inbounds i8, i8* %71, i64 1
store i8* %72, i8** %6
br label %74
73: ; preds = %61, %56
br label %79
74: ; preds = %65
br label %75
75: ; preds = %74
%76 = load i32, i32* %13
%77 = icmp ne i32 %76, 0
%78 = xor i1 %77, true
br i1 %78, label %56, label %79
79: ; preds = %75, %73
%80 = load i8*, i8** %8
%81 = getelementptr inbounds i8, i8* %80, i64 1
store i8* %81, i8** %6
%82 = load i32, i32* %13
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %121
84: ; preds = %79
%85 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 3
store i8 0, i8* %85
br label %86
86: ; preds = %104, %84
%87 = load i8*, i8** %6
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %102
89: ; preds = %86
%90 = load i8*, i8** %6
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %102
94: ; preds = %89
%95 = load i8*, i8** %6
%96 = getelementptr inbounds i8, i8* %95, i64 3
%97 = load i8*, i8** %10
%98 = icmp ult i8* %96, %97
br i1 %98, label %99, label %102
99: ; preds = %94
%100 = load i32, i32* %14
%101 = icmp sge i32 %100, 4
br label %102
102: ; preds = %99, %94, %89, %86
%103 = phi i1 [ false, %94 ], [ false, %89 ], [ false, %86 ], [ %101, %99 ]
br i1 %103, label %104, label %115
104: ; preds = %102
%105 = load i8*, i8** %6
%106 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%107 = call i32 @decode_block(i8* %105, i8* %106)
store i32 %107, i32* %14
%108 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%109 = load i32*, i32** %12
%110 = call i32 @fputs(i8* %108, i32* %109)
%111 = load i32, i32* %14
%112 = load i8*, i8** %6
%113 = sext i32 %111 to i64
%114 = getelementptr inbounds i8, i8* %112, i64 %113
store i8* %114, i8** %6
br label %86
115: ; preds = %102
%116 = load i8*, i8** %6
%117 = load i8*, i8** %10
%118 = icmp ult i8* %116, %117
br i1 %118, label %119, label %120
119: ; preds = %115
store i32 -1, i32* %14
br label %120
120: ; preds = %119, %115
br label %166
121: ; preds = %79
br label %122
122: ; preds = %162, %121
%123 = load i8*, i8** %6
%124 = icmp ne i8* %123, null
br i1 %124, label %125, label %135
125: ; preds = %122
%126 = load i8*, i8** %6
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp ne i32 %128, 0
br i1 %129, label %130, label %135
130: ; preds = %125
%131 = load i8*, i8** %6
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp ne i32 %133, 47
br label %135
135: ; preds = %130, %125, %122
%136 = phi i1 [ false, %125 ], [ false, %122 ], [ %134, %130 ]
br i1 %136, label %137, label %165
137: ; preds = %135
%138 = load i8*, i8** %6
%139 = load i8, i8* %138
%140 = sext i8 %139 to i32
%141 = icmp eq i32 %140, 37
br i1 %141, label %142, label %157
142: ; preds = %137
store i32 0, i32* %15
%143 = load i8*, i8** %6
%144 = getelementptr inbounds i8, i8* %143, i32 1
store i8* %144, i8** %6
%145 = load i8*, i8** %6
%146 = call i32 @decode_hex(i8* %145, i32 2, i32* %15)
store i32 %146, i32* %16
%147 = load i32, i32* %15
%148 = icmp ne i32 %147, 0
br i1 %148, label %150, label %149
149: ; preds = %142
store i32 -1, i32* %14
br label %165
150: ; preds = %142
%151 = load i32, i32* %16
%152 = trunc i32 %151 to i8
%153 = load i32*, i32** %12
%154 = call i32 @fputc(i8 signext %152, i32* %153)
%155 = load i8*, i8** %6
%156 = getelementptr inbounds i8, i8* %155, i32 1
store i8* %156, i8** %6
br label %162
157: ; preds = %137
%158 = load i8*, i8** %6
%159 = load i8, i8* %158
%160 = load i32*, i32** %12
%161 = call i32 @fputc(i8 signext %159, i32* %160)
br label %162
162: ; preds = %157, %150
%163 = load i8*, i8** %6
%164 = getelementptr inbounds i8, i8* %163, i32 1
store i8* %164, i8** %6
br label %122
165: ; preds = %149, %135
br label %166
166: ; preds = %165, %120
%167 = load i32*, i32** %12
%168 = call i32 @fclose(i32* %167)
%169 = load i32, i32* %14
%170 = icmp slt i32 %169, 4
br i1 %170, label %171, label %174
171: ; preds = %166
%172 = load i8*, i8** %9
%173 = call i32 @remove(i8* %172)
br label %175
174: ; preds = %166
store i32 0, i32* %14
br label %175
175: ; preds = %174, %171
br label %176
176: ; preds = %175, %48, %45, %31
%177 = load i32, i32* %14
store i32 %177, i32* %3
br label %178
178: ; preds = %176, %30, %25
%179 = load i32, i32* %3
ret i32 %179
}

LLVM IR (-O2):
@.str = [9 x i8] c"-classad\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [77 x i8] c"PluginVersion = \220.1\22\0APluginType = \22FileTransfer\22\0ASupportedMethods = \22data\22\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c";base64,\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
switch i32 %0, label %91 [
i32 2, label %6
i32 3, label %13
]
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %91
11: ; preds = %6
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
br label %91
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i8* @strchr(i8* dereferenceable(1) %15, i8 signext 44)
%17 = tail call i8* @strrchr(i8* dereferenceable(1) %15, i8 signext 47)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = icmp ne i8* %16, null
%21 = icmp ne i8* %17, null
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %23, label %91
23: ; preds = %13
%24 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %91, label %26
26: ; preds = %23
%27 = load i8*, i8** %14
br label %28
28: ; preds = %36, %26
%29 = phi i8* [ %27, %26 ], [ %39, %36 ]
%30 = tail call i8* @strchr(i8* dereferenceable(1) %29, i8 signext 59)
%31 = icmp ne i8* %30, null
%32 = icmp ult i8* %30, %16
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %36, label %34
34: ; preds = %28
%35 = bitcast i32* %4 to i8*
br label %63
36: ; preds = %28
%37 = tail call i32 @strncmp(i8* %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 7)
%38 = icmp eq i32 %37, 0
%39 = getelementptr inbounds i8, i8* %30, i64 1
br i1 %38, label %40, label %28
40: ; preds = %36
%41 = getelementptr inbounds i8, i8* %16, i64 1
%42 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 0, i8* %42
%43 = load i8, i8* %41
%44 = icmp eq i8 %43, 0
br i1 %44, label %59, label %45
45: ; preds = %40, %52
%46 = phi i32 [ %53, %52 ], [ 4, %40 ]
%47 = phi i8* [ %56, %52 ], [ %41, %40 ]
%48 = getelementptr inbounds i8, i8* %47, i64 3
%49 = icmp ult i8* %48, %17
%50 = icmp sgt i32 %46, 3
%51 = select i1 %49, i1 %50, i1 false
br i1 %51, label %52, label %59
52: ; preds = %45
%53 = call i32 @decode_block(i8* %47, i8* %5)
%54 = call i32 @fputs(i8* %5, i32* %24)
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i8, i8* %47, i64 %55
%57 = load i8, i8* %56
%58 = icmp eq i8 %57, 0
br i1 %58, label %59, label %45
59: ; preds = %45, %52, %40
%60 = phi i8* [ %41, %40 ], [ %56, %52 ], [ %47, %45 ]
%61 = phi i32 [ 4, %40 ], [ %53, %52 ], [ %46, %45 ]
%62 = icmp ult i8* %60, %17
br i1 %62, label %81, label %85
63: ; preds = %76, %34
%64 = phi i8* [ %16, %34 ], [ %77, %76 ]
%65 = getelementptr inbounds i8, i8* %64, i64 1
%66 = load i8, i8* %65
switch i8 %66, label %79 [
i8 0, label %83
i8 47, label %83
i8 37, label %67
]
67: ; preds = %63
store i32 0, i32* %4
%68 = getelementptr inbounds i8, i8* %64, i64 2
%69 = call i32 @decode_hex(i8* %68, i32 2, i32* %4)
%70 = load i32, i32* %4
%71 = icmp eq i32 %70, 0
br i1 %71, label %78, label %72
72: ; preds = %67
%73 = trunc i32 %69 to i8
%74 = call i32 @fputc(i8 signext %73, i32* %24)
%75 = getelementptr inbounds i8, i8* %64, i64 3
br label %76
76: ; preds = %72, %79
%77 = phi i8* [ %65, %79 ], [ %75, %72 ]
br label %63
78: ; preds = %67
br label %81
79: ; preds = %63
%80 = call i32 @fputc(i8 signext %66, i32* %24)
br label %76
81: ; preds = %78, %59
%82 = call i32 @fclose(i32* %24)
br label %88
83: ; preds = %63, %63
%84 = call i32 @fclose(i32* %24)
br label %91
85: ; preds = %59
%86 = call i32 @fclose(i32* %24)
%87 = icmp slt i32 %61, 4
br i1 %87, label %88, label %91
88: ; preds = %81, %85
%89 = phi i32 [ -1, %81 ], [ %61, %85 ]
%90 = call i32 @remove(i8* %19)
br label %91
91: ; preds = %83, %6, %13, %23, %88, %85, %2, %11
%92 = phi i32 [ 0, %11 ], [ -1, %2 ], [ %89, %88 ], [ -1, %23 ], [ -1, %13 ], [ 0, %85 ], [ -1, %6 ], [ 0, %83 ]
ret i32 %92
}