#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 typset {
  int dummy;
};
struct typ {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_final(struct typset *, struct typ *);
int /*<<< orphan*/ add_tentative(struct typset *, int /*<<< orphan*/);
int /*<<< orphan*/ typ_hash_ready(struct typ *);
scalar_t__ typ_is_tentative(struct typ *);
int /*<<< orphan*/ typ_permanent_loc(struct typ *);
void typset_add(struct typset *set, struct typ *t) {
  if (typ_is_tentative(t) || !typ_hash_ready(t)) {
    add_tentative(set, typ_permanent_loc(t));
  } else {
    add_final(set, t);
  }
}


x86 assembly (clang, -O0):
<typset_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <typ_is_tentative@plt>
cmp    $0x0,%rax
jne    1185 <typset_add+0x35>
mov    -0x10(%rbp),%rdi
call   1030 <typ_hash_ready@plt>
cmp    $0x0,%eax
jne    11a6 <typset_add+0x56>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <typ_permanent_loc@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1040 <add_tentative@plt>
jmp    11b3 <typset_add+0x63>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <add_final@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typset_add>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <typ_is_tentative@plt>
test   %rax,%rax
je     1180 <typset_add+0x30>
mov    %rbx,%rdi
call   1070 <typ_permanent_loc@plt>
mov    %r14,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <add_tentative@plt>
mov    %rbx,%rdi
call   1030 <typ_hash_ready@plt>
test   %eax,%eax
je     1167 <typset_add+0x17>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <add_final@plt>

LLVM IR (-O0):
%struct.typset = type { i32 }
%struct.typ = type { i32 }
define void @typset_add(%struct.typset* %0, %struct.typ* %1) {
%3 = alloca %struct.typset*
%4 = alloca %struct.typ*
store %struct.typset* %0, %struct.typset** %3
store %struct.typ* %1, %struct.typ** %4
%5 = load %struct.typ*, %struct.typ** %4
%6 = call i64 @typ_is_tentative(%struct.typ* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load %struct.typ*, %struct.typ** %4
%10 = call i32 @typ_hash_ready(%struct.typ* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %8, %2
%13 = load %struct.typset*, %struct.typset** %3
%14 = load %struct.typ*, %struct.typ** %4
%15 = call i32 @typ_permanent_loc(%struct.typ* %14)
%16 = call i32 @add_tentative(%struct.typset* %13, i32 %15)
br label %21
17: ; preds = %8
%18 = load %struct.typset*, %struct.typset** %3
%19 = load %struct.typ*, %struct.typ** %4
%20 = call i32 @add_final(%struct.typset* %18, %struct.typ* %19)
br label %21
21: ; preds = %17, %12
ret void
}

LLVM IR (-O2):
%struct.typset = type { i32 }
%struct.typ = type { i32 }
define void @typset_add(%struct.typset* %0, %struct.typ* %1) {
%3 = tail call i64 @typ_is_tentative(%struct.typ* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @typ_hash_ready(%struct.typ* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5, %2
%9 = tail call i32 @typ_permanent_loc(%struct.typ* %1)
%10 = tail call i32 @add_tentative(%struct.typset* %0, i32 %9)
br label %13
11: ; preds = %5
%12 = tail call i32 @add_final(%struct.typset* %0, %struct.typ* %1)
br label %13
13: ; preds = %11, %8
ret void
}