#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ xmodem_getc(int *);
int /*<<< orphan*/ xmodem_putc(int *);
int xmodem_send_byte_with_retry(uint8_t cmd) {
  uint8_t retransmit = (3);
  uint8_t rsp;
  while (retransmit--) {
    xmodem_putc(&cmd);
    rsp = (0xFF);
    xmodem_getc(&rsp);
    if (rsp == (0x06)) {
      return 0;
    }

    ;
  }
  return -1;
}


x86 assembly (clang, -O0):
<xmodem_send_byte_with_retry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     117a <xmodem_send_byte_with_retry+0x5a>
lea    -0x8(%rbp),%rdi
call   1030 <xmodem_putc@plt>
movl   $0xff,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <xmodem_getc@plt>
cmpl   $0x6,-0x10(%rbp)
jne    1175 <xmodem_send_byte_with_retry+0x55>
movl   $0x0,-0x4(%rbp)
jmp    1181 <xmodem_send_byte_with_retry+0x61>
jmp    1132 <xmodem_send_byte_with_retry+0x12>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmodem_send_byte_with_retry>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <xmodem_putc@plt>
movl   $0xff,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <xmodem_getc@plt>
xor    %ebx,%ebx
cmpl   $0x6,0x8(%rsp)
je     1199 <xmodem_send_byte_with_retry+0x79>
lea    0xc(%rsp),%rdi
call   1030 <xmodem_putc@plt>
movl   $0xff,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <xmodem_getc@plt>
cmpl   $0x6,0x8(%rsp)
je     1199 <xmodem_send_byte_with_retry+0x79>
lea    0xc(%rsp),%rdi
call   1030 <xmodem_putc@plt>
movl   $0xff,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <xmodem_getc@plt>
xor    %ebx,%ebx
cmpl   $0x6,0x8(%rsp)
setne  %bl
neg    %ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @xmodem_send_byte_with_retry(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 3, i32* %4
br label %6
6: ; preds = %16, %1
%7 = load i32, i32* %4
%8 = add nsw i32 %7, -1
store i32 %8, i32* %4
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = call i32 @xmodem_putc(i32* %3)
store i32 255, i32* %5
%12 = call i32 @xmodem_getc(i32* %5)
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 6
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 0, i32* %2
br label %18
16: ; preds = %10
br label %6
17: ; preds = %6
store i32 -1, i32* %2
br label %18
18: ; preds = %17, %15
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
define i32 @xmodem_send_byte_with_retry(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = bitcast i32* %3 to i8*
%5 = call i32 @xmodem_putc(i32* %2)
store i32 255, i32* %3
%6 = call i32 @xmodem_getc(i32* %3)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 6
br i1 %8, label %20, label %9
9: ; preds = %1
%10 = call i32 @xmodem_putc(i32* %2)
store i32 255, i32* %3
%11 = call i32 @xmodem_getc(i32* %3)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 6
br i1 %13, label %20, label %14
14: ; preds = %9
%15 = call i32 @xmodem_putc(i32* %2)
store i32 255, i32* %3
%16 = call i32 @xmodem_getc(i32* %3)
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 6
%19 = sext i1 %18 to i32
br label %20
20: ; preds = %14, %9, %1
%21 = phi i32 [ 0, %1 ], [ 0, %9 ], [ %19, %14 ]
ret i32 %21
}