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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ link_to_final(int /*<<< orphan*/ *, struct typ *,
                                 struct typ *);
int /*<<< orphan*/ link_to_tentative(int /*<<< orphan*/ *, struct typ *,
                                     struct typ *);
int /*<<< orphan*/ typ_is_generic_functor(struct typ *);
int /*<<< orphan*/ typ_is_tentative(struct typ *);
scalar_t__ typ_is_ungenarg(struct typ *);
void typ_link_tentative(struct typ *dst, struct typ *src) {
  if (typ_is_ungenarg(src)) {
    return;
  }
  assert(typ_is_tentative(src));
  assert(!typ_is_generic_functor(src) && "use typ_link_tentative_functor()");
  if (dst == src) {
    return;
  }
  if (!typ_is_tentative(dst)) {
    link_to_final(NULL, dst, src);
  } else {
    link_to_tentative(NULL, dst, src);
  }
}


x86 assembly (clang, -O0):
<typ_link_tentative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <typ_is_ungenarg@plt>
cmp    $0x0,%rax
je     1188 <typ_link_tentative+0x28>
jmp    1214 <typ_link_tentative+0xb4>
mov    -0x10(%rbp),%rdi
call   1060 <typ_is_tentative@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1070 <typ_is_generic_functor@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    11bb <typ_link_tentative+0x5b>
mov    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    11bb <typ_link_tentative+0x5b>
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    11db <typ_link_tentative+0x7b>
jmp    1214 <typ_link_tentative+0xb4>
mov    -0x8(%rbp),%rdi
call   1060 <typ_is_tentative@plt>
cmp    $0x0,%eax
jne    1203 <typ_link_tentative+0xa3>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
call   1040 <link_to_final@plt>
jmp    1214 <typ_link_tentative+0xb4>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
call   1080 <link_to_tentative@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typ_link_tentative>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <typ_is_ungenarg@plt>
test   %rax,%rax
je     117f <typ_link_tentative+0x1f>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
call   1060 <typ_is_tentative@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1070 <typ_is_generic_functor@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
cmp    %rbx,%r14
je     1177 <typ_link_tentative+0x17>
mov    %r14,%rdi
call   1060 <typ_is_tentative@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
test   %eax,%eax
je     11c8 <typ_link_tentative+0x68>
pop    %rbx
pop    %r14
jmp    1080 <link_to_tentative@plt>
pop    %rbx
pop    %r14
jmp    1040 <link_to_final@plt>

LLVM IR (-O0):
%struct.typ = type { i32 }
@.str = [33 x i8] c"use typ_link_tentative_functor()\00"
define void @typ_link_tentative(%struct.typ* %0, %struct.typ* %1) {
%3 = alloca %struct.typ*
%4 = alloca %struct.typ*
store %struct.typ* %0, %struct.typ** %3
store %struct.typ* %1, %struct.typ** %4
%5 = load %struct.typ*, %struct.typ** %4
%6 = call i64 @typ_is_ungenarg(%struct.typ* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
br label %37
9: ; preds = %2
%10 = load %struct.typ*, %struct.typ** %4
%11 = call i32 @typ_is_tentative(%struct.typ* %10)
%12 = call i32 @assert(i32 %11)
%13 = load %struct.typ*, %struct.typ** %4
%14 = call i32 @typ_is_generic_functor(%struct.typ* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %9
br label %17
17: ; preds = %16, %9
%18 = phi i1 [ false, %9 ], [ true, %16 ]
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load %struct.typ*, %struct.typ** %3
%22 = load %struct.typ*, %struct.typ** %4
%23 = icmp eq %struct.typ* %21, %22
br i1 %23, label %24, label %25
24: ; preds = %17
br label %37
25: ; preds = %17
%26 = load %struct.typ*, %struct.typ** %3
%27 = call i32 @typ_is_tentative(%struct.typ* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load %struct.typ*, %struct.typ** %3
%31 = load %struct.typ*, %struct.typ** %4
%32 = call i32 @link_to_final(i32* null, %struct.typ* %30, %struct.typ* %31)
br label %37
33: ; preds = %25
%34 = load %struct.typ*, %struct.typ** %3
%35 = load %struct.typ*, %struct.typ** %4
%36 = call i32 @link_to_tentative(i32* null, %struct.typ* %34, %struct.typ* %35)
br label %37
37: ; preds = %8, %24, %33, %29
ret void
}

LLVM IR (-O2):
%struct.typ = type { i32 }
define void @typ_link_tentative(%struct.typ* %0, %struct.typ* %1) {
%3 = tail call i64 @typ_is_ungenarg(%struct.typ* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2
%6 = tail call i32 @typ_is_tentative(%struct.typ* %1)
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @typ_is_generic_functor(%struct.typ* %1)
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp eq %struct.typ* %0, %1
br i1 %12, label %20, label %13
13: ; preds = %5
%14 = tail call i32 @typ_is_tentative(%struct.typ* %0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @link_to_final(i32* null, %struct.typ* %0, %struct.typ* %1)
br label %20
18: ; preds = %13
%19 = tail call i32 @link_to_tentative(i32* null, %struct.typ* %0, %struct.typ* %1)
br label %20
20: ; preds = %5, %2, %18, %16
ret void
}