#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 /*<<< orphan*/ outstr;

/* Variables and functions */
int /*<<< orphan*/ appendseriallog(char *, int);
int /*<<< orphan*/ readtonextprompt(int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void blindcmd(int fd, const char *cmd, int no_response) {
  char outstr[1024];
  snprintf(outstr, sizeof(outstr), "%s%s\0", cmd, "\r");
  appendseriallog(outstr, 1);
  write(fd, outstr, strlen(outstr));
  if (0 != no_response) {
    sleep(1);
    readtonextprompt(fd);
  }
}


x86 assembly (clang, -O0):
<blindcmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x400,%esi
lea    0xe74(%rip),%rdx
lea    0xe73(%rip),%r8
call   1050 <snprintf@plt>
lea    -0x420(%rbp),%rdi
mov    $0x1,%esi
call   1070 <appendseriallog@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x42c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x42c(%rbp),%edi
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
je     11fd <blindcmd+0x9d>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x4(%rbp),%edi
call   1060 <readtonextprompt@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blindcmd>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edx,%r14d
mov    %rsi,%rcx
mov    %edi,%ebx
lea    0xe86(%rip),%rdx
lea    0xe85(%rip),%r8
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x400,%esi
call   1050 <snprintf@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
call   1070 <appendseriallog@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %r14d,%r14d
je     11c8 <blindcmd+0x68>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    %ebx,%edi
call   1060 <readtonextprompt@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s%s\00\00"
@.str.1 = [2 x i8] c"\0D\00"
define void @blindcmd(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [1024 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%9 = load i8*, i8** %5
%10 = call i32 @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%12 = call i32 @appendseriallog(i8* %11, i32 1)
%13 = load i32, i32* %4
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @write(i32 %13, i8* %14, i32 %16)
%18 = load i32, i32* %6
%19 = icmp ne i32 0, %18
br i1 %19, label %20, label %24
20: ; preds = %3
%21 = call i32 @sleep(i32 1)
%22 = load i32, i32* %4
%23 = call i32 @readtonextprompt(i32 %22)
br label %24
24: ; preds = %20, %3
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s%s\00\00"
@.str.1 = [2 x i8] c"\0D\00"
define void @blindcmd(i32 %0, i8* %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @appendseriallog(i8* %5, i32 1)
%8 = call i32 @strlen(i8* %5)
%9 = call i32 @write(i32 %0, i8* %5, i32 %8)
%10 = icmp eq i32 %2, 0
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = call i32 @sleep(i32 1)
%13 = call i32 @readtonextprompt(i32 %0)
br label %14
14: ; preds = %11, %3
ret void
}