#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 O_CREAT;
int O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ RLEcompress(int, int);
int RLEdecompress(int, int);
int /*<<< orphan*/ exit(int);
int open(char const *, int, int);
int /*<<< orphan*/ printf(char *, char const *);
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ unlink(char const *);
int main(int argc, char const *argv[]) {
  if (argc != 4) {
    printf("usage\n%s [option] fileIn fileOut\n\nOption "
           ":\n-c:\tcompresse\n-d:\tdecompresse",
           argv[0]);
    exit(0);
  }
  if (!(strcmp("-c", argv[1]) != 0 || strcmp("-d", argv[1]) != 0)) {
    printf("usage\n%s [option] fileIn fileOut\n\nOption "
           ":\n-c:\tcompresse\n-d:\tdecompresse\n",
           argv[0]);
    exit(-1);
  }
  int in = open(argv[2], O_RDONLY, 0640);
  int out = open(argv[3], O_WRONLY | O_CREAT | O_TRUNC, 0640);
  if (in == -1) {
    printf("Error %s", argv[2]);
    exit(-1);
  }
  if (out == -1) {
    printf("Error %s", argv[3]);
    exit(-1);
  }
  int retour = 0;
  if (strcmp("-c", argv[1]) == 0) {
    RLEcompress(in, out);
  } else {
    retour = RLEdecompress(in, out);
  }
  if (retour) {
    unlink(argv[3]);
    printf(
        "Erreur lors de la décompréssion de %s\nle fichier va être supprimé\n",
        argv[3]);
    exit(-1);
  }
}


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)
cmpl   $0x4,-0x8(%rbp)
je     11aa <main+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe90(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe75(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <main+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
mov    $0x1a0,%edx
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
mov    0x2dbf(%rip),%rax
or     (%rax),%esi
mov    0x2dae(%rip),%rax
or     (%rax),%esi
mov    $0x1a0,%edx
call   1080 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1279 <main+0x109>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
cmpl   $0xffffffff,-0x18(%rbp)
jne    12a1 <main+0x131>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd92(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12d6 <main+0x166>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <RLEcompress@plt>
jmp    12e4 <main+0x174>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <RLEdecompress@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1319 <main+0x1a9>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <unlink@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd98(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x4,%edi
jne    1240 <main+0xd0>
mov    0x8(%r14),%rsi
lea    0xebe(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11ae <main+0x3e>
mov    0x8(%r14),%rsi
lea    0xeac(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1276 <main+0x106>
mov    0x10(%r14),%rdi
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
mov    $0x1a0,%edx
call   1080 <open@plt>
mov    %eax,%ebp
mov    0x2df2(%rip),%rax
mov    0x2e23(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x18(%r14),%rdi
mov    0x2e0c(%rip),%rax
or     (%rax),%esi
mov    $0x1a0,%edx
call   1080 <open@plt>
cmp    $0xffffffff,%ebp
je     1256 <main+0xe6>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     125c <main+0xec>
mov    0x8(%r14),%rsi
lea    0xe42(%rip),%rdi
call   1060 <strcmp@plt>
mov    %ebp,%edi
mov    %ebx,%esi
test   %rax,%rax
je     1234 <main+0xc4>
call   1070 <RLEdecompress@plt>
test   %eax,%eax
je     1239 <main+0xc9>
mov    0x18(%r14),%rdi
call   1030 <unlink@plt>
mov    0x18(%r14),%rsi
lea    0xe70(%rip),%rdi
jmp    1267 <main+0xf7>
call   1040 <RLEcompress@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%r14),%rsi
lea    0xdb6(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x10(%r14),%rsi
jmp    1260 <main+0xf0>
mov    0x18(%r14),%rsi
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    (%r14),%rsi
lea    0xdcf(%rip),%rdi
jmp    1267 <main+0xf7>

LLVM IR (-O0):
@.str = [73 x i8] c"usage\0A%s [option] fileIn fileOut\0A\0AOption :\0A-c:\09compresse\0A-d:\09decompresse\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [3 x i8] c"-d\00"
@.str.3 = [74 x i8] c"usage\0A%s [option] fileIn fileOut\0A\0AOption :\0A-c:\09compresse\0A-d:\09decompresse\0A\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [9 x i8] c"Error %s\00"
@.str.5 = [71 x i8] c"Erreur lors de la d\C3\A9compr\C3\A9ssion de %s\0Ale fichier va \C3\AAtre supprim\C3\A9\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %35, label %23
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %23, %17
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = load i32, i32* @O_RDONLY
%40 = call i32 @open(i8* %38, i32 %39, i32 416)
store i32 %40, i32* %6
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 3
%43 = load i8*, i8** %42
%44 = load i32, i32* @O_WRONLY
%45 = load i32, i32* @O_CREAT
%46 = or i32 %44, %45
%47 = load i32, i32* @O_TRUNC
%48 = or i32 %46, %47
%49 = call i32 @open(i8* %43, i32 %48, i32 416)
store i32 %49, i32* %7
%50 = load i32, i32* %6
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %58
52: ; preds = %35
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 -1)
unreachable
58: ; preds = %35
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %67
61: ; preds = %58
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 3
%64 = load i8*, i8** %63
%65 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 -1)
unreachable
67: ; preds = %58
store i32 0, i32* %8
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 1
%70 = load i8*, i8** %69
%71 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %67
%74 = load i32, i32* %6
%75 = load i32, i32* %7
%76 = call i32 @RLEcompress(i32 %74, i32 %75)
br label %81
77: ; preds = %67
%78 = load i32, i32* %6
%79 = load i32, i32* %7
%80 = call i32 @RLEdecompress(i32 %78, i32 %79)
store i32 %80, i32* %8
br label %81
81: ; preds = %77, %73
%82 = load i32, i32* %8
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %94
84: ; preds = %81
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 3
%87 = load i8*, i8** %86
%88 = call i32 @unlink(i8* %87)
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 3
%91 = load i8*, i8** %90
%92 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i8* %91)
%93 = call i32 @exit(i32 -1)
unreachable
94: ; preds = %81
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
@.str = [73 x i8] c"usage\0A%s [option] fileIn fileOut\0A\0AOption :\0A-c:\09compresse\0A-d:\09decompresse\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [3 x i8] c"-d\00"
@.str.3 = [74 x i8] c"usage\0A%s [option] fileIn fileOut\0A\0AOption :\0A-c:\09compresse\0A-d:\09decompresse\0A\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [9 x i8] c"Error %s\00"
@.str.5 = [71 x i8] c"Erreur lors de la d\C3\A9compr\C3\A9ssion de %s\0Ale fichier va \C3\AAtre supprim\C3\A9\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %1
%19 = tail call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %13, %8
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDONLY
%25 = tail call i32 @open(i8* %23, i32 %24, i32 416)
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = load i8*, i8** %26
%28 = load i32, i32* @O_WRONLY
%29 = load i32, i32* @O_CREAT
%30 = or i32 %29, %28
%31 = load i32, i32* @O_TRUNC
%32 = or i32 %30, %31
%33 = tail call i32 @open(i8* %27, i32 %32, i32 416)
%34 = icmp eq i32 %25, -1
br i1 %34, label %35, label %39
35: ; preds = %21
%36 = load i8*, i8** %22
%37 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %36)
%38 = tail call i32 @exit(i32 -1)
unreachable
39: ; preds = %21
%40 = icmp eq i32 %33, -1
br i1 %40, label %41, label %45
41: ; preds = %39
%42 = load i8*, i8** %26
%43 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = tail call i32 @exit(i32 -1)
unreachable
45: ; preds = %39
%46 = load i8*, i8** %9
%47 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = tail call i32 @RLEcompress(i32 %25, i32 %33)
br label %60
51: ; preds = %45
%52 = tail call i32 @RLEdecompress(i32 %25, i32 %33)
%53 = icmp eq i32 %52, 0
br i1 %53, label %60, label %54
54: ; preds = %51
%55 = load i8*, i8** %26
%56 = tail call i32 @unlink(i8* %55)
%57 = load i8*, i8** %26
%58 = tail call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.5, i64 0, i64 0), i8* %57)
%59 = tail call i32 @exit(i32 -1)
unreachable
60: ; preds = %49, %51
ret i32 0
}