#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 hash_fn(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void insert(int arr[]) {
  int k, i = 1, id;
  printf("Enter the element \n");
  scanf("%d", &k);
  id = k % 9;
  while (arr[id] != -1) {
    id = hash_fn(k, i);
    i++;
  }
  arr[id] = k;
}


x86 assembly (clang, -O0):
<insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     119b <insert+0x6b>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <hash_fn@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116d <insert+0x3d>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rdi
imul   $0x38e38e39,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%eax
mov    %edi,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
cmpl   $0xffffffff,(%rbx,%rax,4)
je     11ba <insert+0x8a>
mov    $0x1,%esi
call   1050 <hash_fn@plt>
cltq
cmpl   $0xffffffff,(%rbx,%rax,4)
je     11b6 <insert+0x86>
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x4(%rsp),%edi
mov    %ebp,%esi
call   1050 <hash_fn@plt>
cltq
add    $0x1,%ebp
cmpl   $0xffffffff,(%rbx,%rax,4)
jne    11a0 <insert+0x70>
mov    0x4(%rsp),%edi
mov    %edi,(%rbx,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter the element \0A\00"
@.str.1 = [3 x i8] c"%d\00"
define void @insert(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = srem i32 %8, 9
store i32 %9, i32* %5
br label %10
10: ; preds = %17, %1
%11 = load i32*, i32** %2
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %23
17: ; preds = %10
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @hash_fn(i32 %18, i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %10
23: ; preds = %10
%24 = load i32, i32* %3
%25 = load i32*, i32** %2
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 %24, i32* %28
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [19 x i8] c"Enter the element \00"
define void @insert(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = srem i32 %6, 9
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, -1
br i1 %11, label %30, label %12
12: ; preds = %1
%13 = call i32 @hash_fn(i32 %6, i32 1)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, -1
br i1 %17, label %27, label %18
18: ; preds = %12, %18
%19 = phi i32 [ %20, %18 ], [ 1, %12 ]
%20 = add nuw nsw i32 %19, 1
%21 = load i32, i32* %2
%22 = call i32 @hash_fn(i32 %21, i32 %20)
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %18
27: ; preds = %18, %12
%28 = phi i64 [ %14, %12 ], [ %23, %18 ]
%29 = load i32, i32* %2
br label %30
30: ; preds = %27, %1
%31 = phi i32 [ %6, %1 ], [ %29, %27 ]
%32 = phi i64 [ %8, %1 ], [ %28, %27 ]
%33 = getelementptr inbounds i32, i32* %0, i64 %32
store i32 %31, i32* %33
ret void
}