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

/* Variables and functions */
int /*<<< orphan*/ hash_add(struct hash *, char *, char *);
int /*<<< orphan*/ hash_collision_stats(struct hash *);
int /*<<< orphan*/ hash_destroy(struct hash *);
struct hash *hash_new(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main() {
  struct hash *my_hash;
  int pot;
  int i;
  char *dummy;
  pot = 16;
  my_hash = hash_new(pot);
  for (i = 1; i <= (1 << pot); i++) {
    sprintf(dummy, "dummy_%d", i);
    hash_add(my_hash, dummy, "FOO");
  }
  hash_collision_stats(my_hash);
  hash_destroy(my_hash);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x10,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <hash_new@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
cmp    %ecx,%eax
jg     11c5 <main+0x75>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe62(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    0xe57(%rip),%rdx
call   1040 <hash_add@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1179 <main+0x29>
mov    -0x10(%rbp),%rdi
call   1050 <hash_collision_stats@plt>
mov    -0x10(%rbp),%rdi
call   1030 <hash_destroy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x10,%edi
call   1070 <hash_new@plt>
mov    %rax,%rbx
mov    $0x1,%ebp
lea    0xe90(%rip),%r14
lea    0xe92(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rsi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rdx
call   1040 <hash_add@plt>
add    $0x1,%ebp
cmp    $0x10001,%ebp
jne    1180 <main+0x30>
mov    %rbx,%rdi
call   1050 <hash_collision_stats@plt>
mov    %rbx,%rdi
call   1030 <hash_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hash = type { i32 }
@.str = [9 x i8] c"dummy_%d\00"
@.str.1 = [4 x i8] c"FOO\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.hash*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 0, i32* %1
store i32 16, i32* %3
%6 = load i32, i32* %3
%7 = call %struct.hash* @hash_new(i32 %6)
store %struct.hash* %7, %struct.hash** %2
store i32 1, i32* %4
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = shl i32 1, %10
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i8*, i8** %5
%15 = load i32, i32* %4
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load %struct.hash*, %struct.hash** %2
%18 = load i8*, i8** %5
%19 = call i32 @hash_add(%struct.hash* %17, i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %13
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %8
23: ; preds = %8
%24 = load %struct.hash*, %struct.hash** %2
%25 = call i32 @hash_collision_stats(%struct.hash* %24)
%26 = load %struct.hash*, %struct.hash** %2
%27 = call i32 @hash_destroy(%struct.hash* %26)
ret i32 0
}

LLVM IR (-O2):
%struct.hash = type { i32 }
@.str = [9 x i8] c"dummy_%d\00"
@.str.1 = [4 x i8] c"FOO\00"
define i32 @main() {
%1 = tail call %struct.hash* @hash_new(i32 16)
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 1, %0 ], [ %6, %2 ]
%4 = tail call i32 @sprintf(i8* dereferenceable(1) undef, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @hash_add(%struct.hash* %1, i8* undef, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = add nuw nsw i32 %3, 1
%7 = icmp eq i32 %6, 65537
br i1 %7, label %8, label %2
8: ; preds = %2
%9 = tail call i32 @hash_collision_stats(%struct.hash* %1)
%10 = tail call i32 @hash_destroy(%struct.hash* %1)
ret i32 0
}