#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*/ bXmitComplete(int);
int /*<<< orphan*/ sendChar(int, char);
void RobotC_WriteBuf(int port, char *data, int data_len) {
  int i;
  int timeout;
  for (i = 0; i < data_len; i++) {
    timeout = 0;
    while (!bXmitComplete(port) && (timeout++ < 20))
      ;
    sendChar(port, data[i]);
  }
}


x86 assembly (clang, -O0):
<RobotC_WriteBuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11af <RobotC_WriteBuf+0x8f>
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <bXmitComplete@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
jne    1178 <RobotC_WriteBuf+0x58>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x14,%eax
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1188 <RobotC_WriteBuf+0x68>
jmp    118d <RobotC_WriteBuf+0x6d>
jmp    114c <RobotC_WriteBuf+0x2c>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1040 <sendChar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <RobotC_WriteBuf+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RobotC_WriteBuf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    1177 <RobotC_WriteBuf+0x57>
mov    %rsi,%r14
mov    %edi,%ebp
mov    %edx,%r15d
xor    %r12d,%r12d
jmp    1155 <RobotC_WriteBuf+0x35>
nopl   0x0(%rax)
movsbl (%r14,%r12,1),%esi
mov    %ebp,%edi
call   1040 <sendChar@plt>
add    $0x1,%r12
cmp    %r15,%r12
je     1177 <RobotC_WriteBuf+0x57>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <bXmitComplete@plt>
test   %eax,%eax
jne    1140 <RobotC_WriteBuf+0x20>
lea    0x1(%rbx),%eax
cmp    $0x14,%ebx
mov    %eax,%ebx
jb     1160 <RobotC_WriteBuf+0x40>
jmp    1140 <RobotC_WriteBuf+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @RobotC_WriteBuf(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %33, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %36
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %24, %13
%15 = load i32, i32* %4
%16 = call i32 @bXmitComplete(i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i32, i32* %8
%20 = add nsw i32 %19, 1
store i32 %20, i32* %8
%21 = icmp slt i32 %19, 20
br label %22
22: ; preds = %18, %14
%23 = phi i1 [ false, %14 ], [ %21, %18 ]
br i1 %23, label %24, label %25
24: ; preds = %22
br label %14
25: ; preds = %22
%26 = load i32, i32* %4
%27 = load i8*, i8** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @sendChar(i32 %26, i8 signext %31)
br label %33
33: ; preds = %25
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %9
36: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @RobotC_WriteBuf(i32 %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %16
%8 = phi i64 [ 0, %5 ], [ %20, %16 ]
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %13, %9 ], [ 0, %7 ]
%11 = tail call i32 @bXmitComplete(i32 %0)
%12 = icmp eq i32 %11, 0
%13 = add nuw nsw i32 %10, 1
%14 = icmp ult i32 %10, 20
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %9, label %16
16: ; preds = %9
%17 = getelementptr inbounds i8, i8* %1, i64 %8
%18 = load i8, i8* %17
%19 = tail call i32 @sendChar(i32 %0, i8 signext %18)
%20 = add nuw nsw i64 %8, 1
%21 = icmp eq i64 %20, %6
br i1 %21, label %22, label %7
22: ; preds = %16, %3
ret void
}