#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 codeCarac(int /*<<< orphan*/ *, int /*<<< orphan*/, char **);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *save();
scalar_t__ tableauHuffman(char **);
int codage(char *fichier) {
  FILE *fichierLu = fopen(fichier, "r");
  FILE *fichierCode = NULL;
  char code[256][14];
  int noError = 1, fini = 0;
  if (fichierLu == NULL)
    noError = 0;
  else {
    if (tableauHuffman(code)) {
      fichierCode = save();
      while (!fini)
        fini = codeCarac(fichierCode, fgetc(fichierLu), code);
      fclose(fichierCode);
    }
    fclose(fichierLu);
  }
  return noError;
}


x86 assembly (clang, -O0):
<codage>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0xe24(%rbp)
movl   $0x0,-0xe28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b9 <codage+0x59>
movl   $0x0,-0xe24(%rbp)
jmp    1239 <codage+0xd9>
lea    -0xe20(%rbp),%rdi
call   1030 <tableauHuffman@plt>
cmp    $0x0,%rax
je     1230 <codage+0xd0>
mov    $0x0,%al
call   1050 <save@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0xe28(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f3 <codage+0x93>
jmp    1227 <codage+0xc7>
mov    -0x18(%rbp),%rax
mov    %rax,-0xe30(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    -0xe30(%rbp),%rdi
mov    %eax,%esi
lea    -0xe20(%rbp),%rdx
call   1080 <codeCarac@plt>
mov    %eax,-0xe28(%rbp)
jmp    11da <codage+0x7a>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xe24(%rbp),%eax
add    $0xe30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<codage>:
push   %r15
push   %r14
push   %rbx
sub    $0xe00,%rsp
lea    0xe8d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11d0 <codage+0x70>
mov    %rax,%r14
mov    %rsp,%rdi
call   1030 <tableauHuffman@plt>
test   %rax,%rax
je     11c1 <codage+0x61>
xor    %eax,%eax
call   1050 <save@plt>
mov    %rax,%rbx
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <fgetc@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1080 <codeCarac@plt>
test   %eax,%eax
je     11a0 <codage+0x40>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
jmp    11d2 <codage+0x72>
xor    %eax,%eax
add    $0xe00,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @codage(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [256 x [14 x i8]]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %3
store i32* null, i32** %4
store i32 1, i32* %6
store i32 0, i32* %7
%10 = load i32*, i32** %3
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 0, i32* %6
br label %37
13: ; preds = %1
%14 = getelementptr inbounds [256 x [14 x i8]], [256 x [14 x i8]]* %5, i64 0, i64 0
%15 = bitcast [14 x i8]* %14 to i8**
%16 = call i64 @tableauHuffman(i8** %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %13
%19 = call i32* (...) @save()
store i32* %19, i32** %4
br label %20
20: ; preds = %24, %18
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32*, i32** %4
%26 = load i32*, i32** %3
%27 = call i32 @fgetc(i32* %26)
%28 = getelementptr inbounds [256 x [14 x i8]], [256 x [14 x i8]]* %5, i64 0, i64 0
%29 = bitcast [14 x i8]* %28 to i8**
%30 = call i32 @codeCarac(i32* %25, i32 %27, i8** %29)
store i32 %30, i32* %7
br label %20
31: ; preds = %20
%32 = load i32*, i32** %4
%33 = call i32 @fclose(i32* %32)
br label %34
34: ; preds = %31, %13
%35 = load i32*, i32** %3
%36 = call i32 @fclose(i32* %35)
br label %37
37: ; preds = %34, %12
%38 = load i32, i32* %6
ret i32 %38
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @codage(i8* nocapture %0) {
%2 = alloca [256 x [14 x i8]]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [256 x [14 x i8]], [256 x [14 x i8]]* %2, i64 0, i64 0, i64 0
%5 = icmp eq i32* %3, null
br i1 %5, label %20, label %6
6: ; preds = %1
%7 = bitcast [256 x [14 x i8]]* %2 to i8**
%8 = call i64 @tableauHuffman(i8** %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = call i32* (...) @save()
br label %12
12: ; preds = %10, %12
%13 = call i32 @fgetc(i32* %3)
%14 = call i32 @codeCarac(i32* %11, i32 %13, i8** %7)
%15 = icmp eq i32 %14, 0
br i1 %15, label %12, label %16
16: ; preds = %12
%17 = call i32 @fclose(i32* %11)
br label %18
18: ; preds = %16, %6
%19 = call i32 @fclose(i32* %3)
br label %20
20: ; preds = %1, %18
%21 = phi i32 [ 1, %18 ], [ 0, %1 ]
ret i32 %21
}