#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write_msg(int, unsigned char *, int);
void do_setbto_100(int tty_fd, int bto) {
  unsigned char setbto_100_msg[2] = {0x13};
  if (bto < 0 || bto > 255) {
    fputs("Invalid BTO value\n", stderr);
    return;
  }
  setbto_100_msg[1] = (unsigned char)bto;
  write_msg(tty_fd, setbto_100_msg, sizeof setbto_100_msg);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0xecb(%rip),%ax
mov    %ax,-0xa(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1150 <do_setbto_100+0x30>
cmpl   $0xff,-0x8(%rbp)
jle    116a <do_setbto_100+0x4a>
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
call   1030 <fputs@plt>
jmp    1181 <do_setbto_100+0x61>
mov    -0x8(%rbp),%eax
mov    %al,-0x9(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xa(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write_msg@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rax
movw   $0x13,0x6(%rsp)
cmp    $0x100,%esi
jb     1146 <do_setbto_100+0x26>
mov    0x2ea9(%rip),%rax
mov    (%rax),%esi
lea    0xec0(%rip),%rdi
pop    %rax
jmp    1030 <fputs@plt>
mov    %sil,0x7(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x2,%edx
call   1040 <write_msg@plt>
pop    %rax
ret

LLVM IR (-O0):
@__const.do_setbto_100.setbto_100_msg = [2 x i8] c"\13\00"
@.str = [19 x i8] c"Invalid BTO value\0A\00"
@stderr = global i32 0
define void @do_setbto_100(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = bitcast [2 x i8]* %5 to i8*
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 255
br i1 %11, label %12, label %15
12: ; preds = %9, %2
%13 = load i32, i32* @stderr
%14 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %22
15: ; preds = %9
%16 = load i32, i32* %4
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
store i8 %17, i8* %18
%19 = load i32, i32* %3
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%21 = call i32 @write_msg(i32 %19, i8* %20, i32 2)
br label %22
22: ; preds = %15, %12
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Invalid BTO value\0A\00"
@stderr = global i32 0
define void @do_setbto_100(i32 %0, i32 %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
store i16 19, i16* %3
%5 = icmp ugt i32 %1, 255
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %14
9: ; preds = %2
%10 = bitcast i16* %3 to [2 x i8]*
%11 = trunc i32 %1 to i8
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 1
store i8 %11, i8* %12
%13 = call i32 @write_msg(i32 %0, i8* %4, i32 2)
br label %14
14: ; preds = %9, %6
ret void
}