#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *);
int tableauHuffman(char code[][14]) {
  FILE *fichier = fopen("huff256.cod", "r");
  int i, noError = 1;
  if (fichier == NULL) {
    printf("Erreur : table huff256.cod non presente.\n\n");
    noError = 0;
  } else {
    fscanf(fichier, "%*d");
    for (i = 0; i < 256; i++) {
      fscanf(fichier, "%*d%s", code[i]);
    }
    fclose(fichier);
  }
  return noError;
}


x86 assembly (clang, -O0):
<tableauHuffman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118d <tableauHuffman+0x4d>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
jmp    11eb <tableauHuffman+0xab>
mov    -0x10(%rbp),%rdi
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11e2 <tableauHuffman+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
movslq -0x14(%rbp),%rax
imul   $0xe,%rax,%rax
add    %rax,%rdx
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <tableauHuffman+0x66>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tableauHuffman>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeae(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ad <tableauHuffman+0x6d>
mov    %rax,%r12
lea    0xea1(%rip),%rsi
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
lea    0xe94(%rip),%r15
xor    %ebx,%ebx
lea    (%r14,%rbx,1),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0xe,%rbx
cmp    $0xe00,%rbx
jne    1180 <tableauHuffman+0x40>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
jmp    11bb <tableauHuffman+0x7b>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"huff256.cod\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [43 x i8] c"Erreur : table huff256.cod non presente.\0A\0A\00"
@.str.3 = [4 x i8] c"%*d\00"
@.str.4 = [6 x i8] c"%*d%s\00"
define i32 @tableauHuffman([14 x i8]* %0) {
%2 = alloca [14 x i8]*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store [14 x i8]* %0, [14 x i8]** %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
store i32 1, i32* %5
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %31
11: ; preds = %1
%12 = load i32*, i32** %3
%13 = call i32 (i32*, i8*, ...) @fscanf(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %14
14: ; preds = %25, %11
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 256
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i32*, i32** %3
%19 = load [14 x i8]*, [14 x i8]** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [14 x i8], [14 x i8]* %19, i64 %21
%23 = getelementptr inbounds [14 x i8], [14 x i8]* %22, i64 0, i64 0
%24 = call i32 (i32*, i8*, ...) @fscanf(i32* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %17
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %14
28: ; preds = %14
%29 = load i32*, i32** %3
%30 = call i32 @fclose(i32* %29)
br label %31
31: ; preds = %28, %9
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
@.str = [12 x i8] c"huff256.cod\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [4 x i8] c"%*d\00"
@.str.4 = [6 x i8] c"%*d%s\00"
@str = [42 x i8] c"Erreur : table huff256.cod non presente.\0A\00"
define i32 @tableauHuffman([14 x i8]* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %16
6: ; preds = %1
%7 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %12, %8 ]
%10 = getelementptr inbounds [14 x i8], [14 x i8]* %0, i64 %9, i64 0
%11 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%12 = add nuw nsw i64 %9, 1
%13 = icmp eq i64 %12, 256
br i1 %13, label %14, label %8
14: ; preds = %8
%15 = tail call i32 @fclose(i32* %2)
br label %16
16: ; preds = %14, %4
%17 = phi i32 [ 0, %4 ], [ 1, %14 ]
ret i32 %17
}