#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 /*<<< orphan*/ _IONBF;
size_t compress(char *, int, char *, size_t);
size_t decompress(char *, int, char *, size_t);
size_t dehex(char *);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printhex(char *, size_t);
int scanf(char *, ...);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
int main() {
  setvbuf(stdin, NULL, _IONBF, 0);
  setvbuf(stdout, NULL, _IONBF, 0);
  setvbuf(stderr, NULL, _IONBF, 0);
  struct {
    char command[256];
    char password[256];
    char expected_password[256];
    char src[8192];
    char dst[4096];
  } x;
  char *src = x.src;
  char *dst = x.dst;
  char *command = x.command;
  char *password = x.password;
  char *expected_password = x.expected_password;
  strcpy(command, "cat FORMAT.md");
  printf("What can I do for you?\n");
  printf("1. Compress string\n");
  printf("2. Decompress string\n");
  printf("3. Read compression format documentation\n");
  printf("\n");
  int choice = 0;
  if (scanf("%d", &choice) != 1) {
    error("invalid choice");
  }
  if (choice == 1) {
    printf("Send me the hex-encoded string (max 4k):\n");
    scanf("%8000s", src);
    size_t src_sz = dehex(src);
    size_t sz = compress(dst, 4000, src, src_sz);
    printf("These %zu bytes compress to %zu bytes (%.2lf%%):\n", src_sz, sz,
           100.0 * sz / src_sz);
    printhex(dst, sz);
  } else if (choice == 2) {
    printf("Send me the hex-encoded string (max 4k):\n");
    scanf("%8000s", src);
    size_t src_sz = dehex(src);
    size_t sz = decompress(dst, 4000, src, src_sz);
    printf("That decompresses to:\n");
    printhex(dst, sz);
  } else if (choice == 3) {
    printf("Format documentation is password protected.\n");
    printf("Input password:\n");
    scanf("%100s", password);
    FILE *f = fopen("FORMAT.md.password", "r");
    fscanf(f, "%s", expected_password);
    if (0 != strcmp(password, expected_password)) {
      error("wrong password");
    } else {
      system(command);
    }
  } else {
    error("invalid choice");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3370,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10a0 <setvbuf@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10a0 <setvbuf@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    0x2db4(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10a0 <setvbuf@plt>
lea    -0x3308(%rbp),%rax
add    $0x300,%rax
mov    %rax,-0x3310(%rbp)
lea    -0x3308(%rbp),%rax
add    $0x2300,%rax
mov    %rax,-0x3318(%rbp)
lea    -0x3308(%rbp),%rax
mov    %rax,-0x3320(%rbp)
lea    -0x3308(%rbp),%rax
add    $0x100,%rax
mov    %rax,-0x3328(%rbp)
lea    -0x3308(%rbp),%rax
add    $0x200,%rax
mov    %rax,-0x3330(%rbp)
mov    -0x3320(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x3334(%rbp)
lea    0xda1(%rip),%rdi
lea    -0x3334(%rbp),%rsi
mov    $0x0,%al
call   10b0 <scanf@plt>
cmp    $0x1,%eax
je     1324 <main+0x154>
lea    0xd86(%rip),%rdi
call   10c0 <error@plt>
cmpl   $0x1,-0x3334(%rbp)
jne    141a <main+0x24a>
lea    0xd7c(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x3361(%rbp)
call   1060 <printf@plt>
mov    -0x3361(%rbp),%al
mov    -0x3310(%rbp),%rsi
lea    0xd85(%rip),%rdi
call   10b0 <scanf@plt>
mov    -0x3310(%rbp),%rdi
call   10e0 <dehex@plt>
mov    %rax,-0x3340(%rbp)
mov    -0x3318(%rbp),%rdi
mov    -0x3310(%rbp),%rdx
mov    -0x3340(%rbp),%rcx
mov    $0xfa0,%esi
call   1030 <compress@plt>
mov    %rax,-0x3348(%rbp)
mov    -0x3340(%rbp),%rsi
mov    -0x3348(%rbp),%rdx
movq   %rdx,%xmm0
movaps 0xc4f(%rip),%xmm3
punpckldq %xmm3,%xmm0
movapd 0xc53(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xc4c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movq   %rsi,%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xcea(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x3318(%rbp),%rdi
mov    -0x3348(%rbp),%rsi
call   1090 <printhex@plt>
jmp    1574 <main+0x3a4>
cmpl   $0x2,-0x3334(%rbp)
jne    14a9 <main+0x2d9>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3310(%rbp),%rsi
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   10b0 <scanf@plt>
mov    -0x3310(%rbp),%rdi
call   10e0 <dehex@plt>
mov    %rax,-0x3350(%rbp)
mov    -0x3318(%rbp),%rdi
mov    -0x3310(%rbp),%rdx
mov    -0x3350(%rbp),%rcx
mov    $0xfa0,%esi
call   10f0 <decompress@plt>
mov    %rax,-0x3358(%rbp)
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3318(%rbp),%rdi
mov    -0x3358(%rbp),%rsi
call   1090 <printhex@plt>
jmp    156f <main+0x39f>
cmpl   $0x3,-0x3334(%rbp)
jne    155e <main+0x38e>
lea    0xc71(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3328(%rbp),%rsi
lea    0xc8c(%rip),%rdi
mov    $0x0,%al
call   10b0 <scanf@plt>
lea    0xc84(%rip),%rdi
lea    0xc90(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x3360(%rbp)
mov    -0x3360(%rbp),%rdi
mov    -0x3330(%rbp),%rdx
lea    0xc71(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x3328(%rbp),%rdi
mov    -0x3330(%rbp),%rsi
call   1080 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     154d <main+0x37d>
lea    0xc47(%rip),%rdi
call   10c0 <error@plt>
jmp    1559 <main+0x389>
mov    -0x3320(%rbp),%rdi
call   1050 <system@plt>
jmp    156a <main+0x39a>
lea    0xb40(%rip),%rdi
call   10c0 <error@plt>
jmp    156f <main+0x39f>
jmp    1574 <main+0x3a4>
mov    -0x4(%rbp),%eax
add    $0x3370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3308,%rsp
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    0x2dd2(%rip),%rbx
mov    (%rbx),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   10c0 <setvbuf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   10c0 <setvbuf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   10c0 <setvbuf@plt>
lea    0xde0(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <strcpy@plt>
lea    0xe55(%rip),%rdi
call   1060 <puts@plt>
lea    0xe60(%rip),%rdi
call   1060 <puts@plt>
lea    0xe67(%rip),%rdi
call   1060 <puts@plt>
lea    0xe70(%rip),%rdi
call   1060 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,0x4(%rsp)
lea    0xd9b(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
cmp    $0x1,%eax
je     12b8 <main+0xc8>
lea    0xd86(%rip),%rdi
call   10e0 <error@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
je     138c <main+0x19c>
lea    0x308(%rsp),%r15
lea    0x2308(%rsp),%r14
cmp    $0x2,%eax
je     1403 <main+0x213>
cmp    $0x1,%eax
jne    1457 <main+0x267>
lea    0xe7a(%rip),%rdi
call   1060 <puts@plt>
lea    0xd4e(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    %r15,%rdi
call   1100 <dehex@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    $0xfa0,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1040 <compress@plt>
mov    %rax,%rbx
movq   %rax,%xmm1
movdqa 0xcce(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xcd2(%rip),%xmm3
subpd  %xmm3,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xcca(%rip),%xmm0
movq   %r12,%xmm1
punpckldq %xmm2,%xmm1
subpd  %xmm3,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
lea    0xcd5(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
mov    $0x1,%al
call   1080 <printf@plt>
jmp    144a <main+0x25a>
lea    0x108(%rsp),%rbx
lea    0x208(%rsp),%r14
lea    0xd73(%rip),%rdi
call   1060 <puts@plt>
lea    0xd93(%rip),%rdi
call   1060 <puts@plt>
lea    0xcc6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
lea    0xcbb(%rip),%rdi
lea    0xcc7(%rip),%rsi
call   10f0 <fopen@plt>
lea    0xcbd(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1090 <fscanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1465 <main+0x275>
lea    0xc9e(%rip),%rdi
jmp    145e <main+0x26e>
lea    0xd5e(%rip),%rdi
call   1060 <puts@plt>
lea    0xc32(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    %r15,%rdi
call   1100 <dehex@plt>
mov    %r14,%rdi
mov    $0xfa0,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1110 <decompress@plt>
mov    %rax,%rbx
lea    0xd0d(%rip),%rdi
call   1060 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <printhex@plt>
jmp    146f <main+0x27f>
lea    0xbdb(%rip),%rdi
call   10e0 <error@plt>
jmp    146f <main+0x27f>
lea    0x8(%rsp),%rdi
call   1070 <system@plt>
xor    %eax,%eax
add    $0x3308,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.anon = type { [256 x i8], [256 x i8], [256 x i8], [8192 x i8], [4096 x i8] }
@stdin = global i32 0
@_IONBF = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [14 x i8] c"cat FORMAT.md\00"
@.str.1 = [24 x i8] c"What can I do for you?\0A\00"
@.str.2 = [20 x i8] c"1. Compress string\0A\00"
@.str.3 = [22 x i8] c"2. Decompress string\0A\00"
@.str.4 = [42 x i8] c"3. Read compression format documentation\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [15 x i8] c"invalid choice\00"
@.str.8 = [42 x i8] c"Send me the hex-encoded string (max 4k):\0A\00"
@.str.9 = [7 x i8] c"%8000s\00"
@.str.10 = [50 x i8] c"These %zu bytes compress to %zu bytes (%.2lf%%):\0A\00"
@.str.11 = [23 x i8] c"That decompresses to:\0A\00"
@.str.12 = [45 x i8] c"Format documentation is password protected.\0A\00"
@.str.13 = [17 x i8] c"Input password:\0A\00"
@.str.14 = [6 x i8] c"%100s\00"
@.str.15 = [19 x i8] c"FORMAT.md.password\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [3 x i8] c"%s\00"
@.str.18 = [15 x i8] c"wrong password\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.anon
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32*
store i32 0, i32* %1
%14 = load i32, i32* @stdin
%15 = load i32, i32* @_IONBF
%16 = call i32 @setvbuf(i32 %14, i32* null, i32 %15, i32 0)
%17 = load i32, i32* @stdout
%18 = load i32, i32* @_IONBF
%19 = call i32 @setvbuf(i32 %17, i32* null, i32 %18, i32 0)
%20 = load i32, i32* @stderr
%21 = load i32, i32* @_IONBF
%22 = call i32 @setvbuf(i32 %20, i32* null, i32 %21, i32 0)
%23 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 3
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %23, i64 0, i64 0
store i8* %24, i8** %3
%25 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 4
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
store i8* %26, i8** %4
%27 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 0
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %27, i64 0, i64 0
store i8* %28, i8** %5
%29 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 1
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %29, i64 0, i64 0
store i8* %30, i8** %6
%31 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 2
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %31, i64 0, i64 0
store i8* %32, i8** %7
%33 = load i8*, i8** %5
%34 = call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %8
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %8)
%41 = icmp ne i32 %40, 1
br i1 %41, label %42, label %44
42: ; preds = %0
%43 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %44
44: ; preds = %42, %0
%45 = load i32, i32* %8
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %69
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
%49 = load i8*, i8** %3
%50 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %49)
%51 = load i8*, i8** %3
%52 = call i64 @dehex(i8* %51)
store i64 %52, i64* %9
%53 = load i8*, i8** %4
%54 = load i8*, i8** %3
%55 = load i64, i64* %9
%56 = call i64 @compress(i8* %53, i32 4000, i8* %54, i64 %55)
store i64 %56, i64* %10
%57 = load i64, i64* %9
%58 = load i64, i64* %10
%59 = load i64, i64* %10
%60 = uitofp i64 %59 to double
%61 = fmul double 1.000000e+02, %60
%62 = load i64, i64* %9
%63 = uitofp i64 %62 to double
%64 = fdiv double %61, %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0), i64 %57, i64 %58, double %64)
%66 = load i8*, i8** %4
%67 = load i64, i64* %10
%68 = call i32 @printhex(i8* %66, i64 %67)
br label %112
69: ; preds = %44
%70 = load i32, i32* %8
%71 = icmp eq i32 %70, 2
br i1 %71, label %72, label %86
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
%74 = load i8*, i8** %3
%75 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %74)
%76 = load i8*, i8** %3
%77 = call i64 @dehex(i8* %76)
store i64 %77, i64* %11
%78 = load i8*, i8** %4
%79 = load i8*, i8** %3
%80 = load i64, i64* %11
%81 = call i64 @decompress(i8* %78, i32 4000, i8* %79, i64 %80)
store i64 %81, i64* %12
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0))
%83 = load i8*, i8** %4
%84 = load i64, i64* %12
%85 = call i32 @printhex(i8* %83, i64 %84)
br label %111
86: ; preds = %69
%87 = load i32, i32* %8
%88 = icmp eq i32 %87, 3
br i1 %88, label %89, label %108
89: ; preds = %86
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0))
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%92 = load i8*, i8** %6
%93 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* %92)
%94 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
store i32* %94, i32** %13
%95 = load i32*, i32** %13
%96 = load i8*, i8** %7
%97 = call i32 @fscanf(i32* %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* %96)
%98 = load i8*, i8** %6
%99 = load i8*, i8** %7
%100 = call i64 @strcmp(i8* %98, i8* %99)
%101 = icmp ne i64 0, %100
br i1 %101, label %102, label %104
102: ; preds = %89
%103 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0))
br label %107
104: ; preds = %89
%105 = load i8*, i8** %5
%106 = call i32 @system(i8* %105)
br label %107
107: ; preds = %104, %102
br label %110
108: ; preds = %86
%109 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %110
110: ; preds = %108, %107
br label %111
111: ; preds = %110, %72
br label %112
112: ; preds = %111, %47
%113 = load i32, i32* %1
ret i32 %113
}

LLVM IR (-O2):
%struct.anon = type { [256 x i8], [256 x i8], [256 x i8], [8192 x i8], [4096 x i8] }
@stdin = global i32 0
@_IONBF = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [14 x i8] c"cat FORMAT.md\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [15 x i8] c"invalid choice\00"
@.str.9 = [7 x i8] c"%8000s\00"
@.str.10 = [50 x i8] c"These %zu bytes compress to %zu bytes (%.2lf%%):\0A\00"
@.str.14 = [6 x i8] c"%100s\00"
@.str.15 = [19 x i8] c"FORMAT.md.password\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [3 x i8] c"%s\00"
@.str.18 = [15 x i8] c"wrong password\00"
@str = [23 x i8] c"What can I do for you?\00"
@str.19 = [19 x i8] c"1. Compress string\00"
@str.20 = [21 x i8] c"2. Decompress string\00"
@str.21 = [41 x i8] c"3. Read compression format documentation\00"
@str.22 = [44 x i8] c"Format documentation is password protected.\00"
@str.23 = [16 x i8] c"Input password:\00"
@str.25 = [22 x i8] c"That decompresses to:\00"
@str.26 = [41 x i8] c"Send me the hex-encoded string (max 4k):\00"
define i32 @main() {
%1 = alloca %struct.anon
%2 = alloca i32
%3 = load i32, i32* @stdin
%4 = load i32, i32* @_IONBF
%5 = tail call i32 @setvbuf(i32 %3, i32* null, i32 %4, i32 0)
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = tail call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 0)
%9 = load i32, i32* @stderr
%10 = load i32, i32* @_IONBF
%11 = tail call i32 @setvbuf(i32 %9, i32* null, i32 %10, i32 0)
%12 = getelementptr inbounds %struct.anon, %struct.anon* %1, i64 0, i32 0, i64 0
%13 = getelementptr inbounds %struct.anon, %struct.anon* %1, i64 0, i32 3, i64 0
%14 = getelementptr inbounds %struct.anon, %struct.anon* %1, i64 0, i32 4, i64 0
%15 = getelementptr inbounds %struct.anon, %struct.anon* %1, i64 0, i32 1, i64 0
%16 = getelementptr inbounds %struct.anon, %struct.anon* %1, i64 0, i32 2, i64 0
%17 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.19, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.20, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.21, i64 0, i64 0))
%22 = call i32 @putchar(i32 10)
%23 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%25 = icmp eq i32 %24, 1
br i1 %25, label %28, label %26
26: ; preds = %0
%27 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %0
%29 = load i32, i32* %2
switch i32 %29, label %60 [
i32 1, label %30
i32 2, label %41
i32 3, label %48
]
30: ; preds = %28
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.26, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %13)
%33 = call i64 @dehex(i8* %13)
%34 = call i64 @compress(i8* %14, i32 4000, i8* %13, i64 %33)
%35 = uitofp i64 %34 to double
%36 = fmul double %35, 1.000000e+02
%37 = uitofp i64 %33 to double
%38 = fdiv double %36, %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0), i64 %33, i64 %34, double %38)
%40 = call i32 @printhex(i8* %14, i64 %34)
br label %62
41: ; preds = %28
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.26, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %13)
%44 = call i64 @dehex(i8* %13)
%45 = call i64 @decompress(i8* %14, i32 4000, i8* %13, i64 %44)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.25, i64 0, i64 0))
%47 = call i32 @printhex(i8* %14, i64 %45)
br label %62
48: ; preds = %28
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.22, i64 0, i64 0))
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.23, i64 0, i64 0))
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8* %15)
%52 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%53 = call i32 @fscanf(i32* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i8* %16)
%54 = call i64 @strcmp(i8* %15, i8* %16)
%55 = icmp eq i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %48
%57 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0))
br label %62
58: ; preds = %48
%59 = call i32 @system(i8* %12)
br label %62
60: ; preds = %28
%61 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %62
62: ; preds = %56, %58, %41, %60, %30
ret i32 0
}