#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 */

/* Variables and functions */
int get_next_vertex(int, int *, int *);
int /*<<< orphan*/ printf(char *, int);
void test_next_vertex() {
  int i, next = 2;
  int distance[6], accepted[6];
  for (i = 0; i < 6; ++i) {
    distance[i] = 9999;
    accepted[i] = 0;
  }
  accepted[next] = 1;
  distance[next] = 0;
  distance[0] = 4;
  distance[3] = 22;
  printf("next was: %d", next);
  next = get_next_vertex(6, accepted, distance);
  printf("\nnow next is: %d\n", next);
}


x86 assembly (clang, -O0):
<test_next_vertex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x6,-0x4(%rbp)
jge    1166 <test_next_vertex+0x46>
movslq -0x4(%rbp),%rax
movl   $0x270f,-0x20(%rbp,%rax,4)
movslq -0x4(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1136 <test_next_vertex+0x16>
movslq -0x8(%rbp),%rax
movl   $0x1,-0x40(%rbp,%rax,4)
movslq -0x8(%rbp),%rax
movl   $0x0,-0x20(%rbp,%rax,4)
movl   $0x4,-0x20(%rbp)
movl   $0x16,-0x14(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x6,%edi
call   1030 <get_next_vertex@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_next_vertex>:
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
movabs $0x270f0000270f,%rax
mov    %rax,0x30(%rsp)
movl   $0x1,0x8(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xeb2(%rip),%rdi
mov    $0x2,%esi
call   1040 <printf@plt>
mov    %rsp,%rsi
lea    0x20(%rsp),%rdx
mov    $0x6,%edi
call   1030 <get_next_vertex@plt>
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"next was: %d\00"
@.str.1 = [18 x i8] c"\0Anow next is: %d\0A\00"
define void @test_next_vertex() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x i32]
%4 = alloca [6 x i32]
store i32 2, i32* %2
store i32 0, i32* %1
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 6
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %10
store i32 9999, i32* %11
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 %13
store i32 0, i32* %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %5
18: ; preds = %5
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 %20
store i32 1, i32* %21
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 %23
store i32 0, i32* %24
%25 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
store i32 4, i32* %25
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
store i32 22, i32* %26
%27 = load i32, i32* %2
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%30 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%31 = call i32 @get_next_vertex(i32 6, i32* %29, i32* %30)
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"next was: %d\00"
@.str.1 = [18 x i8] c"\0Anow next is: %d\0A\00"
define void @test_next_vertex() {
%1 = alloca [6 x i32]
%2 = alloca [6 x i32]
%3 = bitcast [6 x i32]* %2 to i8*
%4 = bitcast [6 x i32]* %1 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 4
store i32 9999, i32* %6
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 5
store i32 9999, i32* %7
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 2
store i32 1, i32* %8
%9 = bitcast [6 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 4, i32 9999, i32 0, i32 22>, <4 x i32>* %9
%10 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 2)
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%12 = call i32 @get_next_vertex(i32 6, i32* %11, i32* %5)
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret void
}