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

/* Variables and functions */
int EFAULT;
int hadd(struct hashtable *, char *, char *);
int /*<<< orphan*/ hdel(struct hashtable *, char *);
int /*<<< orphan*/ hfree(struct hashtable *);
char *hget(struct hashtable *, char *);
struct hashtable *hmake(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  struct hashtable *ht = hmake(10);
  if (!ht) {
    return EFAULT;
  }
  hadd(ht, "name", "John");
  hadd(ht, "age", "20");
  int status = hadd(ht, "location", "New York");
  if (status != 0) {
    printf("Memory allocation error\n");
    return status;
  }
  char *name = hget(ht, "name");
  char *age = hget(ht, "age");
  char *location = hget(ht, "location");
  printf("Name: %s\nAge: %s\nLocation: %s\n", name, age, location);
  hdel(ht, "name");
  name = hget(ht, "name");
  printf("Name: %s\n", name);
  hfree(ht);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
call   1070 <hmake@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1199 <main+0x39>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <main+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
lea    0xe5a(%rip),%rdx
call   1050 <hadd@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4f(%rip),%rsi
lea    0xe4c(%rip),%rdx
call   1050 <hadd@plt>
mov    -0x10(%rbp),%rdi
lea    0xe3f(%rip),%rsi
lea    0xe41(%rip),%rdx
call   1050 <hadd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1204 <main+0xa4>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12a0 <main+0x140>
mov    -0x10(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1060 <hget@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1060 <hget@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1060 <hget@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd9b(%rip),%rsi
call   1080 <hdel@plt>
mov    -0x10(%rbp),%rdi
lea    0xd8b(%rip),%rsi
call   1060 <hget@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <hfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xa,%edi
call   1080 <hmake@plt>
test   %rax,%rax
je     11e3 <main+0x73>
mov    %rax,%rbx
lea    0xe6f(%rip),%rsi
lea    0xe6d(%rip),%rdx
mov    %rax,%rdi
call   1060 <hadd@plt>
lea    0xe63(%rip),%rsi
lea    0xe60(%rip),%rdx
mov    %rbx,%rdi
call   1060 <hadd@plt>
lea    0xe54(%rip),%rsi
lea    0xe56(%rip),%rdx
mov    %rbx,%rdi
call   1060 <hadd@plt>
test   %eax,%eax
je     11ee <main+0x7e>
mov    %eax,%ebp
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
jmp    126c <main+0xfc>
mov    0x2e0e(%rip),%rax
mov    (%rax),%ebp
jmp    126c <main+0xfc>
lea    0xe0b(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <hget@plt>
mov    %rax,%r15
lea    0xe00(%rip),%rsi
mov    %rbx,%rdi
call   1070 <hget@plt>
mov    %rax,%r12
lea    0xdf5(%rip),%rsi
mov    %rbx,%rdi
call   1070 <hget@plt>
lea    0xdf8(%rip),%rdi
xor    %ebp,%ebp
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <hdel@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <hget@plt>
lea    0xde8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <hfree@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hashtable = type { i32 }
@EFAULT = global i32 0
@.str = [5 x i8] c"name\00"
@.str.1 = [5 x i8] c"John\00"
@.str.2 = [4 x i8] c"age\00"
@.str.3 = [3 x i8] c"20\00"
@.str.4 = [9 x i8] c"location\00"
@.str.5 = [9 x i8] c"New York\00"
@.str.6 = [25 x i8] c"Memory allocation error\0A\00"
@.str.7 = [31 x i8] c"Name: %s\0AAge: %s\0ALocation: %s\0A\00"
@.str.8 = [10 x i8] c"Name: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.hashtable*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = call %struct.hashtable* @hmake(i32 10)
store %struct.hashtable* %7, %struct.hashtable** %2
%8 = load %struct.hashtable*, %struct.hashtable** %2
%9 = icmp ne %struct.hashtable* %8, null
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = load i32, i32* @EFAULT
store i32 %11, i32* %1
br label %43
12: ; preds = %0
%13 = load %struct.hashtable*, %struct.hashtable** %2
%14 = call i32 @hadd(%struct.hashtable* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = load %struct.hashtable*, %struct.hashtable** %2
%16 = call i32 @hadd(%struct.hashtable* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = load %struct.hashtable*, %struct.hashtable** %2
%18 = call i32 @hadd(%struct.hashtable* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %12
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32, i32* %3
store i32 %23, i32* %1
br label %43
24: ; preds = %12
%25 = load %struct.hashtable*, %struct.hashtable** %2
%26 = call i8* @hget(%struct.hashtable* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %26, i8** %4
%27 = load %struct.hashtable*, %struct.hashtable** %2
%28 = call i8* @hget(%struct.hashtable* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %28, i8** %5
%29 = load %struct.hashtable*, %struct.hashtable** %2
%30 = call i8* @hget(%struct.hashtable* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i8* %30, i8** %6
%31 = load i8*, i8** %4
%32 = load i8*, i8** %5
%33 = load i8*, i8** %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %31, i8* %32, i8* %33)
%35 = load %struct.hashtable*, %struct.hashtable** %2
%36 = call i32 @hdel(%struct.hashtable* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%37 = load %struct.hashtable*, %struct.hashtable** %2
%38 = call i8* @hget(%struct.hashtable* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %38, i8** %4
%39 = load i8*, i8** %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %39)
%41 = load %struct.hashtable*, %struct.hashtable** %2
%42 = call i32 @hfree(%struct.hashtable* %41)
store i32 0, i32* %1
br label %43
43: ; preds = %24, %21, %10
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
%struct.hashtable = type { i32 }
@EFAULT = global i32 0
@.str = [5 x i8] c"name\00"
@.str.1 = [5 x i8] c"John\00"
@.str.2 = [4 x i8] c"age\00"
@.str.3 = [3 x i8] c"20\00"
@.str.4 = [9 x i8] c"location\00"
@.str.5 = [9 x i8] c"New York\00"
@.str.7 = [31 x i8] c"Name: %s\0AAge: %s\0ALocation: %s\0A\00"
@.str.8 = [10 x i8] c"Name: %s\0A\00"
@str = [24 x i8] c"Memory allocation error\00"
define i32 @main() {
%1 = tail call %struct.hashtable* @hmake(i32 10)
%2 = icmp eq %struct.hashtable* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = load i32, i32* @EFAULT
br label %21
5: ; preds = %0
%6 = tail call i32 @hadd(%struct.hashtable* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @hadd(%struct.hashtable* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @hadd(%struct.hashtable* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %21
12: ; preds = %5
%13 = tail call i8* @hget(%struct.hashtable* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = tail call i8* @hget(%struct.hashtable* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i8* @hget(%struct.hashtable* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* %13, i8* %14, i8* %15)
%17 = tail call i32 @hdel(%struct.hashtable* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = tail call i8* @hget(%struct.hashtable* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %18)
%20 = tail call i32 @hfree(%struct.hashtable* %1)
br label %21
21: ; preds = %10, %12, %3
%22 = phi i32 [ %4, %3 ], [ %8, %10 ], [ 0, %12 ]
ret i32 %22
}