#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 */

/* Variables and functions */
int clxns_count(void *);
int /*<<< orphan*/ clxns_free(void *, int /*<<< orphan*/);
void *hash_table(int /*<<< orphan*/);
int /*<<< orphan*/ hash_table_add(void *, char *, char *);
char *ht_add_items() {
  void *ht = hash_table(0);
  hash_table_add(ht, "AAA", "aaa");
  hash_table_add(ht, "BBB", "bbb");
  hash_table_add(ht, "XXX", "xxx");
  hash_table_add(ht, "GGG", "ggg");
  hash_table_add(ht, "QQQ", "qqq");
  int cnt = clxns_count(ht);
  do {
    if (!(cnt == 5))
      return "Wrong number of items after add";
  } while (0);
  clxns_free(ht, 0);
  return 0;
}


x86 assembly (clang, -O0):
<ht_add_items>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
call   1030 <hash_table@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
lea    0xe9f(%rip),%rdx
call   1060 <hash_table_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
lea    0xe90(%rip),%rdx
call   1060 <hash_table_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
lea    0xe81(%rip),%rdx
call   1060 <hash_table_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
lea    0xe72(%rip),%rdx
call   1060 <hash_table_add@plt>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
lea    0xe63(%rip),%rdx
call   1060 <hash_table_add@plt>
mov    -0x10(%rbp),%rdi
call   1040 <clxns_count@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
je     11ec <ht_add_items+0xac>
lea    0xe45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1204 <ht_add_items+0xc4>
jmp    11f1 <ht_add_items+0xb1>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <clxns_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ht_add_items>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <hash_table@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rsi
lea    0xea8(%rip),%rdx
mov    %rax,%rdi
call   1060 <hash_table_add@plt>
lea    0xe9d(%rip),%rsi
lea    0xe9a(%rip),%rdx
mov    %rbx,%rdi
call   1060 <hash_table_add@plt>
lea    0xe8f(%rip),%rsi
lea    0xe8c(%rip),%rdx
mov    %rbx,%rdi
call   1060 <hash_table_add@plt>
lea    0xe81(%rip),%rsi
lea    0xe7e(%rip),%rdx
mov    %rbx,%rdi
call   1060 <hash_table_add@plt>
lea    0xe73(%rip),%rsi
lea    0xe70(%rip),%rdx
mov    %rbx,%rdi
call   1060 <hash_table_add@plt>
mov    %rbx,%rdi
call   1040 <clxns_count@plt>
cmp    $0x5,%eax
jne    11d8 <ht_add_items+0x98>
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <clxns_free@plt>
jmp    11df <ht_add_items+0x9f>
lea    0xe49(%rip),%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"AAA\00"
@.str.1 = [4 x i8] c"aaa\00"
@.str.2 = [4 x i8] c"BBB\00"
@.str.3 = [4 x i8] c"bbb\00"
@.str.4 = [4 x i8] c"XXX\00"
@.str.5 = [4 x i8] c"xxx\00"
@.str.6 = [4 x i8] c"GGG\00"
@.str.7 = [4 x i8] c"ggg\00"
@.str.8 = [4 x i8] c"QQQ\00"
@.str.9 = [4 x i8] c"qqq\00"
@.str.10 = [32 x i8] c"Wrong number of items after add\00"
define i8* @ht_add_items() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = call i8* @hash_table(i32 0)
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @hash_table_add(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = load i8*, i8** %2
%8 = call i32 @hash_table_add(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = load i8*, i8** %2
%10 = call i32 @hash_table_add(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = call i32 @hash_table_add(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%13 = load i8*, i8** %2
%14 = call i32 @hash_table_add(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = call i32 @clxns_count(i8* %15)
store i32 %16, i32* %3
br label %17
17: ; preds = %0
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 5
br i1 %19, label %21, label %20
20: ; preds = %17
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8** %1
br label %25
21: ; preds = %17
br label %22
22: ; preds = %21
%23 = load i8*, i8** %2
%24 = call i32 @clxns_free(i8* %23, i32 0)
store i8* null, i8** %1
br label %25
25: ; preds = %22, %20
%26 = load i8*, i8** %1
ret i8* %26
}

LLVM IR (-O2):
@.str = [4 x i8] c"AAA\00"
@.str.1 = [4 x i8] c"aaa\00"
@.str.2 = [4 x i8] c"BBB\00"
@.str.3 = [4 x i8] c"bbb\00"
@.str.4 = [4 x i8] c"XXX\00"
@.str.5 = [4 x i8] c"xxx\00"
@.str.6 = [4 x i8] c"GGG\00"
@.str.7 = [4 x i8] c"ggg\00"
@.str.8 = [4 x i8] c"QQQ\00"
@.str.9 = [4 x i8] c"qqq\00"
@.str.10 = [32 x i8] c"Wrong number of items after add\00"
define i8* @ht_add_items() {
%1 = tail call i8* @hash_table(i32 0)
%2 = tail call i32 @hash_table_add(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @hash_table_add(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @hash_table_add(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%5 = tail call i32 @hash_table_add(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%6 = tail call i32 @hash_table_add(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%7 = tail call i32 @clxns_count(i8* %1)
%8 = icmp eq i32 %7, 5
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @clxns_free(i8* %1, i32 0)
br label %11
11: ; preds = %0, %9
%12 = phi i8* [ null, %9 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), %0 ]
ret i8* %12
}