#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 joint_probability {
  int dummy;
};
struct belief {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ send_message_for_edge(struct belief *, unsigned int,
                                         struct joint_probability *,
                                         struct belief *);
void send_message_for_node(unsigned int *src_node_to_edges_nodes,
                           unsigned int *src_node_to_edges_edges,
                           struct belief *message_buffer,
                           unsigned int num_edges,
                           struct joint_probability *joint_probabilities,
                           struct belief *edge_messages,
                           unsigned int num_vertices, int i) {
  unsigned int start_index, end_index, j, edge_index;
  start_index = src_node_to_edges_nodes[i];
  if (i + 1 >= num_vertices) {
    end_index = num_edges;
  } else {
    end_index = src_node_to_edges_nodes[i + 1];
  }
  for (j = start_index; j < end_index; ++j) {
    edge_index = src_node_to_edges_edges[j];
    send_message_for_edge(message_buffer, edge_index, joint_probabilities,
                          edge_messages);
  }
}


x86 assembly (clang, -O0):
<send_message_for_node>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq 0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x34(%rbp)
mov    0x18(%rbp),%eax
add    $0x1,%eax
cmp    0x10(%rbp),%eax
jb     115d <send_message_for_node+0x4d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1170 <send_message_for_node+0x60>
mov    -0x8(%rbp),%rax
mov    0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jae    11b1 <send_message_for_node+0xa1>
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1030 <send_message_for_edge@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1176 <send_message_for_node+0x66>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_message_for_node>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r15
mov    %rdx,%r12
mov    %rsi,%r13
movslq 0x48(%rsp),%rax
mov    (%rdi,%rax,4),%ebx
add    $0x1,%eax
cmp    0x40(%rsp),%eax
jae    113d <send_message_for_node+0x2d>
cltq
mov    (%rdi,%rax,4),%ecx
cmp    %ecx,%ebx
jae    116b <send_message_for_node+0x5b>
mov    %ecx,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,4),%esi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <send_message_for_edge@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1150 <send_message_for_node+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.joint_probability = type { i32 }
%struct.belief = type { i32 }
define void @send_message_for_node(i32* %0, i32* %1, %struct.belief* %2, i32 %3, %struct.joint_probability* %4, %struct.belief* %5, i32 %6, i32 %7) {
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca %struct.belief*
%12 = alloca i32
%13 = alloca %struct.joint_probability*
%14 = alloca %struct.belief*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32* %0, i32** %9
store i32* %1, i32** %10
store %struct.belief* %2, %struct.belief** %11
store i32 %3, i32* %12
store %struct.joint_probability* %4, %struct.joint_probability** %13
store %struct.belief* %5, %struct.belief** %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%21 = load i32*, i32** %9
%22 = load i32, i32* %16
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
store i32 %25, i32* %17
%26 = load i32, i32* %16
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %15
%29 = icmp uge i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %8
%31 = load i32, i32* %12
store i32 %31, i32* %18
br label %39
32: ; preds = %8
%33 = load i32*, i32** %9
%34 = load i32, i32* %16
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %33, i64 %36
%38 = load i32, i32* %37
store i32 %38, i32* %18
br label %39
39: ; preds = %32, %30
%40 = load i32, i32* %17
store i32 %40, i32* %19
br label %41
41: ; preds = %56, %39
%42 = load i32, i32* %19
%43 = load i32, i32* %18
%44 = icmp ult i32 %42, %43
br i1 %44, label %45, label %59
45: ; preds = %41
%46 = load i32*, i32** %10
%47 = load i32, i32* %19
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
store i32 %50, i32* %20
%51 = load %struct.belief*, %struct.belief** %11
%52 = load i32, i32* %20
%53 = load %struct.joint_probability*, %struct.joint_probability** %13
%54 = load %struct.belief*, %struct.belief** %14
%55 = call i32 @send_message_for_edge(%struct.belief* %51, i32 %52, %struct.joint_probability* %53, %struct.belief* %54)
br label %56
56: ; preds = %45
%57 = load i32, i32* %19
%58 = add i32 %57, 1
store i32 %58, i32* %19
br label %41
59: ; preds = %41
ret void
}

LLVM IR (-O2):
%struct.joint_probability = type { i32 }
%struct.belief = type { i32 }
define void @send_message_for_node(i32* nocapture %0, i32* nocapture %1, %struct.belief* %2, i32 %3, %struct.joint_probability* %4, %struct.belief* %5, i32 %6, i32 %7) {
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = add nsw i32 %7, 1
%13 = icmp ult i32 %12, %6
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
br label %18
18: ; preds = %8, %14
%19 = phi i32 [ %17, %14 ], [ %3, %8 ]
%20 = icmp ult i32 %11, %19
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = zext i32 %11 to i64
br label %23
23: ; preds = %21, %23
%24 = phi i64 [ %22, %21 ], [ %28, %23 ]
%25 = getelementptr inbounds i32, i32* %1, i64 %24
%26 = load i32, i32* %25
%27 = tail call i32 @send_message_for_edge(%struct.belief* %2, i32 %26, %struct.joint_probability* %4, %struct.belief* %5)
%28 = add nuw nsw i64 %24, 1
%29 = trunc i64 %28 to i32
%30 = icmp eq i32 %19, %29
br i1 %30, label %31, label %23
31: ; preds = %23, %18
ret void
}