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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
char *hash_get(struct hash_table *, char const *);
const char *messages_get_ctx(const char *key, struct hash_table *ctx) {
  const char *r = NULL;
  assert(key != NULL);
  if (ctx != NULL) {
    r = hash_get(ctx, key);
  }
  if (r == NULL) {
    r = key;
  }
  return r;
}


x86 assembly (clang, -O0):
<messages_get_ctx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
je     1166 <messages_get_ctx+0x46>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <hash_get@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1179 <messages_get_ctx+0x59>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<messages_get_ctx>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
test   %r14,%r14
je     114a <messages_get_ctx+0x2a>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <hash_get@plt>
jmp    114c <messages_get_ctx+0x2c>
xor    %eax,%eax
test   %rax,%rax
cmovne %rax,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.hash_table = type { i32 }
define i8* @messages_get_ctx(i8* %0, %struct.hash_table* %1) {
%3 = alloca i8*
%4 = alloca %struct.hash_table*
%5 = alloca i8*
store i8* %0, i8** %3
store %struct.hash_table* %1, %struct.hash_table** %4
store i8* null, i8** %5
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load %struct.hash_table*, %struct.hash_table** %4
%11 = icmp ne %struct.hash_table* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load %struct.hash_table*, %struct.hash_table** %4
%14 = load i8*, i8** %3
%15 = call i8* @hash_get(%struct.hash_table* %13, i8* %14)
store i8* %15, i8** %5
br label %16
16: ; preds = %12, %2
%17 = load i8*, i8** %5
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i8*, i8** %3
store i8* %20, i8** %5
br label %21
21: ; preds = %19, %16
%22 = load i8*, i8** %5
ret i8* %22
}

LLVM IR (-O2):
%struct.hash_table = type { i32 }
define i8* @messages_get_ctx(i8* %0, %struct.hash_table* %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp eq %struct.hash_table* %1, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i8* @hash_get(%struct.hash_table* %1, i8* %0)
br label %9
9: ; preds = %7, %2
%10 = phi i8* [ %8, %7 ], [ null, %2 ]
%11 = icmp eq i8* %10, null
%12 = select i1 %11, i8* %0, i8* %10
ret i8* %12
}