#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 key_value {
  int dummy;
};
struct hash_table {
  int dummy;
};

/* Variables and functions */
struct key_value **hash_map_slot(struct hash_table *, char *,
                                 int /*<<< orphan*/ *);
struct key_value *sym_key_value(char *, int /*<<< orphan*/ *);
struct key_value *inter_mapping_intern(struct hash_table *map, char *sym_key) {
  struct key_value **slot = hash_map_slot(map, sym_key, NULL);
  if (!*slot) {
    *slot = sym_key_value(sym_key, NULL);
  }
  return *slot;
}


x86 assembly (clang, -O0):
<inter_mapping_intern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <hash_map_slot@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    116a <inter_mapping_intern+0x4a>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <sym_key_value@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inter_mapping_intern>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
xor    %edx,%edx
call   1030 <hash_map_slot@plt>
mov    %rax,%rbx
mov    (%rax),%rax
test   %rax,%rax
jne    1146 <inter_mapping_intern+0x26>
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <sym_key_value@plt>
mov    %rax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.key_value = type { i32 }
%struct.hash_table = type { i32 }
define %struct.key_value* @inter_mapping_intern(%struct.hash_table* %0, i8* %1) {
%3 = alloca %struct.hash_table*
%4 = alloca i8*
%5 = alloca %struct.key_value**
store %struct.hash_table* %0, %struct.hash_table** %3
store i8* %1, i8** %4
%6 = load %struct.hash_table*, %struct.hash_table** %3
%7 = load i8*, i8** %4
%8 = call %struct.key_value** @hash_map_slot(%struct.hash_table* %6, i8* %7, i32* null)
store %struct.key_value** %8, %struct.key_value*** %5
%9 = load %struct.key_value**, %struct.key_value*** %5
%10 = load %struct.key_value*, %struct.key_value** %9
%11 = icmp ne %struct.key_value* %10, null
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call %struct.key_value* @sym_key_value(i8* %13, i32* null)
%15 = load %struct.key_value**, %struct.key_value*** %5
store %struct.key_value* %14, %struct.key_value** %15
br label %16
16: ; preds = %12, %2
%17 = load %struct.key_value**, %struct.key_value*** %5
%18 = load %struct.key_value*, %struct.key_value** %17
ret %struct.key_value* %18
}

LLVM IR (-O2):
%struct.key_value = type { i32 }
%struct.hash_table = type { i32 }
define %struct.key_value* @inter_mapping_intern(%struct.hash_table* %0, i8* %1) {
%3 = tail call %struct.key_value** @hash_map_slot(%struct.hash_table* %0, i8* %1, i32* null)
%4 = load %struct.key_value*, %struct.key_value** %3
%5 = icmp eq %struct.key_value* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call %struct.key_value* @sym_key_value(i8* %1, i32* null)
store %struct.key_value* %7, %struct.key_value** %3
br label %8
8: ; preds = %6, %2
%9 = phi %struct.key_value* [ %7, %6 ], [ %4, %2 ]
ret %struct.key_value* %9
}