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

/* Variables and functions */
int /*<<< orphan*/ indexDump(struct index *);
int /*<<< orphan*/ indexFree(struct index *);
int /*<<< orphan*/ indexInsert(struct index *, char *, int, double);
struct index *indexLoad(char *);
int /*<<< orphan*/ printf(char *, ...);
int db__hash_idx_sets(char *fileName, char *key, int value) {
  struct index *hash_idx = NULL;
  hash_idx = indexLoad(fileName);
  int ret;
  if (hash_idx == NULL) {
    printf("can't find the hash index in db__hash_idx_sets()\n");
    return -1;
  } else {
    if (!indexInsert(hash_idx, key, value, 0.0001)) {
      printf("insert to hash index fail :key=%s, value=%d\n", key, value);
      return -1;
    } else {
      printf("insert to hash index succeed\n");
    }
  }
  ret = 87;
  indexDump(hash_idx);
  indexFree(hash_idx);
  return ret;
}


x86 assembly (clang, -O0):
<db__hash_idx_sets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <indexLoad@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    119d <db__hash_idx_sets+0x4d>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <db__hash_idx_sets+0xc1>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsd  0xe50(%rip),%xmm0
call   1030 <indexInsert@plt>
cmp    $0x0,%eax
jne    11df <db__hash_idx_sets+0x8f>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <db__hash_idx_sets+0xc1>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11f2 <db__hash_idx_sets+0xa2>
movl   $0x57,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <indexDump@plt>
mov    -0x28(%rbp),%rdi
call   1060 <indexFree@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db__hash_idx_sets>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
call   1080 <indexLoad@plt>
test   %rax,%rax
je     11b4 <db__hash_idx_sets+0x54>
mov    %rax,%rbp
movsd  0xe81(%rip),%xmm0
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <indexInsert@plt>
test   %eax,%eax
je     11c2 <db__hash_idx_sets+0x62>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1050 <indexDump@plt>
mov    %rbp,%rdi
call   1070 <indexFree@plt>
mov    $0x57,%eax
jmp    11db <db__hash_idx_sets+0x7b>
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
jmp    11d6 <db__hash_idx_sets+0x76>
lea    0xe3f(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.index = type { i32 }
@.str = [50 x i8] c"can't find the hash index in db__hash_idx_sets()\0A\00"
@.str.1 = [45 x i8] c"insert to hash index fail :key=%s, value=%d\0A\00"
@.str.2 = [30 x i8] c"insert to hash index succeed\0A\00"
define i32 @db__hash_idx_sets(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.index*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store %struct.index* null, %struct.index** %8
%10 = load i8*, i8** %5
%11 = call %struct.index* @indexLoad(i8* %10)
store %struct.index* %11, %struct.index** %8
%12 = load %struct.index*, %struct.index** %8
%13 = icmp eq %struct.index* %12, null
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %35
16: ; preds = %3
%17 = load %struct.index*, %struct.index** %8
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = call i32 @indexInsert(%struct.index* %17, i8* %18, i32 %19, double 1.000000e-04)
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %16
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %23, i32 %24)
store i32 -1, i32* %4
br label %35
26: ; preds = %16
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26
br label %29
29: ; preds = %28
store i32 87, i32* %9
%30 = load %struct.index*, %struct.index** %8
%31 = call i32 @indexDump(%struct.index* %30)
%32 = load %struct.index*, %struct.index** %8
%33 = call i32 @indexFree(%struct.index* %32)
%34 = load i32, i32* %9
store i32 %34, i32* %4
br label %35
35: ; preds = %29, %22, %14
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
%struct.index = type { i32 }
@.str.1 = [45 x i8] c"insert to hash index fail :key=%s, value=%d\0A\00"
@str = [29 x i8] c"insert to hash index succeed\00"
@str.3 = [49 x i8] c"can't find the hash index in db__hash_idx_sets()\00"
define i32 @db__hash_idx_sets(i8* %0, i8* %1, i32 %2) {
%4 = tail call %struct.index* @indexLoad(i8* %0)
%5 = icmp eq %struct.index* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.3, i64 0, i64 0))
br label %17
8: ; preds = %3
%9 = tail call i32 @indexInsert(%struct.index* %4, i8* %1, i32 %2, double 1.000000e-04)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %2)
br label %17
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @indexDump(%struct.index* %4)
%16 = tail call i32 @indexFree(%struct.index* %4)
br label %17
17: ; preds = %13, %11, %6
%18 = phi i32 [ -1, %6 ], [ 87, %13 ], [ -1, %11 ]
ret i32 %18
}