#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 */
scalar_t__ is_actually_still_tentative(struct typ *);
int /*<<< orphan*/ schedule_finalization(struct typ *);
scalar_t__ typ_is_tentative(struct typ *);
scalar_t__ typ_was_zeroed(struct typ *);
void link_finalize(struct typ *user) {
  if (typ_was_zeroed(user)) {
    return;
  }
  if (typ_is_tentative(user) && is_actually_still_tentative(user)) {
    return;
  }
  schedule_finalization(user);
}


x86 assembly (clang, -O0):
<link_finalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <typ_was_zeroed@plt>
cmp    $0x0,%rax
je     1164 <link_finalize+0x24>
jmp    1198 <link_finalize+0x58>
mov    -0x8(%rbp),%rdi
call   1050 <typ_is_tentative@plt>
cmp    $0x0,%rax
je     118f <link_finalize+0x4f>
mov    -0x8(%rbp),%rdi
call   1040 <is_actually_still_tentative@plt>
cmp    $0x0,%rax
je     118f <link_finalize+0x4f>
jmp    1198 <link_finalize+0x58>
mov    -0x8(%rbp),%rdi
call   1030 <schedule_finalization@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<link_finalize>:
push   %rbx
mov    %rdi,%rbx
call   1060 <typ_was_zeroed@plt>
test   %rax,%rax
je     1150 <link_finalize+0x10>
pop    %rbx
ret
mov    %rbx,%rdi
call   1050 <typ_is_tentative@plt>
test   %rax,%rax
je     116a <link_finalize+0x2a>
mov    %rbx,%rdi
call   1040 <is_actually_still_tentative@plt>
test   %rax,%rax
jne    114e <link_finalize+0xe>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <schedule_finalization@plt>

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

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