#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*/ printf(char *);
int si_expect_yn(int);
int /*<<< orphan*/ si_send_command(int, int);
void si_send_command_yn(int fd, int data) {
  int ex;
  si_send_command(fd, data);
  ex = si_expect_yn(fd);
  if (ex < 0)
    printf("error expected Y/N uart\n");
  else if (ex)
    printf("got yes from uart\n");
  else
    printf("got no from uart\n");
}


x86 assembly (clang, -O0):
<si_send_command_yn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <si_send_command@plt>
mov    -0x4(%rbp),%edi
call   1050 <si_expect_yn@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    116f <si_send_command_yn+0x3f>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    119b <si_send_command_yn+0x6b>
cmpl   $0x0,-0xc(%rbp)
je     118a <si_send_command_yn+0x5a>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    1196 <si_send_command_yn+0x66>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    119b <si_send_command_yn+0x6b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<si_send_command_yn>:
push   %rbx
mov    %edi,%ebx
call   1040 <si_send_command@plt>
mov    %ebx,%edi
call   1050 <si_expect_yn@plt>
test   %eax,%eax
lea    0xeb8(%rip),%rax
lea    0xec2(%rip),%rcx
cmove  %rax,%rcx
lea    0xec9(%rip),%rdi
cmovns %rcx,%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"error expected Y/N uart\0A\00"
@.str.1 = [19 x i8] c"got yes from uart\0A\00"
@.str.2 = [18 x i8] c"got no from uart\0A\00"
define void @si_send_command_yn(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = load i32, i32* %4
%8 = call i32 @si_send_command(i32 %6, i32 %7)
%9 = load i32, i32* %3
%10 = call i32 @si_expect_yn(i32 %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %23
15: ; preds = %2
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
br label %23
23: ; preds = %22, %13
ret void
}

LLVM IR (-O2):
@str = [17 x i8] c"got no from uart\00"
@str.3 = [18 x i8] c"got yes from uart\00"
@str.4 = [24 x i8] c"error expected Y/N uart\00"
define void @si_send_command_yn(i32 %0, i32 %1) {
%3 = tail call i32 @si_send_command(i32 %0, i32 %1)
%4 = tail call i32 @si_expect_yn(i32 %0)
%5 = icmp slt i32 %4, 0
%6 = icmp eq i32 %4, 0
%7 = select i1 %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0)
%8 = select i1 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0), i8* %7
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
ret void
}