#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*/ crashme(int /*<<< orphan*/ *);
int netd_getMyID();
int netd_getSize();
int /*<<< orphan*/ netd_recvdat(int, char *, int);
int /*<<< orphan*/ netd_senddat(int, char *, int);
void worker() {
  int done;
  int my_id, from, to, size;
  char msg[200];
  my_id = netd_getMyID();
  size = netd_getSize();
  if (my_id == (size - 1))
    to = 0;
  else
    to = my_id + 1;
  from = my_id - 1;
  crashme(NULL);
  done = 0;
  while (!done) {
    netd_recvdat(from, msg, 200);
    if (msg[0] == '\1')
      done = 1;
    netd_senddat(to, msg, 200);
  }
}


x86 assembly (clang, -O0):
<worker>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    $0x0,%al
call   1060 <netd_getMyID@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <netd_getSize@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    118c <worker+0x3c>
movl   $0x0,-0x10(%rbp)
jmp    1195 <worker+0x45>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <crashme@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c4 <worker+0x74>
jmp    1208 <worker+0xb8>
mov    -0xc(%rbp),%edi
lea    -0xe0(%rbp),%rsi
mov    $0xc8,%edx
call   1040 <netd_recvdat@plt>
movsbl -0xe0(%rbp),%eax
cmp    $0x1,%eax
jne    11ef <worker+0x9f>
movl   $0x1,-0x4(%rbp)
mov    -0x10(%rbp),%edi
lea    -0xe0(%rbp),%rsi
mov    $0xc8,%edx
call   1050 <netd_senddat@plt>
jmp    11ae <worker+0x5e>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<worker>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc8,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <netd_getMyID@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1070 <netd_getSize@plt>
add    $0xffffffff,%eax
lea    0x1(%r14),%r15d
cmp    %eax,%r14d
cmove  %ebx,%r15d
add    $0xffffffff,%r14d
xor    %edi,%edi
call   1030 <crashme@plt>
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0xc8,%edx
call   1040 <netd_recvdat@plt>
movzbl (%rsp),%ebx
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0xc8,%edx
call   1050 <netd_senddat@plt>
cmp    $0x1,%bl
jne    1190 <worker+0x40>
add    $0xc8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @worker() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [200 x i8]
%7 = call i32 (...) @netd_getMyID()
store i32 %7, i32* %2
%8 = call i32 (...) @netd_getSize()
store i32 %8, i32* %5
%9 = load i32, i32* %2
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 1
%12 = icmp eq i32 %9, %11
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 0, i32* %4
br label %17
14: ; preds = %0
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %17
17: ; preds = %14, %13
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %3
%20 = call i32 @crashme(i32* null)
store i32 0, i32* %1
br label %21
21: ; preds = %34, %17
%22 = load i32, i32* %1
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = load i32, i32* %3
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%28 = call i32 @netd_recvdat(i32 %26, i8* %27, i32 200)
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %34
33: ; preds = %25
store i32 1, i32* %1
br label %34
34: ; preds = %33, %25
%35 = load i32, i32* %4
%36 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%37 = call i32 @netd_senddat(i32 %35, i8* %36, i32 200)
br label %21
38: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @worker() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @netd_getMyID()
%4 = tail call i32 (...) @netd_getSize()
%5 = add nsw i32 %4, -1
%6 = icmp eq i32 %3, %5
%7 = add nsw i32 %3, 1
%8 = select i1 %6, i32 0, i32 %7
%9 = add nsw i32 %3, -1
%10 = tail call i32 @crashme(i32* null)
br label %11
11: ; preds = %0, %11
%12 = call i32 @netd_recvdat(i32 %9, i8* %2, i32 200)
%13 = load i8, i8* %2
%14 = icmp eq i8 %13, 1
%15 = call i32 @netd_senddat(i32 %8, i8* %2, i32 200)
br i1 %14, label %16, label %11
16: ; preds = %11
ret void
}