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

/* Variables and functions */
int get_random_vertex();
int /*<<< orphan*/ initialze_random_array(int, int);
int /*<<< orphan*/ link_creation(struct Graph *, int, int);
int /*<<< orphan*/ printf(char *);
void generate_path(struct Graph *graph, int source_index, int target_index) {
  printf("...Generating Path...\n");
  int i, v, j;
  initialze_random_array(source_index, target_index);
  int vertex_index = source_index, random_vertex_index;
  while ((random_vertex_index = get_random_vertex()) != -1) {
    link_creation(graph, vertex_index, random_vertex_index);
    vertex_index = random_vertex_index;
  }
  link_creation(graph, vertex_index, target_index);
}


x86 assembly (clang, -O0):
<generate_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <initialze_random_array@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1050 <get_random_vertex@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     119c <generate_path+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1060 <link_creation@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    116f <generate_path+0x2f>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <link_creation@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_path>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%r15
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    %r14d,%esi
call   1040 <initialze_random_array@plt>
xor    %eax,%eax
call   1050 <get_random_vertex@plt>
cmp    $0xffffffff,%eax
je     119e <generate_path+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1060 <link_creation@plt>
xor    %eax,%eax
call   1050 <get_random_vertex@plt>
mov    %ebp,%ebx
cmp    $0xffffffff,%eax
jne    1180 <generate_path+0x40>
jmp    11a0 <generate_path+0x60>
mov    %ebx,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <link_creation@plt>

LLVM IR (-O0):
%struct.Graph = type { i32 }
@.str = [23 x i8] c"...Generating Path...\0A\00"
define void @generate_path(%struct.Graph* %0, i32 %1, i32 %2) {
%4 = alloca %struct.Graph*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.Graph* %0, %struct.Graph** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = call i32 @initialze_random_array(i32 %13, i32 %14)
%16 = load i32, i32* %5
store i32 %16, i32* %10
br label %17
17: ; preds = %20, %3
%18 = call i32 (...) @get_random_vertex()
store i32 %18, i32* %11
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load %struct.Graph*, %struct.Graph** %4
%22 = load i32, i32* %10
%23 = load i32, i32* %11
%24 = call i32 @link_creation(%struct.Graph* %21, i32 %22, i32 %23)
%25 = load i32, i32* %11
store i32 %25, i32* %10
br label %17
26: ; preds = %17
%27 = load %struct.Graph*, %struct.Graph** %4
%28 = load i32, i32* %10
%29 = load i32, i32* %6
%30 = call i32 @link_creation(%struct.Graph* %27, i32 %28, i32 %29)
ret void
}

LLVM IR (-O2):
%struct.Graph = type { i32 }
@str = [22 x i8] c"...Generating Path...\00"
define void @generate_path(%struct.Graph* %0, i32 %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @initialze_random_array(i32 %1, i32 %2)
%6 = tail call i32 (...) @get_random_vertex()
%7 = icmp eq i32 %6, -1
br i1 %7, label %14, label %8
8: ; preds = %3, %8
%9 = phi i32 [ %12, %8 ], [ %6, %3 ]
%10 = phi i32 [ %9, %8 ], [ %1, %3 ]
%11 = tail call i32 @link_creation(%struct.Graph* %0, i32 %10, i32 %9)
%12 = tail call i32 (...) @get_random_vertex()
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %8
14: ; preds = %8, %3
%15 = phi i32 [ %1, %3 ], [ %9, %8 ]
%16 = tail call i32 @link_creation(%struct.Graph* %0, i32 %15, i32 %2)
ret void
}