#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 */
scalar_t__ RecvFrame(int, unsigned char *);
int /*<<< orphan*/ SendLAFrame(int, unsigned char);
int WaitLAFrame(int newtFd, unsigned char seqNo) {
  unsigned char frame[256 + 256];
  do {
    while (RecvFrame(newtFd, frame) < 0)
      ;
    if (frame[1] == '\x04')
      SendLAFrame(newtFd, frame[2]);
  } while (frame[1] != '\x05');
  if (frame[2] == seqNo)
    return 0;
  else
    return -1;
}


x86 assembly (clang, -O0):
<WaitLAFrame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jmp    1139 <WaitLAFrame+0x19>
mov    -0x8(%rbp),%edi
lea    -0x210(%rbp),%rsi
call   1030 <RecvFrame@plt>
cmp    $0x0,%rax
jge    1157 <WaitLAFrame+0x37>
jmp    1139 <WaitLAFrame+0x19>
movzbl -0x20f(%rbp),%eax
cmp    $0x4,%eax
jne    1176 <WaitLAFrame+0x56>
mov    -0x8(%rbp),%edi
movzbl -0x20e(%rbp),%esi
call   1040 <SendLAFrame@plt>
jmp    117b <WaitLAFrame+0x5b>
movzbl -0x20f(%rbp),%eax
cmp    $0x5,%eax
jne    1134 <WaitLAFrame+0x14>
movzbl -0x20e(%rbp),%eax
movzbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    11aa <WaitLAFrame+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <WaitLAFrame+0x91>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WaitLAFrame>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %esi,%r14d
mov    %edi,%ebp
mov    %rsp,%rbx
jmp    1144 <WaitLAFrame+0x24>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x5,%al
je     116f <WaitLAFrame+0x4f>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <RecvFrame@plt>
test   %rax,%rax
js     1144 <WaitLAFrame+0x24>
movzbl 0x1(%rsp),%eax
cmp    $0x4,%al
jne    1140 <WaitLAFrame+0x20>
movzbl 0x2(%rsp),%esi
mov    %ebp,%edi
call   1040 <SendLAFrame@plt>
movzbl 0x1(%rsp),%eax
jmp    1140 <WaitLAFrame+0x20>
xor    %eax,%eax
cmp    %r14b,0x2(%rsp)
setne  %al
neg    %eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @WaitLAFrame(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca [512 x i8]
store i32 %0, i32* %4
store i8 %1, i8* %5
br label %7
7: ; preds = %25, %2
br label %8
8: ; preds = %13, %7
%9 = load i32, i32* %4
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%11 = call i64 @RecvFrame(i32 %9, i8* %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
br label %8
14: ; preds = %8
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = icmp eq i32 %17, 4
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i32, i32* %4
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 2
%22 = load i8, i8* %21
%23 = call i32 @SendLAFrame(i32 %20, i8 zeroext %22)
br label %24
24: ; preds = %19, %14
br label %25
25: ; preds = %24
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 1
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp ne i32 %28, 5
br i1 %29, label %7, label %30
30: ; preds = %25
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 2
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = load i8, i8* %5
%35 = zext i8 %34 to i32
%36 = icmp eq i32 %33, %35
br i1 %36, label %37, label %38
37: ; preds = %30
store i32 0, i32* %3
br label %39
38: ; preds = %30
store i32 -1, i32* %3
br label %39
39: ; preds = %38, %37
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @WaitLAFrame(i32 %0, i8 zeroext %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 1
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 2
br label %7
7: ; preds = %10, %2
%8 = call i64 @RecvFrame(i32 %0, i8* %4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7, %18
br label %7
11: ; preds = %7
%12 = load i8, i8* %5
%13 = icmp eq i8 %12, 4
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i8, i8* %6
%16 = call i32 @SendLAFrame(i32 %0, i8 zeroext %15)
%17 = load i8, i8* %5
br label %18
18: ; preds = %11, %14
%19 = phi i8 [ %12, %11 ], [ %17, %14 ]
%20 = icmp eq i8 %19, 5
br i1 %20, label %21, label %10
21: ; preds = %18
%22 = load i8, i8* %6
%23 = icmp ne i8 %22, %1
%24 = sext i1 %23 to i32
ret i32 %24
}