#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 transport_sendPacketBuffernb(int);
int /*<<< orphan*/ transport_sendPacketBuffernb_start(int, unsigned char *,
                                                      int);
int transport_sendPacketBuffer(int sock, unsigned char *buf, int buflen) {
  int rc;
  transport_sendPacketBuffernb_start(sock, buf, buflen);
  while ((rc = transport_sendPacketBuffernb(sock)) == 0) {
  }
  if (rc == 1) {
    return buflen;
  }
  return -1;
}


x86 assembly (clang, -O0):
<transport_sendPacketBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <transport_sendPacketBuffernb_start@plt>
mov    -0x8(%rbp),%edi
call   1040 <transport_sendPacketBuffernb@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jne    115a <transport_sendPacketBuffer+0x3a>
jmp    1141 <transport_sendPacketBuffer+0x21>
cmpl   $0x1,-0x18(%rbp)
jne    116f <transport_sendPacketBuffer+0x4f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1176 <transport_sendPacketBuffer+0x56>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transport_sendPacketBuffer>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %edi,%ebp
call   1030 <transport_sendPacketBuffernb_start@plt>
nopl   0x0(%rax)
mov    %ebp,%edi
call   1040 <transport_sendPacketBuffernb@plt>
test   %eax,%eax
je     1130 <transport_sendPacketBuffer+0x10>
cmp    $0x1,%eax
je     1145 <transport_sendPacketBuffer+0x25>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @transport_sendPacketBuffer(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = call i32 @transport_sendPacketBuffernb_start(i32 %9, i8* %10, i32 %11)
br label %13
13: ; preds = %17, %3
%14 = load i32, i32* %5
%15 = call i32 @transport_sendPacketBuffernb(i32 %14)
store i32 %15, i32* %8
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = load i32, i32* %8
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = load i32, i32* %7
store i32 %22, i32* %4
br label %24
23: ; preds = %18
store i32 -1, i32* %4
br label %24
24: ; preds = %23, %21
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
define i32 @transport_sendPacketBuffer(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @transport_sendPacketBuffernb_start(i32 %0, i8* %1, i32 %2)
br label %5
5: ; preds = %5, %3
%6 = tail call i32 @transport_sendPacketBuffernb(i32 %0)
switch i32 %6, label %8 [
i32 0, label %5
i32 1, label %7
]
7: ; preds = %5
br label %8
8: ; preds = %5, %7
%9 = phi i32 [ %2, %7 ], [ -1, %5 ]
ret i32 %9
}