#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 translation {
  int dummy;
};
struct hashlib_hash {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ failed();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ hashlib_get(struct hashlib_hash *, char *);
int /*<<< orphan*/ hashlib_hash_delete(struct hashlib_hash *);
struct hashlib_hash *hashlib_hash_new(int);
int /*<<< orphan*/ hashlib_put(struct hashlib_hash *, char *,
                               struct translation *);
struct translation *hashlib_remove(struct hashlib_hash *, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ success();
int /*<<< orphan*/ translation_delete(struct translation *);
struct translation *translation_new();
void test_hashlib_remove(void) {
  struct hashlib_hash *hash;
  struct translation *p, *r;
  hash = hashlib_hash_new(1000);
  p = translation_new();
  hashlib_put(hash, "test", p);
  r = hashlib_remove(hash, "test");
  do {
    fputs(("Testing "
           "hashlib_remove"
           ": "),
          stdout);
    fflush(stdout);
  } while (0);
  if (r != p) {
    failed();
  } else {
    if (hashlib_get(hash, "test"))
      failed();
    else
      success();
  }
  translation_delete(p);
  hashlib_hash_delete(hash);
}


x86 assembly (clang, -O0):
<test_hashlib_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x3e8,%edi
call   10b0 <hashlib_hash_new@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <translation_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1080 <hashlib_put@plt>
mov    -0x8(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1030 <hashlib_remove@plt>
mov    %rax,-0x18(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%esi
lea    0xdfc(%rip),%rdi
call   1060 <fputs@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1236 <test_hashlib_remove+0x86>
mov    $0x0,%al
call   10a0 <failed@plt>
jmp    1268 <test_hashlib_remove+0xb8>
mov    -0x8(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   10c0 <hashlib_get@plt>
cmp    $0x0,%rax
je     125c <test_hashlib_remove+0xac>
mov    $0x0,%al
call   10a0 <failed@plt>
jmp    1263 <test_hashlib_remove+0xb3>
mov    $0x0,%al
call   1050 <success@plt>
jmp    1268 <test_hashlib_remove+0xb8>
mov    -0x10(%rbp),%rdi
call   1090 <translation_delete@plt>
mov    -0x8(%rbp),%rdi
call   1070 <hashlib_hash_delete@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_hashlib_remove>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x3e8,%edi
call   10b0 <hashlib_hash_new@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <translation_new@plt>
mov    %rax,%r15
lea    0xe2a(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1080 <hashlib_put@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <hashlib_remove@plt>
mov    %rax,%rbx
mov    0x2de7(%rip),%r12
mov    (%r12),%esi
lea    0xe01(%rip),%rdi
call   1060 <fputs@plt>
mov    (%r12),%edi
call   10d0 <fflush@plt>
cmp    %r15,%rbx
jne    122b <test_hashlib_remove+0x7b>
lea    0xde2(%rip),%rsi
mov    %r14,%rdi
call   10c0 <hashlib_get@plt>
test   %rax,%rax
je     124d <test_hashlib_remove+0x9d>
xor    %eax,%eax
call   10a0 <failed@plt>
mov    %r15,%rdi
call   1090 <translation_delete@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <hashlib_hash_delete@plt>
xor    %eax,%eax
call   1050 <success@plt>
jmp    1232 <test_hashlib_remove+0x82>

LLVM IR (-O0):
%struct.hashlib_hash = type { i32 }
%struct.translation = type { i32 }
@.str = [5 x i8] c"test\00"
@.str.1 = [25 x i8] c"Testing hashlib_remove: \00"
@stdout = global i32 0
define void @test_hashlib_remove() {
%1 = alloca %struct.hashlib_hash*
%2 = alloca %struct.translation*
%3 = alloca %struct.translation*
%4 = call %struct.hashlib_hash* @hashlib_hash_new(i32 1000)
store %struct.hashlib_hash* %4, %struct.hashlib_hash** %1
%5 = call %struct.translation* (...) @translation_new()
store %struct.translation* %5, %struct.translation** %2
%6 = load %struct.hashlib_hash*, %struct.hashlib_hash** %1
%7 = load %struct.translation*, %struct.translation** %2
%8 = call i32 @hashlib_put(%struct.hashlib_hash* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.translation* %7)
%9 = load %struct.hashlib_hash*, %struct.hashlib_hash** %1
%10 = call %struct.translation* @hashlib_remove(%struct.hashlib_hash* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.translation* %10, %struct.translation** %3
br label %11
11: ; preds = %0
%12 = load i32, i32* @stdout
%13 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
br label %16
16: ; preds = %11
%17 = load %struct.translation*, %struct.translation** %3
%18 = load %struct.translation*, %struct.translation** %2
%19 = icmp ne %struct.translation* %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (...) @failed()
br label %31
22: ; preds = %16
%23 = load %struct.hashlib_hash*, %struct.hashlib_hash** %1
%24 = call i64 @hashlib_get(%struct.hashlib_hash* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (...) @failed()
br label %30
28: ; preds = %22
%29 = call i32 (...) @success()
br label %30
30: ; preds = %28, %26
br label %31
31: ; preds = %30, %20
%32 = load %struct.translation*, %struct.translation** %2
%33 = call i32 @translation_delete(%struct.translation* %32)
%34 = load %struct.hashlib_hash*, %struct.hashlib_hash** %1
%35 = call i32 @hashlib_hash_delete(%struct.hashlib_hash* %34)
ret void
}

LLVM IR (-O2):
%struct.hashlib_hash = type { i32 }
%struct.translation = type { i32 }
@.str = [5 x i8] c"test\00"
@.str.1 = [25 x i8] c"Testing hashlib_remove: \00"
@stdout = global i32 0
define void @test_hashlib_remove() {
%1 = tail call %struct.hashlib_hash* @hashlib_hash_new(i32 1000)
%2 = tail call %struct.translation* (...) @translation_new()
%3 = tail call i32 @hashlib_put(%struct.hashlib_hash* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.translation* %2)
%4 = tail call %struct.translation* @hashlib_remove(%struct.hashlib_hash* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdout
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @stdout
%8 = tail call i32 @fflush(i32 %7)
%9 = icmp eq %struct.translation* %4, %2
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = tail call i32 (...) @failed()
br label %19
12: ; preds = %0
%13 = tail call i64 @hashlib_get(%struct.hashlib_hash* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 (...) @failed()
br label %19
17: ; preds = %12
%18 = tail call i32 (...) @success()
br label %19
19: ; preds = %15, %17, %10
%20 = tail call i32 @translation_delete(%struct.translation* %2)
%21 = tail call i32 @hashlib_hash_delete(%struct.hashlib_hash* %1)
ret void
}