#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*/ die(char *);
scalar_t__ st_getbytes(int, char *, int);
int /*<<< orphan*/ write(int, char const *, int);
void st_cmd(int devfd, const char *out, int outlen, int inlen) {
  char buf[64];
  write(devfd, out, outlen);
  if (inlen && st_getbytes(devfd, buf, inlen) < 0)
    die("error: target quit responding.  "
        "Cycle power and try again.\n");
}


x86 assembly (clang, -O0):
<st_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
cmpl   $0x0,-0x18(%rbp)
je     1183 <st_cmd+0x53>
mov    -0x4(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <st_getbytes@plt>
cmp    $0x0,%rax
jge    1183 <st_cmd+0x53>
lea    0xe82(%rip),%rdi
call   1050 <die@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<st_cmd>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %ecx,%ebx
mov    %edi,%ebp
call   1030 <write@plt>
test   %ebx,%ebx
je     1160 <st_cmd+0x30>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    %ebx,%edx
call   1040 <st_getbytes@plt>
test   %rax,%rax
jns    1160 <st_cmd+0x30>
lea    0xea5(%rip),%rdi
call   1050 <die@plt>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"error: target quit responding. Cycle power and try again.\0A\00"
define void @st_cmd(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [64 x i8]
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = call i32 @write(i32 %10, i8* %11, i32 %12)
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %4
%17 = load i32, i32* %5
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%19 = load i32, i32* %8
%20 = call i64 @st_getbytes(i32 %17, i8* %18, i32 %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = call i32 @die(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %16, %4
ret void
}

LLVM IR (-O2):
@.str = [60 x i8] c"error: target quit responding. Cycle power and try again.\0A\00"
define void @st_cmd(i32 %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @write(i32 %0, i8* %1, i32 %2)
%8 = icmp eq i32 %3, 0
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = call i64 @st_getbytes(i32 %0, i8* %6, i32 %3)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @die(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9, %4
ret void
}