#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 /*<<< 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);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strrchr(char *, char);
char strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  char *c = NULL, *d = NULL, *data = NULL, *dest = NULL, *lastslash = NULL;
  unsigned char out[4];
  char hex[2];
  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 == '%') {
          c++;
          strncpy(hex, c, 2);
          fputc(strtol(hex, NULL, 16), 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    126b <main+0x9b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc3(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    126b <main+0x9b>
lea    0xdb6(%rip),%rdi
lea    0xdb2(%rip),%rsi
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1543 <main+0x373>
cmpl   $0x3,-0x8(%rbp)
je     1281 <main+0xb1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1543 <main+0x373>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     153d <main+0x36d>
cmpq   $0x0,-0x38(%rbp)
je     153d <main+0x36d>
mov    -0x30(%rbp),%rdi
lea    0xd7f(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     153d <main+0x36d>
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   1070 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1369 <main+0x199>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1369 <main+0x199>
mov    -0x20(%rbp),%rdi
lea    0xd1d(%rip),%rsi
mov    $0x7,%edx
call   1050 <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    136e <main+0x19e>
jmp    1384 <main+0x1b4>
jmp    1373 <main+0x1a3>
cmpl   $0x0,-0x4c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1308 <main+0x138>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1441 <main+0x271>
movb   $0x0,-0x39(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x51(%rbp)
je     13e4 <main+0x214>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x51(%rbp)
je     13e4 <main+0x214>
mov    -0x18(%rbp),%rcx
add    $0x3,%rcx
xor    %eax,%eax
cmp    -0x38(%rbp),%rcx
mov    %al,-0x51(%rbp)
jae    13e4 <main+0x214>
cmpl   $0x4,-0x50(%rbp)
setge  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    13f4 <main+0x224>
jmp    1427 <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    139e <main+0x1ce>
mov    -0x18(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    143c <main+0x26c>
movl   $0xffffffff,-0x50(%rbp)
jmp    1510 <main+0x340>
jmp    1446 <main+0x276>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x52(%rbp)
je     147b <main+0x2ab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x52(%rbp)
je     147b <main+0x2ab>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x52(%rbp)
mov    -0x52(%rbp),%al
test   $0x1,%al
jne    148b <main+0x2bb>
jmp    150b <main+0x33b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    14e8 <main+0x318>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    -0x3e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x3e(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10e0 <strtol@plt>
mov    -0x48(%rbp),%rsi
movsbl %al,%edi
call   10c0 <fputc@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    14fa <main+0x32a>
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    1446 <main+0x276>
jmp    1510 <main+0x340>
mov    -0x48(%rbp),%rdi
call   1060 <fclose@plt>
cmpl   $0x4,-0x50(%rbp)
jge    1531 <main+0x361>
mov    -0x30(%rbp),%rdi
call   1040 <remove@plt>
jmp    1538 <main+0x368>
movl   $0x0,-0x50(%rbp)
jmp    153d <main+0x36d>
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,%r14
mov    $0xffffffff,%r13d
cmp    $0x3,%edi
je     1229 <main+0x59>
cmp    $0x2,%edi
jne    13ee <main+0x21e>
mov    0x8(%r14),%rdi
lea    0xe00(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
jne    13ee <main+0x21e>
lea    0xdf4(%rip),%rdi
lea    0xdf0(%rip),%rsi
call   1080 <printf@plt>
xor    %r13d,%r13d
jmp    13ee <main+0x21e>
mov    0x8(%r14),%rbp
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1070 <strchr@plt>
mov    %rax,%r15
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
test   %r15,%r15
je     13ee <main+0x21e>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     13ee <main+0x21e>
mov    0x10(%r14),%rbx
lea    0xded(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     13ee <main+0x21e>
mov    %rax,%r12
mov    %rbx,0x8(%rsp)
mov    %r15,%rbx
mov    0x8(%r14),%rbp
lea    0xdc8(%rip),%r13
mov    0x10(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x3b,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1384 <main+0x1b4>
mov    %rax,%rbp
cmp    %r15,%rax
jae    1384 <main+0x1b4>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    $0x7,%edx
call   1050 <strncmp@plt>
add    $0x1,%rbp
test   %eax,%eax
jne    12a0 <main+0xd0>
add    $0x1,%r15
movb   $0x0,0x7(%rsp)
cmpb   $0x0,0x1(%rbx)
je     13a5 <main+0x1d5>
mov    $0x4,%ebp
lea    0x4(%rsp),%r13
mov    0x8(%rsp),%rbx
nopl   0x0(%rax)
lea    0x3(%r15),%rax
cmp    %r14,%rax
jae    13bc <main+0x1ec>
cmp    $0x4,%ebp
jl     13bc <main+0x1ec>
mov    %r15,%rdi
mov    %r13,%rsi
call   10b0 <decode_block@plt>
mov    %eax,%ebp
mov    %r13,%rdi
mov    %r12,%rsi
call   10a0 <fputs@plt>
movslq %ebp,%rcx
lea    (%r15,%rcx,1),%rax
cmpb   $0x0,(%r15,%rcx,1)
mov    %rax,%r15
jne    1300 <main+0x130>
jmp    13bf <main+0x1ef>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x2(%rbx),%rsi
lea    0x2(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10e0 <strtol@plt>
movsbl %al,%edi
mov    %r12,%rsi
call   10c0 <fputc@plt>
add    $0x3,%rbx
movzbl 0x1(%rbx),%eax
cmp    $0x25,%al
je     1350 <main+0x180>
test   %al,%al
je     13af <main+0x1df>
cmp    $0x2f,%al
je     13af <main+0x1df>
add    $0x1,%rbx
movsbl %al,%edi
mov    %r12,%rsi
call   10c0 <fputc@plt>
jmp    1384 <main+0x1b4>
cmp    %r14,%r15
mov    0x8(%rsp),%rbx
jb     13c4 <main+0x1f4>
mov    %r12,%rdi
call   1060 <fclose@plt>
xor    %r13d,%r13d
jmp    13ee <main+0x21e>
mov    %r15,%rax
cmp    %r14,%rax
jae    13d3 <main+0x203>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    $0xffffffff,%ebp
jmp    13e3 <main+0x213>
mov    %r12,%rdi
call   1060 <fclose@plt>
xor    %r13d,%r13d
cmp    $0x3,%ebp
jg     13ee <main+0x21e>
mov    %rbx,%rdi
call   1040 <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 [2 x i8]
%13 = alloca i32*
%14 = alloca i32
%15 = 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** %13
store i32 0, i32* %14
store i32 -1, i32* %15
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = 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 %174
26: ; preds = %18, %2
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 3
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 -1, i32* %3
br label %174
30: ; preds = %26
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i8* @strchr(i8* %33, i8 signext 44)
store i8* %34, i8** %8
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i8* @strrchr(i8* %37, i8 signext 47)
store i8* %38, i8** %10
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
store i8* %41, i8** %9
%42 = load i8*, i8** %8
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %172
44: ; preds = %30
%45 = load i8*, i8** %10
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %172
47: ; preds = %44
%48 = load i8*, i8** %9
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %49, i32** %13
%50 = icmp ne i32* %49, null
br i1 %50, label %51, label %172
51: ; preds = %47
store i32 4, i32* %15
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
store i8* %54, i8** %6
store i8* null, i8** %7
br label %55
55: ; preds = %74, %51
%56 = load i8*, i8** %6
%57 = call i8* @strchr(i8* %56, i8 signext 59)
store i8* %57, i8** %7
%58 = load i8*, i8** %7
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %72
60: ; preds = %55
%61 = load i8*, i8** %7
%62 = load i8*, i8** %8
%63 = icmp ult i8* %61, %62
br i1 %63, label %64, label %72
64: ; preds = %60
%65 = load i8*, i8** %7
%66 = call i32 @strncmp(i8* %65, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 7)
%67 = icmp ne i32 %66, 0
%68 = xor i1 %67, true
%69 = zext i1 %68 to i32
store i32 %69, i32* %14
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i64 1
store i8* %71, i8** %6
br label %73
72: ; preds = %60, %55
br label %78
73: ; preds = %64
br label %74
74: ; preds = %73
%75 = load i32, i32* %14
%76 = icmp ne i32 %75, 0
%77 = xor i1 %76, true
br i1 %77, label %55, label %78
78: ; preds = %74, %72
%79 = load i8*, i8** %8
%80 = getelementptr inbounds i8, i8* %79, i64 1
store i8* %80, i8** %6
%81 = load i32, i32* %14
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %120
83: ; preds = %78
%84 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 3
store i8 0, i8* %84
br label %85
85: ; preds = %103, %83
%86 = load i8*, i8** %6
%87 = icmp ne i8* %86, null
br i1 %87, label %88, label %101
88: ; preds = %85
%89 = load i8*, i8** %6
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %101
93: ; preds = %88
%94 = load i8*, i8** %6
%95 = getelementptr inbounds i8, i8* %94, i64 3
%96 = load i8*, i8** %10
%97 = icmp ult i8* %95, %96
br i1 %97, label %98, label %101
98: ; preds = %93
%99 = load i32, i32* %15
%100 = icmp sge i32 %99, 4
br label %101
101: ; preds = %98, %93, %88, %85
%102 = phi i1 [ false, %93 ], [ false, %88 ], [ false, %85 ], [ %100, %98 ]
br i1 %102, label %103, label %114
103: ; preds = %101
%104 = load i8*, i8** %6
%105 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%106 = call i32 @decode_block(i8* %104, i8* %105)
store i32 %106, i32* %15
%107 = getelementptr inbounds [4 x i8], [4 x i8]* %11, i64 0, i64 0
%108 = load i32*, i32** %13
%109 = call i32 @fputs(i8* %107, i32* %108)
%110 = load i32, i32* %15
%111 = load i8*, i8** %6
%112 = sext i32 %110 to i64
%113 = getelementptr inbounds i8, i8* %111, i64 %112
store i8* %113, i8** %6
br label %85
114: ; preds = %101
%115 = load i8*, i8** %6
%116 = load i8*, i8** %10
%117 = icmp ult i8* %115, %116
br i1 %117, label %118, label %119
118: ; preds = %114
store i32 -1, i32* %15
br label %119
119: ; preds = %118, %114
br label %162
120: ; preds = %78
br label %121
121: ; preds = %158, %120
%122 = load i8*, i8** %6
%123 = icmp ne i8* %122, null
br i1 %123, label %124, label %134
124: ; preds = %121
%125 = load i8*, i8** %6
%126 = load i8, i8* %125
%127 = sext i8 %126 to i32
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %124
%130 = load i8*, i8** %6
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = icmp ne i32 %132, 47
br label %134
134: ; preds = %129, %124, %121
%135 = phi i1 [ false, %124 ], [ false, %121 ], [ %133, %129 ]
br i1 %135, label %136, label %161
136: ; preds = %134
%137 = load i8*, i8** %6
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp eq i32 %139, 37
br i1 %140, label %141, label %153
141: ; preds = %136
%142 = load i8*, i8** %6
%143 = getelementptr inbounds i8, i8* %142, i32 1
store i8* %143, i8** %6
%144 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%145 = load i8*, i8** %6
%146 = call i32 @strncpy(i8* %144, i8* %145, i32 2)
%147 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%148 = call signext i8 @strtol(i8* %147, i32* null, i32 16)
%149 = load i32*, i32** %13
%150 = call i32 @fputc(i8 signext %148, i32* %149)
%151 = load i8*, i8** %6
%152 = getelementptr inbounds i8, i8* %151, i32 1
store i8* %152, i8** %6
br label %158
153: ; preds = %136
%154 = load i8*, i8** %6
%155 = load i8, i8* %154
%156 = load i32*, i32** %13
%157 = call i32 @fputc(i8 signext %155, i32* %156)
br label %158
158: ; preds = %153, %141
%159 = load i8*, i8** %6
%160 = getelementptr inbounds i8, i8* %159, i32 1
store i8* %160, i8** %6
br label %121
161: ; preds = %134
br label %162
162: ; preds = %161, %119
%163 = load i32*, i32** %13
%164 = call i32 @fclose(i32* %163)
%165 = load i32, i32* %15
%166 = icmp slt i32 %165, 4
br i1 %166, label %167, label %170
167: ; preds = %162
%168 = load i8*, i8** %9
%169 = call i32 @remove(i8* %168)
br label %171
170: ; preds = %162
store i32 0, i32* %15
br label %171
171: ; preds = %170, %167
br label %172
172: ; preds = %171, %47, %44, %30
%173 = load i32, i32* %15
store i32 %173, i32* %3
br label %174
174: ; preds = %172, %29, %24
%175 = load i32, i32* %3
ret i32 %175
}

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