#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 assoc_array {
  int dummy;
};

/* Variables and functions */
scalar_t__ assoc_get(struct assoc_array *, char *);
int /*<<< orphan*/ assoc_print(struct assoc_array *);
int /*<<< orphan*/ free_config(struct assoc_array *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
struct assoc_array *read_config(char *);
int main() {
  char filename[] = "config_test.cfg";
  puts("reading the config");
  struct assoc_array *config = read_config(filename);
  puts("printing whole array");
  assoc_print(config);
  puts("reading key");
  printf("key => %s\n", (char *)assoc_get(config, "key"));
  printf("test => %s\n", (char *)assoc_get(config, "test"));
  free_config(config);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
lea    -0x20(%rbp),%rdi
call   1080 <read_config@plt>
mov    %rax,-0x28(%rbp)
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    -0x28(%rbp),%rdi
call   1050 <assoc_print@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    -0x28(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1070 <assoc_get@plt>
mov    %rax,%rsi
lea    0xe6b(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1070 <assoc_get@plt>
mov    %rax,%rsi
lea    0xe57(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free_config@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movaps 0xe94(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1080 <read_config@plt>
mov    %rax,%rbx
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <assoc_print@plt>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1070 <assoc_get@plt>
lea    0xe87(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <assoc_get@plt>
lea    0xe74(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <free_config@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.assoc_array = type { i32 }
@__const.main.filename = [16 x i8] c"config_test.cfg\00"
@.str = [19 x i8] c"reading the config\00"
@.str.1 = [21 x i8] c"printing whole array\00"
@.str.2 = [12 x i8] c"reading key\00"
@.str.3 = [11 x i8] c"key => %s\0A\00"
@.str.4 = [4 x i8] c"key\00"
@.str.5 = [12 x i8] c"test => %s\0A\00"
@.str.6 = [5 x i8] c"test\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca %struct.assoc_array*
store i32 0, i32* %1
%4 = bitcast [16 x i8]* %2 to i8*
%5 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%7 = call %struct.assoc_array* @read_config(i8* %6)
store %struct.assoc_array* %7, %struct.assoc_array** %3
%8 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = load %struct.assoc_array*, %struct.assoc_array** %3
%10 = call i32 @assoc_print(%struct.assoc_array* %9)
%11 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%12 = load %struct.assoc_array*, %struct.assoc_array** %3
%13 = call i64 @assoc_get(%struct.assoc_array* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%14 = inttoptr i64 %13 to i8*
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = load %struct.assoc_array*, %struct.assoc_array** %3
%17 = call i64 @assoc_get(%struct.assoc_array* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%18 = inttoptr i64 %17 to i8*
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %18)
%20 = load %struct.assoc_array*, %struct.assoc_array** %3
%21 = call i32 @free_config(%struct.assoc_array* %20)
ret i32 0
}

LLVM IR (-O2):
%struct.assoc_array = type { i32 }
@__const.main.filename = [16 x i8] c"config_test.cfg\00"
@.str = [19 x i8] c"reading the config\00"
@.str.1 = [21 x i8] c"printing whole array\00"
@.str.2 = [12 x i8] c"reading key\00"
@.str.3 = [11 x i8] c"key => %s\0A\00"
@.str.4 = [4 x i8] c"key\00"
@.str.5 = [12 x i8] c"test => %s\0A\00"
@.str.6 = [5 x i8] c"test\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = call %struct.assoc_array* @read_config(i8* %2)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @assoc_print(%struct.assoc_array* %4)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%8 = call i64 @assoc_get(%struct.assoc_array* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%9 = inttoptr i64 %8 to i8*
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = call i64 @assoc_get(%struct.assoc_array* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%12 = inttoptr i64 %11 to i8*
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%14 = call i32 @free_config(%struct.assoc_array* %4)
ret i32 0
}