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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
struct node *definition(struct typ *);
int /*<<< orphan*/ do_instances_add(struct module *, struct node *,
                                    struct typ **, int /*<<< orphan*/);
int /*<<< orphan*/ typ_is_tentative(struct typ *);
void instances_add(struct module *mod, struct typ *genf,
                   struct typ **instance) {
  assert(mod != NULL || !typ_is_tentative(*instance));
  struct node *gendef = definition(genf);
  do_instances_add(mod, gendef, instance, 0);
}


x86 assembly (clang, -O0):
<instances_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x1,%al
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x21(%rbp)
jne    117b <instances_add+0x3b>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1050 <typ_is_tentative@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <definition@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %ecx,%ecx
call   1060 <do_instances_add@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<instances_add>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x1,%edi
test   %rbx,%rbx
jne    1168 <instances_add+0x28>
mov    (%r14),%rdi
call   1050 <typ_is_tentative@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    %r15,%rdi
call   1030 <definition@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <do_instances_add@plt>

LLVM IR (-O0):
%struct.module = type { i32 }
%struct.typ = type { i32 }
%struct.node = type { i32 }
define void @instances_add(%struct.module* %0, %struct.typ* %1, %struct.typ** %2) {
%4 = alloca %struct.module*
%5 = alloca %struct.typ*
%6 = alloca %struct.typ**
%7 = alloca %struct.node*
store %struct.module* %0, %struct.module** %4
store %struct.typ* %1, %struct.typ** %5
store %struct.typ** %2, %struct.typ*** %6
%8 = load %struct.module*, %struct.module** %4
%9 = icmp ne %struct.module* %8, null
br i1 %9, label %16, label %10
10: ; preds = %3
%11 = load %struct.typ**, %struct.typ*** %6
%12 = load %struct.typ*, %struct.typ** %11
%13 = call i32 @typ_is_tentative(%struct.typ* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br label %16
16: ; preds = %10, %3
%17 = phi i1 [ true, %3 ], [ %15, %10 ]
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load %struct.typ*, %struct.typ** %5
%21 = call %struct.node* @definition(%struct.typ* %20)
store %struct.node* %21, %struct.node** %7
%22 = load %struct.module*, %struct.module** %4
%23 = load %struct.node*, %struct.node** %7
%24 = load %struct.typ**, %struct.typ*** %6
%25 = call i32 @do_instances_add(%struct.module* %22, %struct.node* %23, %struct.typ** %24, i32 0)
ret void
}

LLVM IR (-O2):
%struct.module = type { i32 }
%struct.typ = type { i32 }
%struct.node = type { i32 }
define void @instances_add(%struct.module* %0, %struct.typ* %1, %struct.typ** %2) {
%4 = icmp eq %struct.module* %0, null
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = load %struct.typ*, %struct.typ** %2
%7 = tail call i32 @typ_is_tentative(%struct.typ* %6)
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %5, %3
%11 = phi i32 [ 1, %3 ], [ %9, %5 ]
%12 = tail call i32 @assert(i32 %11)
%13 = tail call %struct.node* @definition(%struct.typ* %1)
%14 = tail call i32 @do_instances_add(%struct.module* %0, %struct.node* %13, %struct.typ** %2, i32 0)
ret void
}