#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 __send_local(long, unsigned short, int, long, unsigned short);
int /*<<< orphan*/ create_message(int, unsigned short, long, unsigned short,
                                  int, long, unsigned short);
int /*<<< orphan*/ log_graph(int, unsigned short, unsigned short,
                             int /*<<< orphan*/);
int my_id();
unsigned short num_nodes();
int send_intheory(unsigned short, int /*<<< orphan*/);
int __send_to(unsigned short node, long ticket, unsigned short type, int slot,
              long value, unsigned short flags) {
  int n = node % (num_nodes());
  log_graph(my_id(), node, type, 0);
  if (n == my_id()) {
    return __send_local(ticket, type, slot, value, flags);
  }
  return send_intheory(
      node, create_message(my_id(), node, ticket, type, slot, value, flags));
}


x86 assembly (clang, -O0):
<__send_to>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r9w,%ax
mov    %di,-0x6(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %dx,-0x12(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %ax,-0x22(%rbp)
movzwl -0x6(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   1060 <num_nodes@plt>
mov    %ax,%cx
mov    -0x30(%rbp),%eax
movzwl %cx,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    $0x0,%al
call   1040 <my_id@plt>
mov    %eax,%edi
mov    -0x6(%rbp),%ax
xor    %ecx,%ecx
movzwl %ax,%esi
movzwl -0x12(%rbp),%edx
call   1080 <log_graph@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <my_id@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jne    11f9 <__send_to+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x12(%rbp),%ax
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
movzwl %ax,%esi
movzwl -0x22(%rbp),%r8d
call   1050 <__send_local@plt>
mov    %eax,-0x4(%rbp)
jmp    1241 <__send_to+0xe1>
mov    -0x6(%rbp),%ax
mov    %ax,-0x32(%rbp)
mov    $0x0,%al
call   1040 <my_id@plt>
mov    %eax,%edi
mov    -0x6(%rbp),%cx
mov    -0x10(%rbp),%rdx
mov    -0x12(%rbp),%ax
mov    -0x18(%rbp),%r8d
mov    -0x20(%rbp),%r9
movzwl %cx,%esi
movzwl %ax,%ecx
movzwl -0x22(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <create_message@plt>
mov    %eax,%esi
mov    -0x32(%rbp),%ax
movzwl %ax,%edi
call   1070 <send_intheory@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__send_to>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r13d
mov    %r8,0x10(%rsp)
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r12
mov    %edi,%ebx
xor    %eax,%eax
call   1060 <num_nodes@plt>
mov    %eax,%ecx
mov    %ebx,%eax
xor    %edx,%edx
div    %cx
movzwl %dx,%r14d
xor    %eax,%eax
call   1040 <my_id@plt>
mov    %eax,%edi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1080 <log_graph@plt>
xor    %eax,%eax
call   1040 <my_id@plt>
cmp    %r14d,%eax
jne    11d9 <__send_to+0x79>
movzwl %bp,%esi
movzwl %r13w,%r8d
mov    %r12,%rdi
mov    %r15d,%edx
mov    0x10(%rsp),%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <__send_local@plt>
xor    %eax,%eax
call   1040 <my_id@plt>
movzwl %r13w,%ecx
mov    %ecx,(%rsp)
movzwl %bx,%ebx
movzwl %bp,%ecx
mov    %eax,%edi
mov    %ebx,%esi
mov    %r12,%rdx
mov    %r15d,%r8d
mov    0x10(%rsp),%r9
call   1030 <create_message@plt>
mov    %ebx,%edi
mov    %eax,%esi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <send_intheory@plt>

LLVM IR (-O0):
define i32 @__send_to(i16 zeroext %0, i64 %1, i16 zeroext %2, i32 %3, i64 %4, i16 zeroext %5) {
%7 = alloca i32
%8 = alloca i16
%9 = alloca i64
%10 = alloca i16
%11 = alloca i32
%12 = alloca i64
%13 = alloca i16
%14 = alloca i32
store i16 %0, i16* %8
store i64 %1, i64* %9
store i16 %2, i16* %10
store i32 %3, i32* %11
store i64 %4, i64* %12
store i16 %5, i16* %13
%15 = load i16, i16* %8
%16 = zext i16 %15 to i32
%17 = call zeroext i16 (...) @num_nodes()
%18 = zext i16 %17 to i32
%19 = srem i32 %16, %18
store i32 %19, i32* %14
%20 = call i32 (...) @my_id()
%21 = load i16, i16* %8
%22 = load i16, i16* %10
%23 = call i32 @log_graph(i32 %20, i16 zeroext %21, i16 zeroext %22, i32 0)
%24 = load i32, i32* %14
%25 = call i32 (...) @my_id()
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %34
27: ; preds = %6
%28 = load i64, i64* %9
%29 = load i16, i16* %10
%30 = load i32, i32* %11
%31 = load i64, i64* %12
%32 = load i16, i16* %13
%33 = call i32 @__send_local(i64 %28, i16 zeroext %29, i32 %30, i64 %31, i16 zeroext %32)
store i32 %33, i32* %7
br label %45
34: ; preds = %6
%35 = load i16, i16* %8
%36 = call i32 (...) @my_id()
%37 = load i16, i16* %8
%38 = load i64, i64* %9
%39 = load i16, i16* %10
%40 = load i32, i32* %11
%41 = load i64, i64* %12
%42 = load i16, i16* %13
%43 = call i32 @create_message(i32 %36, i16 zeroext %37, i64 %38, i16 zeroext %39, i32 %40, i64 %41, i16 zeroext %42)
%44 = call i32 @send_intheory(i16 zeroext %35, i32 %43)
store i32 %44, i32* %7
br label %45
45: ; preds = %34, %27
%46 = load i32, i32* %7
ret i32 %46
}

LLVM IR (-O2):
define i32 @__send_to(i16 zeroext %0, i64 %1, i16 zeroext %2, i32 %3, i64 %4, i16 zeroext %5) {
%7 = tail call zeroext i16 (...) @num_nodes()
%8 = urem i16 %0, %7
%9 = zext i16 %8 to i32
%10 = tail call i32 (...) @my_id()
%11 = tail call i32 @log_graph(i32 %10, i16 zeroext %0, i16 zeroext %2, i32 0)
%12 = tail call i32 (...) @my_id()
%13 = icmp eq i32 %12, %9
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = tail call i32 @__send_local(i64 %1, i16 zeroext %2, i32 %3, i64 %4, i16 zeroext %5)
br label %20
16: ; preds = %6
%17 = tail call i32 (...) @my_id()
%18 = tail call i32 @create_message(i32 %17, i16 zeroext %0, i64 %1, i16 zeroext %2, i32 %3, i64 %4, i16 zeroext %5)
%19 = tail call i32 @send_intheory(i16 zeroext %0, i32 %18)
br label %20
20: ; preds = %16, %14
%21 = phi i32 [ %15, %14 ], [ %19, %16 ]
ret i32 %21
}