#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 */
struct abr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ affiche_huffman(struct abr *);
int /*<<< orphan*/ insertion(struct abr **, int, int);
int /*<<< orphan*/ libere_huffman(struct abr *);
int next_huffman_value(struct abr *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  struct abr *ht = NULL;
  printf("INSERTIONS\n");
  insertion(&ht, 2, 0x0d);
  insertion(&ht, 2, 0x0e);
  insertion(&ht, 2, 0x0a);
  insertion(&ht, 3, 0x0c);
  insertion(&ht, 3, 0x0b);
  affiche_huffman(ht);
  printf("\nNEXT_HUFFMAN_VALUE\n");
  char *code = "00";
  printf("%s <=> 0x%x\n", code, next_huffman_value(ht, code));
  code = "01";
  printf("%s <=> 0x%x\n", code, next_huffman_value(ht, code));
  code = "10";
  printf("%s <=> 0x%x\n", code, next_huffman_value(ht, code));
  code = "110";
  printf("%s <=> 0x%x\n", code, next_huffman_value(ht, code));
  code = "111";
  printf("%s <=> 0x%x\n", code, next_huffman_value(ht, code));
  libere_huffman(ht);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
mov    $0xd,%edx
call   1060 <insertion@plt>
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
mov    $0xe,%edx
call   1060 <insertion@plt>
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1060 <insertion@plt>
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0xc,%edx
call   1060 <insertion@plt>
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0xb,%edx
call   1060 <insertion@plt>
mov    -0x10(%rbp),%rdi
call   1070 <affiche_huffman@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2f(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <next_huffman_value@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <next_huffman_value@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xddb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <next_huffman_value@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda6(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <next_huffman_value@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd76(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <next_huffman_value@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <libere_huffman@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xd,%edx
call   1070 <insertion@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xe,%edx
call   1070 <insertion@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1070 <insertion@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0xc,%edx
call   1070 <insertion@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0xb,%edx
call   1070 <insertion@plt>
mov    (%rsp),%rdi
call   1080 <affiche_huffman@plt>
lea    0xe41(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rdi
lea    0xe0b(%rip),%rbx
mov    %rbx,%rsi
call   1060 <next_huffman_value@plt>
lea    0xdff(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rdi
lea    0xdf2(%rip),%rbx
mov    %rbx,%rsi
call   1060 <next_huffman_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rdi
lea    0xdd4(%rip),%rbx
mov    %rbx,%rsi
call   1060 <next_huffman_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rdi
lea    0xdb1(%rip),%rbx
mov    %rbx,%rsi
call   1060 <next_huffman_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rdi
lea    0xd93(%rip),%rbx
mov    %rbx,%rsi
call   1060 <next_huffman_value@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rdi
call   1050 <libere_huffman@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.abr = type { i32 }
@.str = [12 x i8] c"INSERTIONS\0A\00"
@.str.1 = [21 x i8] c"\0ANEXT_HUFFMAN_VALUE\0A\00"
@.str.2 = [3 x i8] c"00\00"
@.str.3 = [13 x i8] c"%s <=> 0x%x\0A\00"
@.str.4 = [3 x i8] c"01\00"
@.str.5 = [3 x i8] c"10\00"
@.str.6 = [4 x i8] c"110\00"
@.str.7 = [4 x i8] c"111\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.abr*
%3 = alloca i8*
store i32 0, i32* %1
store %struct.abr* null, %struct.abr** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @insertion(%struct.abr** %2, i32 2, i32 13)
%6 = call i32 @insertion(%struct.abr** %2, i32 2, i32 14)
%7 = call i32 @insertion(%struct.abr** %2, i32 2, i32 10)
%8 = call i32 @insertion(%struct.abr** %2, i32 3, i32 12)
%9 = call i32 @insertion(%struct.abr** %2, i32 3, i32 11)
%10 = load %struct.abr*, %struct.abr** %2
%11 = call i32 @affiche_huffman(%struct.abr* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %3
%13 = load i8*, i8** %3
%14 = load %struct.abr*, %struct.abr** %2
%15 = load i8*, i8** %3
%16 = call i32 @next_huffman_value(%struct.abr* %14, i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %13, i32 %16)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %3
%18 = load i8*, i8** %3
%19 = load %struct.abr*, %struct.abr** %2
%20 = load i8*, i8** %3
%21 = call i32 @next_huffman_value(%struct.abr* %19, i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %18, i32 %21)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %3
%23 = load i8*, i8** %3
%24 = load %struct.abr*, %struct.abr** %2
%25 = load i8*, i8** %3
%26 = call i32 @next_huffman_value(%struct.abr* %24, i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %23, i32 %26)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %3
%28 = load i8*, i8** %3
%29 = load %struct.abr*, %struct.abr** %2
%30 = load i8*, i8** %3
%31 = call i32 @next_huffman_value(%struct.abr* %29, i8* %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %28, i32 %31)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %3
%33 = load i8*, i8** %3
%34 = load %struct.abr*, %struct.abr** %2
%35 = load i8*, i8** %3
%36 = call i32 @next_huffman_value(%struct.abr* %34, i8* %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %33, i32 %36)
%38 = load %struct.abr*, %struct.abr** %2
%39 = call i32 @libere_huffman(%struct.abr* %38)
ret i32 0
}

LLVM IR (-O2):
%struct.abr = type { i32 }
@.str.2 = [3 x i8] c"00\00"
@.str.3 = [13 x i8] c"%s <=> 0x%x\0A\00"
@.str.4 = [3 x i8] c"01\00"
@.str.5 = [3 x i8] c"10\00"
@.str.6 = [4 x i8] c"110\00"
@.str.7 = [4 x i8] c"111\00"
@str = [11 x i8] c"INSERTIONS\00"
@str.8 = [20 x i8] c"\0ANEXT_HUFFMAN_VALUE\00"
define i32 @main() {
%1 = alloca %struct.abr*
%2 = bitcast %struct.abr** %1 to i8*
store %struct.abr* null, %struct.abr** %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = call i32 @insertion(%struct.abr** %1, i32 2, i32 13)
%5 = call i32 @insertion(%struct.abr** %1, i32 2, i32 14)
%6 = call i32 @insertion(%struct.abr** %1, i32 2, i32 10)
%7 = call i32 @insertion(%struct.abr** %1, i32 3, i32 12)
%8 = call i32 @insertion(%struct.abr** %1, i32 3, i32 11)
%9 = load %struct.abr*, %struct.abr** %1
%10 = call i32 @affiche_huffman(%struct.abr* %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
%12 = load %struct.abr*, %struct.abr** %1
%13 = call i32 @next_huffman_value(%struct.abr* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load %struct.abr*, %struct.abr** %1
%16 = call i32 @next_huffman_value(%struct.abr* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = load %struct.abr*, %struct.abr** %1
%19 = call i32 @next_huffman_value(%struct.abr* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = load %struct.abr*, %struct.abr** %1
%22 = call i32 @next_huffman_value(%struct.abr* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %22)
%24 = load %struct.abr*, %struct.abr** %1
%25 = call i32 @next_huffman_value(%struct.abr* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = load %struct.abr*, %struct.abr** %1
%28 = call i32 @libere_huffman(%struct.abr* %27)
ret i32 0
}