#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*/ comprimir(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ descomprimir(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *forigen = NULL, *fdestino = NULL;
  if (argc != 4) {
    printf("Sintaxis: comp {-c|-d} forigen fdestino\n");
    exit(1);
  }
  if ((forigen = fopen(argv[2], "r")) == NULL) {
    printf("El fichero %s no puede abrirse\n", argv[2]);
    exit(1);
  }
  if ((fdestino = fopen(argv[3], "w")) == NULL) {
    printf("El fichero %s no puede abrirse\n", argv[3]);
    exit(1);
  }
  if (argv[1][0] == '-' && argv[1][1] == 'c')
    comprimir(forigen, fdestino);
  else if (argv[1][0] == '-' && argv[1][1] == 'd')
    descomprimir(forigen, fdestino);
  else
    printf("Opción incorrecta\n");
  fclose(forigen);
  fclose(fdestino);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11a8 <main+0x48>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe72(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ea <main+0x8a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe52(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    122c <main+0xcc>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1267 <main+0x107>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x63,%eax
jne    1267 <main+0x107>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <comprimir@plt>
jmp    12b5 <main+0x155>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12a2 <main+0x142>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    12a2 <main+0x142>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <descomprimir@plt>
jmp    12b0 <main+0x150>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12b5 <main+0x155>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x4,%edi
jne    1207 <main+0x97>
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
lea    0xe74(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     121d <main+0xad>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1223 <main+0xb3>
mov    %rax,%r15
mov    0x8(%rbx),%rax
cmpb   $0x2d,(%rax)
jne    11d6 <main+0x66>
mov    0x1(%rax),%al
cmp    $0x64,%al
je     11e4 <main+0x74>
cmp    $0x63,%al
jne    11d6 <main+0x66>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <comprimir@plt>
jmp    11ef <main+0x7f>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
jmp    11ef <main+0x7f>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <descomprimir@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe29(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x10(%rbx),%rsi
jmp    1227 <main+0xb7>
mov    0x18(%rbx),%rsi
lea    0xdd4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"Sintaxis: comp {-c|-d} forigen fdestino\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [32 x i8] c"El fichero %s no puede abrirse\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [20 x i8] c"Opci\C3\B3n incorrecta\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %13
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %29, i32** %7
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %25
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 45
br i1 %44, label %45, label %57
45: ; preds = %37
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 99
br i1 %52, label %53, label %57
53: ; preds = %45
%54 = load i32*, i32** %6
%55 = load i32*, i32** %7
%56 = call i32 @comprimir(i32* %54, i32* %55)
br label %80
57: ; preds = %45, %37
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = getelementptr inbounds i8, i8* %60, i64 0
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 45
br i1 %64, label %65, label %77
65: ; preds = %57
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = getelementptr inbounds i8, i8* %68, i64 1
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 100
br i1 %72, label %73, label %77
73: ; preds = %65
%74 = load i32*, i32** %6
%75 = load i32*, i32** %7
%76 = call i32 @descomprimir(i32* %74, i32* %75)
br label %79
77: ; preds = %65, %57
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
br label %80
80: ; preds = %79, %53
%81 = load i32*, i32** %6
%82 = call i32 @fclose(i32* %81)
%83 = load i32*, i32** %7
%84 = call i32 @fclose(i32* %83)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [32 x i8] c"El fichero %s no puede abrirse\0A\00"
@.str.3 = [2 x i8] c"w\00"
@str = [19 x i8] c"Opci\C3\B3n incorrecta\00"
@str.5 = [40 x i8] c"Sintaxis: comp {-c|-d} forigen fdestino\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.5, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i8*, i8** %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %7
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i8*, i8** %17
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %16
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 45
br i1 %29, label %30, label %37
30: ; preds = %25
%31 = getelementptr inbounds i8, i8* %27, i64 1
%32 = load i8, i8* %31
switch i8 %32, label %37 [
i8 99, label %33
i8 100, label %35
]
33: ; preds = %30
%34 = tail call i32 @comprimir(i32* %10, i32* %19)
br label %39
35: ; preds = %30
%36 = tail call i32 @descomprimir(i32* %10, i32* %19)
br label %39
37: ; preds = %30, %25
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %39
39: ; preds = %35, %37, %33
%40 = tail call i32 @fclose(i32* %10)
%41 = tail call i32 @fclose(i32* %19)
ret i32 0
}