#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 ifexist(struct hashentry **, long long, long long, int);
int /*<<< orphan*/ printf(char *, long long, long long);
int getandRemove(struct hashentry **ht, long long int val, long unsigned int m,
                 long long int N, int remove) {
  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);
  }
  return ifexist(ht, key, val, remove);
}


x86 assembly (clang, -O0):
<getandRemove>:
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    %r8d,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <generatekey@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     119a <getandRemove+0x5a>
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <ifexist@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getandRemove>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1050 <generatekey@plt>
cmp    %rbx,%rax
jge    1181 <getandRemove+0x41>
mov    %r15,%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ifexist@plt>
lea    0xe78(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1040 <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 i32 @getandRemove(%struct.hashentry** %0, i64 %1, i64 %2, i64 %3, i32 %4) {
%6 = alloca %struct.hashentry**
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
store %struct.hashentry** %0, %struct.hashentry*** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i32 %4, i32* %10
%12 = load i64, i64* %7
%13 = load i64, i64* %8
%14 = load i64, i64* %9
%15 = call i64 @generatekey(i64 %12, i64 %13, i64 %14)
store i64 %15, i64* %11
%16 = load i64, i64* %11
%17 = load i64, i64* %9
%18 = icmp sge i64 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %5
%20 = load i64, i64* %11
%21 = load i64, i64* %9
%22 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %20, i64 %21)
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %5
%25 = load %struct.hashentry**, %struct.hashentry*** %6
%26 = load i64, i64* %11
%27 = load i64, i64* %7
%28 = load i32, i32* %10
%29 = call i32 @ifexist(%struct.hashentry** %25, i64 %26, i64 %27, i32 %28)
ret i32 %29
}

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