#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ fatal_(int, char *, int, char *, scalar_t__, scalar_t__);
int /*<<< orphan*/ uart_send_recv(int, scalar_t__ *, int, int);
void uart_send_cmd(int fd, uint8_t *cmd, int len) {
  uint8_t ack = cmd[0];
  uart_send_recv(fd, cmd, len, 1);
  if (cmd[0] != ack)
    do {
      fatal_(1,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/drkitty/pickler/refs/heads/master/"
             "pickler.c",
             389, "Programmer can't execute '%c' (returned 0x%02X)", ack,
             cmd[0]);
    } while (0);
}


x86 assembly (clang, -O0):
<uart_send_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x1,%ecx
call   1030 <uart_send_recv@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
je     1194 <uart_send_cmd+0x74>
jmp    1167 <uart_send_cmd+0x47>
mov    -0x20(%rbp),%r8
mov    -0x10(%rbp),%rax
mov    (%rax),%r9
mov    $0x1,%edi
lea    0xe82(%rip),%rsi
mov    $0x185,%edx
lea    0xefc(%rip),%rcx
call   1040 <fatal_@plt>
jmp    1194 <uart_send_cmd+0x74>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_send_cmd>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rsi),%r14
mov    $0x1,%ecx
call   1030 <uart_send_recv@plt>
mov    (%rbx),%r9
cmp    %r14,%r9
jne    1144 <uart_send_cmd+0x24>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeb5(%rip),%rsi
lea    0xf34(%rip),%rcx
mov    $0x1,%edi
mov    $0x185,%edx
mov    %r14,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fatal_@plt>

LLVM IR (-O0):
@.str = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drkitty/pickler/refs/heads/master/pickler.c\00"
@.str.1 = [48 x i8] c"Programmer can't execute '%c' (returned 0x%02X)\00"
define void @uart_send_cmd(i32 %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i64
store i32 %0, i32* %4
store i64* %1, i64** %5
store i32 %2, i32* %6
%8 = load i64*, i64** %5
%9 = getelementptr inbounds i64, i64* %8, i64 0
%10 = load i64, i64* %9
store i64 %10, i64* %7
%11 = load i32, i32* %4
%12 = load i64*, i64** %5
%13 = load i32, i32* %6
%14 = call i32 @uart_send_recv(i32 %11, i64* %12, i32 %13, i32 1)
%15 = load i64*, i64** %5
%16 = getelementptr inbounds i64, i64* %15, i64 0
%17 = load i64, i64* %16
%18 = load i64, i64* %7
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %3
br label %21
21: ; preds = %20
%22 = load i64, i64* %7
%23 = load i64*, i64** %5
%24 = getelementptr inbounds i64, i64* %23, i64 0
%25 = load i64, i64* %24
%26 = call i32 @fatal_(i32 1, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i32 389, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i64 %22, i64 %25)
br label %27
27: ; preds = %21
br label %28
28: ; preds = %27, %3
ret void
}

LLVM IR (-O2):
@.str = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/drkitty/pickler/refs/heads/master/pickler.c\00"
@.str.1 = [48 x i8] c"Programmer can't execute '%c' (returned 0x%02X)\00"
define void @uart_send_cmd(i32 %0, i64* %1, i32 %2) {
%4 = load i64, i64* %1
%5 = tail call i32 @uart_send_recv(i32 %0, i64* %1, i32 %2, i32 1)
%6 = load i64, i64* %1
%7 = icmp eq i64 %6, %4
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 @fatal_(i32 1, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i32 389, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i64 %4, i64 %6)
br label %10
10: ; preds = %8, %3
ret void
}