#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*/ TCIOFLUSH;
int /*<<< orphan*/ send_command(int, char);
scalar_t__ tcflush(int, int /*<<< orphan*/);
void set_low(int fd, int channel) {
  unsigned char buffer[100];
  int got, intvalue;
  char chan[8] = {'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I'};
  if ((channel < 1) || (channel > 8))
    return;
  if (tcflush(fd, TCIOFLUSH) != 0)
    return;
  send_command(fd, chan[channel - 1]);
}


x86 assembly (clang, -O0):
<set_low>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x80(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     1150 <set_low+0x30>
cmpl   $0x8,-0x8(%rbp)
jle    1155 <set_low+0x35>
jmp    118a <set_low+0x6a>
mov    -0x4(%rbp),%edi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
call   1030 <tcflush@plt>
cmp    $0x0,%rax
je     1175 <set_low+0x55>
jmp    118a <set_low+0x6a>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x80(%rbp,%rax,1),%esi
call   1040 <send_command@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_low>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
lea    -0x9(%rbx),%eax
cmp    $0xfffffff8,%eax
jb     1142 <set_low+0x22>
mov    %edi,%ebp
mov    0x2eaa(%rip),%rax
mov    (%rax),%esi
call   1030 <tcflush@plt>
test   %rax,%rax
je     1149 <set_low+0x29>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
add    $0xffffffff,%ebx
lea    0xead(%rip),%rax
movsbl (%rbx,%rax,1),%esi
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <send_command@plt>

LLVM IR (-O0):
@__const.set_low.chan = [8 x i8] c"QWERTYUI"
@TCIOFLUSH = global i32 0
define void @set_low(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca [8 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = bitcast [8 x i8]* %8 to i8*
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 8
br i1 %14, label %15, label %16
15: ; preds = %12, %2
br label %30
16: ; preds = %12
%17 = load i32, i32* %3
%18 = load i32, i32* @TCIOFLUSH
%19 = call i64 @tcflush(i32 %17, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %30
22: ; preds = %16
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @send_command(i32 %23, i8 signext %28)
br label %30
30: ; preds = %22, %21, %15
ret void
}

LLVM IR (-O2):
@__const.set_low.chan = [8 x i8] c"QWERTYUI"
@TCIOFLUSH = global i32 0
define void @set_low(i32 %0, i32 %1) {
%3 = add i32 %1, -9
%4 = icmp ult i32 %3, -8
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = load i32, i32* @TCIOFLUSH
%7 = tail call i64 @tcflush(i32 %0, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = add nsw i32 %1, -1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [8 x i8], [8 x i8]* @__const.set_low.chan, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = tail call i32 @send_command(i32 %0, i8 signext %13)
br label %15
15: ; preds = %5, %2, %9
ret void
}