#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*/ comm_rec(int, unsigned long *, int);
int /*<<< orphan*/ comm_sen(int, unsigned long, int /*<<< orphan*/);
int CommTestOthers(void) {
  unsigned long i_mesg, o_mesg;
  int out_port;
  int i = 0;
  do {
    i = 0;
    while (!comm_rec(i, &i_mesg, 10))
      if (++i == 6)
        i = 0;
    out_port = i_mesg & 0x7;
    if (out_port == 7)
      return (1);
    o_mesg = i_mesg >> 3;
    comm_sen(out_port, o_mesg, 0);
    comm_rec(i, &i_mesg, 0);
    o_mesg = i_mesg;
    comm_sen(out_port, o_mesg, 0);
  } while (out_port != 7);
  return (1);
}


x86 assembly (clang, -O0):
<CommTestOthers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1030 <comm_rec@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115c <CommTestOthers+0x3c>
jmp    117a <CommTestOthers+0x5a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x6,%eax
jne    1175 <CommTestOthers+0x55>
movl   $0x0,-0x20(%rbp)
jmp    1136 <CommTestOthers+0x16>
mov    -0x10(%rbp),%rax
and    $0x7,%rax
mov    %eax,-0x1c(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jne    119b <CommTestOthers+0x7b>
movl   $0x1,-0x4(%rbp)
jmp    11ea <CommTestOthers+0xca>
mov    -0x10(%rbp),%rax
shr    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <comm_sen@plt>
mov    -0x20(%rbp),%edi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <comm_rec@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <comm_sen@plt>
cmpl   $0x7,-0x1c(%rbp)
jne    112f <CommTestOthers+0xf>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CommTestOthers>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsp,%r14
xor    %r15d,%r15d
nopl   (%rax)
xor    %edi,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <comm_rec@plt>
mov    $0x0,%ebp
test   %eax,%eax
jne    116d <CommTestOthers+0x4d>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x6,%ebp
cmove  %r15d,%ebp
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <comm_rec@plt>
test   %eax,%eax
je     1150 <CommTestOthers+0x30>
mov    (%rsp),%rsi
mov    %esi,%ebx
and    $0x7,%ebx
cmp    $0x7,%ebx
je     11a3 <CommTestOthers+0x83>
shr    $0x3,%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1040 <comm_sen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <comm_rec@plt>
mov    (%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1040 <comm_sen@plt>
jmp    1130 <CommTestOthers+0x10>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @CommTestOthers() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %5
br label %6
6: ; preds = %37, %0
store i32 0, i32* %5
br label %7
7: ; preds = %17, %6
%8 = load i32, i32* %5
%9 = call i32 @comm_rec(i32 %8, i64* %2, i32 10)
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
store i32 %14, i32* %5
%15 = icmp eq i32 %14, 6
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 0, i32* %5
br label %17
17: ; preds = %16, %12
br label %7
18: ; preds = %7
%19 = load i64, i64* %2
%20 = and i64 %19, 7
%21 = trunc i64 %20 to i32
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 7
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 1, i32* %1
br label %41
25: ; preds = %18
%26 = load i64, i64* %2
%27 = lshr i64 %26, 3
store i64 %27, i64* %3
%28 = load i32, i32* %4
%29 = load i64, i64* %3
%30 = call i32 @comm_sen(i32 %28, i64 %29, i32 0)
%31 = load i32, i32* %5
%32 = call i32 @comm_rec(i32 %31, i64* %2, i32 0)
%33 = load i64, i64* %2
store i64 %33, i64* %3
%34 = load i32, i32* %4
%35 = load i64, i64* %3
%36 = call i32 @comm_sen(i32 %34, i64 %35, i32 0)
br label %37
37: ; preds = %25
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 7
br i1 %39, label %6, label %40
40: ; preds = %37
store i32 1, i32* %1
br label %41
41: ; preds = %40, %24
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
define i32 @CommTestOthers() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
br label %3
3: ; preds = %19, %0
%4 = call i32 @comm_rec(i32 0, i64* %1, i32 10)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3, %6
%7 = phi i32 [ %10, %6 ], [ 0, %3 ]
%8 = add nsw i32 %7, 1
%9 = icmp eq i32 %8, 6
%10 = select i1 %9, i32 0, i32 %8
%11 = call i32 @comm_rec(i32 %10, i64* %1, i32 10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %6, label %13
13: ; preds = %6, %3
%14 = phi i32 [ 0, %3 ], [ %10, %6 ]
%15 = load i64, i64* %1
%16 = trunc i64 %15 to i32
%17 = and i32 %16, 7
%18 = icmp eq i32 %17, 7
br i1 %18, label %25, label %19
19: ; preds = %13
%20 = lshr i64 %15, 3
%21 = call i32 @comm_sen(i32 %17, i64 %20, i32 0)
%22 = call i32 @comm_rec(i32 %14, i64* %1, i32 0)
%23 = load i64, i64* %1
%24 = call i32 @comm_sen(i32 %17, i64 %23, i32 0)
br label %3
25: ; preds = %13
ret i32 1
}