#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 cras_expr_value {
  int dummy;
};
struct cras_expr_env {
  int dummy;
};

/* Variables and functions */
struct cras_expr_value *find_value(struct cras_expr_env *, char const *);
struct cras_expr_value *insert_value(struct cras_expr_env *, char const *);
struct cras_expr_value *find_or_insert_value(struct cras_expr_env *env,
                                             const char *key) {
  struct cras_expr_value *value = find_value(env, key);
  if (!value)
    value = insert_value(env, key);
  return value;
}


x86 assembly (clang, -O0):
<find_or_insert_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <find_value@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115d <find_or_insert_value+0x3d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <insert_value@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_or_insert_value>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <find_value@plt>
test   %rax,%rax
je     113c <find_or_insert_value+0x1c>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <insert_value@plt>

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

LLVM IR (-O2):
%struct.cras_expr_value = type { i32 }
%struct.cras_expr_env = type { i32 }
define %struct.cras_expr_value* @find_or_insert_value(%struct.cras_expr_env* %0, i8* %1) {
%3 = tail call %struct.cras_expr_value* @find_value(%struct.cras_expr_env* %0, i8* %1)
%4 = icmp eq %struct.cras_expr_value* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call %struct.cras_expr_value* @insert_value(%struct.cras_expr_env* %0, i8* %1)
br label %7
7: ; preds = %5, %2
%8 = phi %struct.cras_expr_value* [ %3, %2 ], [ %6, %5 ]
ret %struct.cras_expr_value* %8
}