#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*/ Delay(int);
int /*<<< orphan*/ Exit();
int Receive(int *, int);
int /*<<< orphan*/ Reply(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ Send(int, int *, int, int /*<<< orphan*/,
                        int /*<<< orphan*/);
int /*<<< orphan*/ console_xy(int, int);
int /*<<< orphan*/ cprintf(char *, ...);
main() {
  int EnderPID;
  int myNum;
  int mainPID;
  int i;
  int row;
  int col;
  int EraseThis;
  int delayDuration;
  EnderPID = 5;
  mainPID = Receive(&myNum, sizeof(int));
  Reply(mainPID, 0, 0);
  console_xy(0, (10 + myNum));
  for (i = 1; i <= ((5 * 20) / myNum); i++) {
    EraseThis = (i * myNum);
    if ((EraseThis % 20) != 0) {
      row = (EraseThis / 20);
      col = EraseThis - (row * 20);
    } else {
      row = ((EraseThis / 20) - 1);
      col = 20;
    }
    console_xy((col * 3), row);
    cprintf("   ");
    delayDuration = ((i * myNum) * 2);
    Delay(myNum * 2);
  }
  console_xy(0, (20 + myNum));
  cprintf("Eater %d finnishing \n", myNum);
  Send(EnderPID, &myNum, sizeof(int), 0, 0);
  while (1) {
    Delay(40);
    cprintf("ea");
  }
  Exit();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
call   1040 <Receive@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <Reply@plt>
mov    -0xc(%rbp),%esi
add    $0xa,%esi
xor    %edi,%edi
call   1070 <console_xy@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x64,%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jg     1258 <main+0xf8>
mov    -0x14(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1200 <main+0xa0>
mov    -0x20(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
imul   $0x14,-0x18(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    1218 <main+0xb8>
mov    -0x20(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x14,-0x1c(%rbp)
imul   $0x3,-0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <console_xy@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1060 <cprintf@plt>
mov    -0x14(%rbp),%eax
imul   -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
shl    $0x1,%edi
call   1030 <Delay@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <main+0x47>
mov    -0xc(%rbp),%esi
add    $0x14,%esi
xor    %edi,%edi
call   1070 <console_xy@plt>
mov    -0xc(%rbp),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1060 <cprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1080 <Send@plt>
mov    $0x28,%edi
call   1030 <Delay@plt>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1060 <cprintf@plt>
jmp    128d <main+0x12d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
call   1040 <Receive@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <Reply@plt>
mov    0xc(%rsp),%esi
add    $0xa,%esi
xor    %edi,%edi
call   1070 <console_xy@plt>
mov    0xc(%rsp),%esi
mov    $0x64,%eax
xor    %edx,%edx
idiv   %esi
test   %eax,%eax
jle    1212 <main+0xb2>
mov    $0x3c,%r14d
lea    0xe52(%rip),%rbx
xor    %ebp,%ebp
add    $0x1,%ebp
imul   %ebp,%esi
movslq %esi,%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rsi
add    %ecx,%esi
lea    0x0(,%rsi,4),%ecx
lea    (%rcx,%rcx,4),%ecx
xor    %edx,%edx
sub    %ecx,%eax
sete   %dl
lea    (%rax,%rax,2),%edi
cmove  %r14d,%edi
sub    %edx,%esi
call   1070 <console_xy@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <cprintf@plt>
mov    0xc(%rsp),%edi
add    %edi,%edi
call   1030 <Delay@plt>
mov    0xc(%rsp),%esi
mov    $0x64,%eax
xor    %edx,%edx
idiv   %esi
cmp    %eax,%ebp
jl     11b0 <main+0x50>
add    $0x14,%esi
xor    %edi,%edi
call   1070 <console_xy@plt>
mov    0xc(%rsp),%esi
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1060 <cprintf@plt>
lea    0xc(%rsp),%rsi
mov    $0x5,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1080 <Send@plt>
lea    0xdcc(%rip),%rbx
xchg   %ax,%ax
mov    $0x28,%edi
call   1030 <Delay@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <cprintf@plt>
jmp    1250 <main+0xf0>

LLVM IR (-O0):
@.str = [4 x i8] c" \00"
@.str.1 = [22 x i8] c"Eater %d finnishing \0A\00"
@.str.2 = [3 x i8] c"ea\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
%10 = call i32 @Receive(i32* %3, i32 4)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = call i32 @Reply(i32 %11, i32 0, i32 0)
%13 = load i32, i32* %3
%14 = add nsw i32 10, %13
%15 = call i32 @console_xy(i32 0, i32 %14)
store i32 1, i32* %5
br label %16
16: ; preds = %52, %0
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = sdiv i32 100, %18
%20 = icmp sle i32 %17, %19
br i1 %20, label %21, label %55
21: ; preds = %16
%22 = load i32, i32* %5
%23 = load i32, i32* %3
%24 = mul nsw i32 %22, %23
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = srem i32 %25, 20
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %21
%29 = load i32, i32* %8
%30 = sdiv i32 %29, 20
store i32 %30, i32* %6
%31 = load i32, i32* %8
%32 = load i32, i32* %6
%33 = mul nsw i32 %32, 20
%34 = sub nsw i32 %31, %33
store i32 %34, i32* %7
br label %39
35: ; preds = %21
%36 = load i32, i32* %8
%37 = sdiv i32 %36, 20
%38 = sub nsw i32 %37, 1
store i32 %38, i32* %6
store i32 20, i32* %7
br label %39
39: ; preds = %35, %28
%40 = load i32, i32* %7
%41 = mul nsw i32 %40, 3
%42 = load i32, i32* %6
%43 = call i32 @console_xy(i32 %41, i32 %42)
%44 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%45 = load i32, i32* %5
%46 = load i32, i32* %3
%47 = mul nsw i32 %45, %46
%48 = mul nsw i32 %47, 2
store i32 %48, i32* %9
%49 = load i32, i32* %3
%50 = mul nsw i32 %49, 2
%51 = call i32 @Delay(i32 %50)
br label %52
52: ; preds = %39
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %16
55: ; preds = %16
%56 = load i32, i32* %3
%57 = add nsw i32 20, %56
%58 = call i32 @console_xy(i32 0, i32 %57)
%59 = load i32, i32* %3
%60 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %2
%62 = call i32 @Send(i32 %61, i32* %3, i32 4, i32 0, i32 0)
br label %63
63: ; preds = %55, %63
%64 = call i32 @Delay(i32 40)
%65 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %63
}

LLVM IR (-O2):
@.str = [4 x i8] c" \00"
@.str.1 = [22 x i8] c"Eater %d finnishing \0A\00"
@.str.2 = [3 x i8] c"ea\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @Receive(i32* %1, i32 4)
%4 = call i32 @Reply(i32 %3, i32 0, i32 0)
%5 = load i32, i32* %1
%6 = add nsw i32 %5, 10
%7 = call i32 @console_xy(i32 0, i32 %6)
%8 = load i32, i32* %1
%9 = sdiv i32 100, %8
%10 = icmp slt i32 %9, 1
br i1 %10, label %33, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %30, %11 ], [ %8, %0 ]
%13 = phi i32 [ %29, %11 ], [ 1, %0 ]
%14 = mul nsw i32 %12, %13
%15 = srem i32 %14, 20
%16 = icmp eq i32 %15, 0
%17 = sdiv i32 %14, 20
%18 = mul nsw i32 %17, -20
%19 = add i32 %18, %14
%20 = sext i1 %16 to i32
%21 = add nsw i32 %17, %20
%22 = mul nsw i32 %19, 3
%23 = select i1 %16, i32 60, i32 %22
%24 = call i32 @console_xy(i32 %23, i32 %21)
%25 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = shl nsw i32 %26, 1
%28 = call i32 @Delay(i32 %27)
%29 = add nuw nsw i32 %13, 1
%30 = load i32, i32* %1
%31 = sdiv i32 100, %30
%32 = icmp slt i32 %13, %31
br i1 %32, label %11, label %33
33: ; preds = %11, %0
%34 = phi i32 [ %8, %0 ], [ %30, %11 ]
%35 = add nsw i32 %34, 20
%36 = call i32 @console_xy(i32 0, i32 %35)
%37 = load i32, i32* %1
%38 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = call i32 @Send(i32 5, i32* %1, i32 4, i32 0, i32 0)
br label %40
40: ; preds = %40, %33
%41 = call i32 @Delay(i32 40)
%42 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %40
}