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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ tit_next(struct tit *);
struct typ *tit_typ(struct tit *);
int /*<<< orphan*/ trigger_mod_for(struct typ *);
struct tit *typ_definition_parent(struct typ *);
scalar_t__ typ_is_generic_functor(struct typ *);
int /*<<< orphan*/ typ_is_tentative(struct typ *);
scalar_t__ typ_was_zeroed(struct typ *);
int /*<<< orphan*/ unify_with_new_parent(int /*<<< orphan*/,
                                         int /*<<< orphan*/ *, struct typ *,
                                         struct typ *);
void link_parent_update(struct typ *user, struct typ *dst, struct typ *src) {
  if (typ_was_zeroed(user)) {
    return;
  }
  if (typ_is_generic_functor(user)) {
    return;
  }
  assert(typ_is_tentative(user));
  struct tit *par = typ_definition_parent(user);
  if (tit_typ(par) == src) {
    unify_with_new_parent(trigger_mod_for(user), NULL, dst, user);
  }
  tit_next(par);
}


x86 assembly (clang, -O0):
<link_parent_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <typ_was_zeroed@plt>
cmp    $0x0,%rax
je     11bc <link_parent_update+0x2c>
jmp    1229 <link_parent_update+0x99>
mov    -0x8(%rbp),%rdi
call   1070 <typ_is_generic_functor@plt>
cmp    $0x0,%rax
je     11d4 <link_parent_update+0x44>
jmp    1229 <link_parent_update+0x99>
mov    -0x8(%rbp),%rdi
call   1060 <typ_is_tentative@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   10b0 <typ_definition_parent@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <tit_typ@plt>
cmp    -0x18(%rbp),%rax
jne    1220 <link_parent_update+0x90>
mov    -0x8(%rbp),%rdi
call   1090 <trigger_mod_for@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <unify_with_new_parent@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <tit_next@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<link_parent_update>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1080 <typ_was_zeroed@plt>
test   %rax,%rax
jne    11b8 <link_parent_update+0x28>
mov    %rbx,%rdi
call   1070 <typ_is_generic_functor@plt>
test   %rax,%rax
je     11c4 <link_parent_update+0x34>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1060 <typ_is_tentative@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    %rbx,%rdi
call   10b0 <typ_definition_parent@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1030 <tit_typ@plt>
cmp    %r15,%rax
jne    1202 <link_parent_update+0x72>
mov    %rbx,%rdi
call   1090 <trigger_mod_for@plt>
mov    %eax,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <unify_with_new_parent@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    10a0 <tit_next@plt>

LLVM IR (-O0):
%struct.typ = type { i32 }
%struct.tit = type { i32 }
define void @link_parent_update(%struct.typ* %0, %struct.typ* %1, %struct.typ* %2) {
%4 = alloca %struct.typ*
%5 = alloca %struct.typ*
%6 = alloca %struct.typ*
%7 = alloca %struct.tit*
store %struct.typ* %0, %struct.typ** %4
store %struct.typ* %1, %struct.typ** %5
store %struct.typ* %2, %struct.typ** %6
%8 = load %struct.typ*, %struct.typ** %4
%9 = call i64 @typ_was_zeroed(%struct.typ* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
br label %36
12: ; preds = %3
%13 = load %struct.typ*, %struct.typ** %4
%14 = call i64 @typ_is_generic_functor(%struct.typ* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %36
17: ; preds = %12
%18 = load %struct.typ*, %struct.typ** %4
%19 = call i32 @typ_is_tentative(%struct.typ* %18)
%20 = call i32 @assert(i32 %19)
%21 = load %struct.typ*, %struct.typ** %4
%22 = call %struct.tit* @typ_definition_parent(%struct.typ* %21)
store %struct.tit* %22, %struct.tit** %7
%23 = load %struct.tit*, %struct.tit** %7
%24 = call %struct.typ* @tit_typ(%struct.tit* %23)
%25 = load %struct.typ*, %struct.typ** %6
%26 = icmp eq %struct.typ* %24, %25
br i1 %26, label %27, label %33
27: ; preds = %17
%28 = load %struct.typ*, %struct.typ** %4
%29 = call i32 @trigger_mod_for(%struct.typ* %28)
%30 = load %struct.typ*, %struct.typ** %5
%31 = load %struct.typ*, %struct.typ** %4
%32 = call i32 @unify_with_new_parent(i32 %29, i32* null, %struct.typ* %30, %struct.typ* %31)
br label %33
33: ; preds = %27, %17
%34 = load %struct.tit*, %struct.tit** %7
%35 = call i32 @tit_next(%struct.tit* %34)
br label %36
36: ; preds = %33, %16, %11
ret void
}

LLVM IR (-O2):
%struct.typ = type { i32 }
%struct.tit = type { i32 }
define void @link_parent_update(%struct.typ* %0, %struct.typ* %1, %struct.typ* readnone %2) {
%4 = tail call i64 @typ_was_zeroed(%struct.typ* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = tail call i64 @typ_is_generic_functor(%struct.typ* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = tail call i32 @typ_is_tentative(%struct.typ* %0)
%11 = tail call i32 @assert(i32 %10)
%12 = tail call %struct.tit* @typ_definition_parent(%struct.typ* %0)
%13 = tail call %struct.typ* @tit_typ(%struct.tit* %12)
%14 = icmp eq %struct.typ* %13, %2
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = tail call i32 @trigger_mod_for(%struct.typ* %0)
%17 = tail call i32 @unify_with_new_parent(i32 %16, i32* null, %struct.typ* %1, %struct.typ* %0)
br label %18
18: ; preds = %15, %9
%19 = tail call i32 @tit_next(%struct.tit* %12)
br label %20
20: ; preds = %6, %3, %18
ret void
}