#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 MyTid();
int /*<<< orphan*/ console_xy(int, int);
int /*<<< orphan*/ cprintf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int);
main() {
  int i, j;
  int tid, tid1;
  int send = 13;
  int reply = 0;
  int *pSend = &send;
  int *pReply = &reply;
  int x;
  int y;
  int dlyTime;
  int MaxY;
  int StartY;
  int letter;
  int xx;
  int mode = 1;
  tid = MyTid();
  StartY = 25;
  x = ((tid - 6) * 3) + 3;
  letter = (x % 10);
  y = StartY;
  dlyTime = (x % 20);
  MaxY = 40;
  srand(tid);
  while (1) {
    xx = rand();
    letter = xx % 10;
    mode = xx % 10;
    if (mode != 1) {
      y = StartY;
      do {
        xx = rand();
        dlyTime = xx % 10 + 30;
        console_xy(x, y - 1);
        cprintf("-");
        console_xy(x, y++);
        cprintf("%d", letter);
        Delay(dlyTime);
      } while (!(y > MaxY));
      console_xy(x, MaxY);
      cprintf("-");
    } else {
      y = MaxY;
      do {
        xx = rand();
        dlyTime = xx % 10;
        console_xy(x, y + 1);
        cprintf("_");
        console_xy(x, y--);
        cprintf("%d", letter);
        Delay(dlyTime);
      } while ((y >= StartY));
      console_xy(x, StartY);
      cprintf("-");
      y = StartY;
    }
  }
  Exit();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xd,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x1c(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x50(%rbp)
mov    $0x0,%al
call   1040 <MyTid@plt>
mov    %eax,-0x10(%rbp)
movl   $0x19,-0x44(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
imul   $0x3,%eax,%eax
add    $0x3,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x48(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
movl   $0x28,-0x40(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x50(%rbp)
cmpl   $0x1,-0x50(%rbp)
je     12af <main+0x14f>
mov    -0x44(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x1e,%edx
mov    %edx,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
sub    $0x1,%esi
call   1070 <console_xy@plt>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1050 <cprintf@plt>
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
call   1070 <console_xy@plt>
mov    -0x48(%rbp),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1050 <cprintf@plt>
mov    -0x3c(%rbp),%edi
call   1030 <Delay@plt>
mov    -0x38(%rbp),%eax
cmp    -0x40(%rbp),%eax
setg   %al
xor    $0xff,%al
test   $0x1,%al
jne    121b <main+0xbb>
mov    -0x34(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1070 <console_xy@plt>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1050 <cprintf@plt>
jmp    1340 <main+0x1e0>
mov    -0x40(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
add    $0x1,%esi
call   1070 <console_xy@plt>
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1050 <cprintf@plt>
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    %esi,%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
call   1070 <console_xy@plt>
mov    -0x48(%rbp),%esi
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1050 <cprintf@plt>
mov    -0x3c(%rbp),%edi
call   1030 <Delay@plt>
mov    -0x38(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    12b5 <main+0x155>
mov    -0x34(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1070 <console_xy@plt>
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   1050 <cprintf@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    11e5 <main+0x85>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <MyTid@plt>
lea    (%rax,%rax,2),%r14d
add    $0xfffffff1,%r14d
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe7d(%rip),%r12
lea    0xe73(%rip),%r15
jmp    11bb <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x19,%esi
mov    %r14d,%edi
call   1070 <console_xy@plt>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1050 <cprintf@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%r13
imul   $0x66666667,%r13,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r13d
cmp    $0x1,%r13d
jne    1260 <main+0x100>
mov    $0x29,%ebp
nopl   0x0(%rax)
lea    -0x1(%rbp),%r13d
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
mov    %r14d,%edi
mov    %ebp,%esi
call   1070 <console_xy@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <cprintf@plt>
mov    %r14d,%edi
mov    %r13d,%esi
call   1070 <console_xy@plt>
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <cprintf@plt>
mov    %ebx,%edi
call   1030 <Delay@plt>
mov    %r13d,%ebp
cmp    $0x19,%r13d
ja     11f0 <main+0x90>
jmp    11a0 <main+0x40>
nopl   0x0(%rax)
mov    $0x18,%ebx
lea    0xd94(%rip),%r15
nopl   0x0(%rax)
lea    0x1(%rbx),%ebp
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r12d
add    $0x1e,%r12d
mov    %r14d,%edi
mov    %ebx,%esi
call   1070 <console_xy@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <cprintf@plt>
mov    %r14d,%edi
mov    %ebp,%esi
call   1070 <console_xy@plt>
lea    0xd3e(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <cprintf@plt>
mov    %r12d,%edi
call   1030 <Delay@plt>
mov    %ebp,%ebx
cmp    $0x28,%ebp
jne    1270 <main+0x110>
mov    $0x28,%esi
lea    0xd1c(%rip),%r12
lea    0xd12(%rip),%r15
jmp    11a5 <main+0x45>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"_\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*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %1
store i32 13, i32* %6
store i32 0, i32* %7
store i32* %6, i32** %8
store i32* %7, i32** %9
store i32 1, i32* %17
%18 = call i32 (...) @MyTid()
store i32 %18, i32* %4
store i32 25, i32* %14
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 6
%21 = mul nsw i32 %20, 3
%22 = add nsw i32 %21, 3
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = srem i32 %23, 10
store i32 %24, i32* %15
%25 = load i32, i32* %14
store i32 %25, i32* %11
%26 = load i32, i32* %10
%27 = srem i32 %26, 20
store i32 %27, i32* %12
store i32 40, i32* %13
%28 = load i32, i32* %4
%29 = call i32 @srand(i32 %28)
br label %30
30: ; preds = %0, %97
%31 = call i32 (...) @rand()
store i32 %31, i32* %16
%32 = load i32, i32* %16
%33 = srem i32 %32, 10
store i32 %33, i32* %15
%34 = load i32, i32* %16
%35 = srem i32 %34, 10
store i32 %35, i32* %17
%36 = load i32, i32* %17
%37 = icmp ne i32 %36, 1
br i1 %37, label %38, label %68
38: ; preds = %30
%39 = load i32, i32* %14
store i32 %39, i32* %11
br label %40
40: ; preds = %58, %38
%41 = call i32 (...) @rand()
store i32 %41, i32* %16
%42 = load i32, i32* %16
%43 = srem i32 %42, 10
%44 = add nsw i32 %43, 30
store i32 %44, i32* %12
%45 = load i32, i32* %10
%46 = load i32, i32* %11
%47 = sub nsw i32 %46, 1
%48 = call i32 @console_xy(i32 %45, i32 %47)
%49 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%50 = load i32, i32* %10
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
%53 = call i32 @console_xy(i32 %50, i32 %51)
%54 = load i32, i32* %15
%55 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %12
%57 = call i32 @Delay(i32 %56)
br label %58
58: ; preds = %40
%59 = load i32, i32* %11
%60 = load i32, i32* %13
%61 = icmp sgt i32 %59, %60
%62 = xor i1 %61, true
br i1 %62, label %40, label %63
63: ; preds = %58
%64 = load i32, i32* %10
%65 = load i32, i32* %13
%66 = call i32 @console_xy(i32 %64, i32 %65)
%67 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %97
68: ; preds = %30
%69 = load i32, i32* %13
store i32 %69, i32* %11
br label %70
70: ; preds = %87, %68
%71 = call i32 (...) @rand()
store i32 %71, i32* %16
%72 = load i32, i32* %16
%73 = srem i32 %72, 10
store i32 %73, i32* %12
%74 = load i32, i32* %10
%75 = load i32, i32* %11
%76 = add nsw i32 %75, 1
%77 = call i32 @console_xy(i32 %74, i32 %76)
%78 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%79 = load i32, i32* %10
%80 = load i32, i32* %11
%81 = add nsw i32 %80, -1
store i32 %81, i32* %11
%82 = call i32 @console_xy(i32 %79, i32 %80)
%83 = load i32, i32* %15
%84 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %83)
%85 = load i32, i32* %12
%86 = call i32 @Delay(i32 %85)
br label %87
87: ; preds = %70
%88 = load i32, i32* %11
%89 = load i32, i32* %14
%90 = icmp sge i32 %88, %89
br i1 %90, label %70, label %91
91: ; preds = %87
%92 = load i32, i32* %10
%93 = load i32, i32* %14
%94 = call i32 @console_xy(i32 %92, i32 %93)
%95 = call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%96 = load i32, i32* %14
store i32 %96, i32* %11
br label %97
97: ; preds = %91, %63
br label %30
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"_\00"
define i32 @main() {
%1 = tail call i32 (...) @MyTid()
%2 = mul i32 %1, 3
%3 = add i32 %2, -15
%4 = tail call i32 @srand(i32 %1)
br label %5
5: ; preds = %34, %0
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 10
%8 = icmp eq i32 %7, 1
br i1 %8, label %22, label %9
9: ; preds = %5, %9
%10 = phi i32 [ %17, %9 ], [ 25, %5 ]
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 10
%13 = add nsw i32 %12, 30
%14 = add nsw i32 %10, -1
%15 = tail call i32 @console_xy(i32 %3, i32 %14)
%16 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = add nuw nsw i32 %10, 1
%18 = tail call i32 @console_xy(i32 %3, i32 %10)
%19 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%20 = tail call i32 @Delay(i32 %13)
%21 = icmp eq i32 %17, 41
br i1 %21, label %34, label %9
22: ; preds = %5, %22
%23 = phi i32 [ %29, %22 ], [ 40, %5 ]
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 10
%26 = add nuw nsw i32 %23, 1
%27 = tail call i32 @console_xy(i32 %3, i32 %26)
%28 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = add nsw i32 %23, -1
%30 = tail call i32 @console_xy(i32 %3, i32 %23)
%31 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
%32 = tail call i32 @Delay(i32 %25)
%33 = icmp ugt i32 %23, 25
br i1 %33, label %22, label %34
34: ; preds = %9, %22
%35 = phi i32 [ 25, %22 ], [ 40, %9 ]
%36 = tail call i32 @console_xy(i32 %3, i32 %35)
%37 = tail call i32 (i8*, ...) @cprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %5
}