#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 /*<<< orphan*/ first_v1(int **, int, int *, int *);
int get_label_edge(int *);
int /*<<< orphan*/ next_v1(int **, int, int *, int *);
int calc_local_earliest_times(int *g[3], int es[][3], int vs[][(4 + 2)],
                              int vid) {
  int v1 = 0;
  int eid = 0;
  int max = 0;
  int tmp = 0;
  first_v1(g, vid, &v1, &eid);
  while (v1 != (-1)) {
    if (v1 == vid) {
      next_v1(g, vid, &v1, &eid);
    } else {
      tmp = vs[v1][4] + get_label_edge(es[eid]);
      if (tmp > max) {
        max = tmp;
      }
      next_v1(g, vid, &v1, &eid);
    }
  }
  return max;
}


x86 assembly (clang, -O0):
<calc_local_earliest_times>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1040 <first_v1@plt>
cmpl   $0xffffffff,-0x20(%rbp)
je     1204 <calc_local_earliest_times+0xd4>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11a6 <calc_local_earliest_times+0x76>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1050 <next_v1@plt>
jmp    11ff <calc_local_earliest_times+0xcf>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x10(%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
imul   $0xc,%rax,%rax
add    %rax,%rdi
call   1030 <get_label_edge@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    11eb <calc_local_earliest_times+0xbb>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1050 <next_v1@plt>
jmp    1177 <calc_local_earliest_times+0x47>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_local_earliest_times>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebx
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%r12
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
mov    %ebx,%esi
call   1040 <first_v1@plt>
mov    (%rsp),%eax
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
je     11cd <calc_local_earliest_times+0x9d>
mov    %rsp,%r13
lea    0x4(%rsp),%r14
jmp    1198 <calc_local_earliest_times+0x68>
nop
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %r14,%rcx
call   1050 <next_v1@plt>
mov    (%rsp),%eax
cmp    $0xffffffff,%eax
je     11cd <calc_local_earliest_times+0x9d>
cmp    %ebx,%eax
je     1180 <calc_local_earliest_times+0x50>
cltq
lea    (%rax,%rax,2),%rax
mov    0x10(%rsp),%rcx
mov    0x10(%rcx,%rax,8),%r15d
movslq 0x4(%rsp),%rax
lea    (%rax,%rax,2),%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,4),%rdi
call   1030 <get_label_edge@plt>
add    %r15d,%eax
cmp    %ebp,%eax
cmovg  %eax,%ebp
jmp    1180 <calc_local_earliest_times+0x50>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @calc_local_earliest_times(i32** %0, [3 x i32]* %1, [6 x i32]* %2, i32 %3) {
%5 = alloca i32**
%6 = alloca [3 x i32]*
%7 = alloca [6 x i32]*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32** %0, i32*** %5
store [3 x i32]* %1, [3 x i32]** %6
store [6 x i32]* %2, [6 x i32]** %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load i32**, i32*** %5
%14 = load i32, i32* %8
%15 = call i32 @first_v1(i32** %13, i32 %14, i32* %9, i32* %10)
br label %16
16: ; preds = %50, %4
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %51
19: ; preds = %16
%20 = load i32, i32* %9
%21 = load i32, i32* %8
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i32**, i32*** %5
%25 = load i32, i32* %8
%26 = call i32 @next_v1(i32** %24, i32 %25, i32* %9, i32* %10)
br label %50
27: ; preds = %19
%28 = load [6 x i32]*, [6 x i32]** %7
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [6 x i32], [6 x i32]* %28, i64 %30
%32 = getelementptr inbounds [6 x i32], [6 x i32]* %31, i64 0, i64 4
%33 = load i32, i32* %32
%34 = load [3 x i32]*, [3 x i32]** %6
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %34, i64 %36
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %37, i64 0, i64 0
%39 = call i32 @get_label_edge(i32* %38)
%40 = add nsw i32 %33, %39
store i32 %40, i32* %12
%41 = load i32, i32* %12
%42 = load i32, i32* %11
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %46
44: ; preds = %27
%45 = load i32, i32* %12
store i32 %45, i32* %11
br label %46
46: ; preds = %44, %27
%47 = load i32**, i32*** %5
%48 = load i32, i32* %8
%49 = call i32 @next_v1(i32** %47, i32 %48, i32* %9, i32* %10)
br label %50
50: ; preds = %46, %23
br label %16
51: ; preds = %16
%52 = load i32, i32* %11
ret i32 %52
}

LLVM IR (-O2):
define i32 @calc_local_earliest_times(i32** %0, [3 x i32]* %1, [6 x i32]* nocapture %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%8 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%9 = call i32 @first_v1(i32** %0, i32 %3, i32* %5, i32* %6)
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, -1
br i1 %11, label %32, label %12
12: ; preds = %4, %27
%13 = phi i32 [ %30, %27 ], [ %10, %4 ]
%14 = phi i32 [ %28, %27 ], [ 0, %4 ]
%15 = icmp eq i32 %13, %3
br i1 %15, label %27, label %16
16: ; preds = %12
%17 = sext i32 %13 to i64
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 %17, i64 4
%19 = load i32, i32* %18
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 %21, i64 0
%23 = call i32 @get_label_edge(i32* %22)
%24 = add nsw i32 %23, %19
%25 = icmp sgt i32 %24, %14
%26 = select i1 %25, i32 %24, i32 %14
br label %27
27: ; preds = %12, %16
%28 = phi i32 [ %26, %16 ], [ %14, %12 ]
%29 = call i32 @next_v1(i32** %0, i32 %3, i32* %5, i32* %6)
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %12
32: ; preds = %27, %4
%33 = phi i32 [ 0, %4 ], [ %28, %27 ]
ret i32 %33
}