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

/* Variables and functions */
struct virtual_machine_object *
virtual_machine_object_type_from_object(struct virtual_machine *,
                                        struct virtual_machine_object const *);
int virtual_machine_object_type(
    struct virtual_machine *vm, struct virtual_machine_object **object_out,
    const struct virtual_machine_object *object_src) {
  int ret = 0;
  struct virtual_machine_object *new_object = NULL;
  if ((new_object = virtual_machine_object_type_from_object(vm, object_src)) ==
      NULL) {
    goto fail;
  }
  *object_out = new_object;
  goto done;
fail:
  *object_out = NULL;
done:
  return ret;
}


x86 assembly (clang, -O0):
<virtual_machine_object_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <virtual_machine_object_type_from_object@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1153 <virtual_machine_object_type+0x43>
jmp    1163 <virtual_machine_object_type+0x53>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    116e <virtual_machine_object_type+0x5e>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<virtual_machine_object_type>:
push   %rbx
mov    %rsi,%rbx
mov    %rdx,%rsi
call   1030 <virtual_machine_object_type_from_object@plt>
mov    %rax,(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.virtual_machine = type { i32 }
%struct.virtual_machine_object = type { i32 }
define i32 @virtual_machine_object_type(%struct.virtual_machine* %0, %struct.virtual_machine_object** %1, %struct.virtual_machine_object* %2) {
%4 = alloca %struct.virtual_machine*
%5 = alloca %struct.virtual_machine_object**
%6 = alloca %struct.virtual_machine_object*
%7 = alloca i32
%8 = alloca %struct.virtual_machine_object*
store %struct.virtual_machine* %0, %struct.virtual_machine** %4
store %struct.virtual_machine_object** %1, %struct.virtual_machine_object*** %5
store %struct.virtual_machine_object* %2, %struct.virtual_machine_object** %6
store i32 0, i32* %7
store %struct.virtual_machine_object* null, %struct.virtual_machine_object** %8
%9 = load %struct.virtual_machine*, %struct.virtual_machine** %4
%10 = load %struct.virtual_machine_object*, %struct.virtual_machine_object** %6
%11 = call %struct.virtual_machine_object* @virtual_machine_object_type_from_object(%struct.virtual_machine* %9, %struct.virtual_machine_object* %10)
store %struct.virtual_machine_object* %11, %struct.virtual_machine_object** %8
%12 = icmp eq %struct.virtual_machine_object* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
br label %17
14: ; preds = %3
%15 = load %struct.virtual_machine_object*, %struct.virtual_machine_object** %8
%16 = load %struct.virtual_machine_object**, %struct.virtual_machine_object*** %5
store %struct.virtual_machine_object* %15, %struct.virtual_machine_object** %16
br label %19
17: ; preds = %13
%18 = load %struct.virtual_machine_object**, %struct.virtual_machine_object*** %5
store %struct.virtual_machine_object* null, %struct.virtual_machine_object** %18
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* %7
ret i32 %20
}

LLVM IR (-O2):
%struct.virtual_machine = type { i32 }
%struct.virtual_machine_object = type { i32 }
define i32 @virtual_machine_object_type(%struct.virtual_machine* %0, %struct.virtual_machine_object** nocapture writeonly %1, %struct.virtual_machine_object* %2) {
%4 = tail call %struct.virtual_machine_object* @virtual_machine_object_type_from_object(%struct.virtual_machine* %0, %struct.virtual_machine_object* %2)
store %struct.virtual_machine_object* %4, %struct.virtual_machine_object** %1
ret i32 0
}