#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 vertex {
  int dummy;
};
struct graph {
  int dummy;
};
struct edge {
  int dummy;
};

/* Variables and functions */
struct edge *graph_add_edge(struct graph *, struct vertex *, struct vertex *);
struct vertex *graph_make_vertex(struct graph *, int);
struct edge *graph_join(struct graph *g, int v1, int v2) {
  struct vertex *a = graph_make_vertex(g, v1);
  struct vertex *b = graph_make_vertex(g, v2);
  if (a != NULL && b != NULL) {
    return graph_add_edge(g, a, b);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<graph_join>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <graph_make_vertex@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <graph_make_vertex@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1182 <graph_join+0x62>
cmpq   $0x0,-0x28(%rbp)
je     1182 <graph_join+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <graph_add_edge@plt>
mov    %rax,-0x8(%rbp)
jmp    118a <graph_join+0x6a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<graph_join>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rdi,%rbx
call   1040 <graph_make_vertex@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <graph_make_vertex@plt>
test   %r14,%r14
je     1157 <graph_join+0x37>
test   %rax,%rax
je     1157 <graph_join+0x37>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <graph_add_edge@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.edge = type { i32 }
%struct.graph = type { i32 }
%struct.vertex = type { i32 }
define %struct.edge* @graph_join(%struct.graph* %0, i32 %1, i32 %2) {
%4 = alloca %struct.edge*
%5 = alloca %struct.graph*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.vertex*
%9 = alloca %struct.vertex*
store %struct.graph* %0, %struct.graph** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load %struct.graph*, %struct.graph** %5
%11 = load i32, i32* %6
%12 = call %struct.vertex* @graph_make_vertex(%struct.graph* %10, i32 %11)
store %struct.vertex* %12, %struct.vertex** %8
%13 = load %struct.graph*, %struct.graph** %5
%14 = load i32, i32* %7
%15 = call %struct.vertex* @graph_make_vertex(%struct.graph* %13, i32 %14)
store %struct.vertex* %15, %struct.vertex** %9
%16 = load %struct.vertex*, %struct.vertex** %8
%17 = icmp ne %struct.vertex* %16, null
br i1 %17, label %18, label %26
18: ; preds = %3
%19 = load %struct.vertex*, %struct.vertex** %9
%20 = icmp ne %struct.vertex* %19, null
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load %struct.graph*, %struct.graph** %5
%23 = load %struct.vertex*, %struct.vertex** %8
%24 = load %struct.vertex*, %struct.vertex** %9
%25 = call %struct.edge* @graph_add_edge(%struct.graph* %22, %struct.vertex* %23, %struct.vertex* %24)
store %struct.edge* %25, %struct.edge** %4
br label %27
26: ; preds = %18, %3
store %struct.edge* null, %struct.edge** %4
br label %27
27: ; preds = %26, %21
%28 = load %struct.edge*, %struct.edge** %4
ret %struct.edge* %28
}

LLVM IR (-O2):
%struct.edge = type { i32 }
%struct.graph = type { i32 }
%struct.vertex = type { i32 }
define %struct.edge* @graph_join(%struct.graph* %0, i32 %1, i32 %2) {
%4 = tail call %struct.vertex* @graph_make_vertex(%struct.graph* %0, i32 %1)
%5 = tail call %struct.vertex* @graph_make_vertex(%struct.graph* %0, i32 %2)
%6 = icmp ne %struct.vertex* %4, null
%7 = icmp ne %struct.vertex* %5, null
%8 = select i1 %6, i1 %7, i1 false
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call %struct.edge* @graph_add_edge(%struct.graph* %0, %struct.vertex* %4, %struct.vertex* %5)
br label %11
11: ; preds = %3, %9
%12 = phi %struct.edge* [ %10, %9 ], [ null, %3 ]
ret %struct.edge* %12
}