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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
long long generatekey(long long, unsigned long, long long);
int getandRemove(struct hashentry **, long long, unsigned long, long long,
                 int /*<<< orphan*/);
int /*<<< orphan*/ insertInList(struct hashentry **, long long, long long);
int /*<<< orphan*/ printf(char *, long long, long long);
void put(struct hashentry **ht, long long int val, long unsigned int m,
         long long int N) {
  long long int key = generatekey(val, m, N);
  if (key >= N) {
    printf("\n***Error*** key is > N. key:%lli N:%lli\n", key, N);
    exit(0);
  }
  if (getandRemove(ht, val, m, N, 0) == -1) {
    insertInList(ht, key, val);
  }
}


x86 assembly (clang, -O0):
<put>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <generatekey@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     11a6 <put+0x56>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
xor    %r8d,%r8d
call   1050 <getandRemove@plt>
cmp    $0xffffffff,%eax
jne    11d8 <put+0x88>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <insertInList@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1040 <generatekey@plt>
mov    %rax,%r12
cmp    %rbx,%rax
jge    11b5 <put+0x65>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1050 <getandRemove@plt>
cmp    $0xffffffff,%eax
je     119e <put+0x4e>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1070 <insertInList@plt>
lea    0xe44(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.hashentry = type { i32 }
@.str = [42 x i8] c"\0A***Error*** key is > N. key:%lli N:%lli\0A\00"
define void @put(%struct.hashentry** %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca %struct.hashentry**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store %struct.hashentry** %0, %struct.hashentry*** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %6
%11 = load i64, i64* %7
%12 = load i64, i64* %8
%13 = call i64 @generatekey(i64 %10, i64 %11, i64 %12)
store i64 %13, i64* %9
%14 = load i64, i64* %9
%15 = load i64, i64* %8
%16 = icmp sge i64 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %4
%18 = load i64, i64* %9
%19 = load i64, i64* %8
%20 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %19)
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %4
%23 = load %struct.hashentry**, %struct.hashentry*** %5
%24 = load i64, i64* %6
%25 = load i64, i64* %7
%26 = load i64, i64* %8
%27 = call i32 @getandRemove(%struct.hashentry** %23, i64 %24, i64 %25, i64 %26, i32 0)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load %struct.hashentry**, %struct.hashentry*** %5
%31 = load i64, i64* %9
%32 = load i64, i64* %6
%33 = call i32 @insertInList(%struct.hashentry** %30, i64 %31, i64 %32)
br label %34
34: ; preds = %29, %22
ret void
}

LLVM IR (-O2):
%struct.hashentry = type { i32 }
@.str = [42 x i8] c"\0A***Error*** key is > N. key:%lli N:%lli\0A\00"
define void @put(%struct.hashentry** %0, i64 %1, i64 %2, i64 %3) {
%5 = tail call i64 @generatekey(i64 %1, i64 %2, i64 %3)
%6 = icmp slt i64 %5, %3
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %5, i64 %3)
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %4
%11 = tail call i32 @getandRemove(%struct.hashentry** %0, i64 %1, i64 %2, i64 %3, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @insertInList(%struct.hashentry** %0, i64 %5, i64 %1)
br label %15
15: ; preds = %13, %10
ret void
}