#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*/ TIOCMBIC;
int TIOCM_DTR;
int TIOCM_RTS;
int ioctl(int, int /*<<< orphan*/, int *);
int tty_clear(int fd, int rts, int dtr) {
  int mask;
  mask = rts ? TIOCM_RTS : 0;
  mask |= dtr ? TIOCM_DTR : 0;
  if (ioctl(fd, TIOCMBIC, &mask) == -1) {
    do {
    } while (0);
    do {
    } while (0);
    return (0);
  }
  return (1);
}


x86 assembly (clang, -O0):
<tty_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     113c <tty_clear+0x2c>
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <tty_clear+0x36>
xor    %eax,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <tty_clear+0x36>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1167 <tty_clear+0x57>
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    1171 <tty_clear+0x61>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    1171 <tty_clear+0x61>
mov    -0x1c(%rbp),%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
lea    -0x14(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    11b8 <tty_clear+0xa8>
jmp    119d <tty_clear+0x8d>
jmp    11a2 <tty_clear+0x92>
jmp    11a7 <tty_clear+0x97>
jmp    11ac <tty_clear+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11bf <tty_clear+0xaf>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tty_clear>:
push   %rax
test   %esi,%esi
je     111e <tty_clear+0xe>
mov    0x2ecc(%rip),%rax
mov    (%rax),%esi
test   %edx,%edx
je     112b <tty_clear+0x1b>
mov    0x2eb7(%rip),%rax
mov    (%rax),%edx
or     %esi,%edx
mov    %edx,0x4(%rsp)
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
call   1030 <ioctl@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@TIOCM_RTS = global i32 0
@TIOCM_DTR = global i32 0
@TIOCMBIC = global i32 0
define i32 @tty_clear(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = load i32, i32* @TIOCM_RTS
br label %14
13: ; preds = %3
br label %14
14: ; preds = %13, %11
%15 = phi i32 [ %12, %11 ], [ 0, %13 ]
store i32 %15, i32* %8
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* @TIOCM_DTR
br label %21
20: ; preds = %14
br label %21
21: ; preds = %20, %18
%22 = phi i32 [ %19, %18 ], [ 0, %20 ]
%23 = load i32, i32* %8
%24 = or i32 %23, %22
store i32 %24, i32* %8
%25 = load i32, i32* %5
%26 = load i32, i32* @TIOCMBIC
%27 = call i32 @ioctl(i32 %25, i32 %26, i32* %8)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %21
br label %30
30: ; preds = %29
br label %31
31: ; preds = %30
br label %32
32: ; preds = %31
br label %33
33: ; preds = %32
store i32 0, i32* %4
br label %35
34: ; preds = %21
store i32 1, i32* %4
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@TIOCM_RTS = global i32 0
@TIOCM_DTR = global i32 0
@TIOCMBIC = global i32 0
define i32 @tty_clear(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = icmp eq i32 %1, 0
%7 = load i32, i32* @TIOCM_RTS
%8 = select i1 %6, i32 0, i32 %7
%9 = icmp eq i32 %2, 0
%10 = load i32, i32* @TIOCM_DTR
%11 = select i1 %9, i32 0, i32 %10
%12 = or i32 %11, %8
store i32 %12, i32* %4
%13 = load i32, i32* @TIOCMBIC
%14 = call i32 @ioctl(i32 %0, i32 %13, i32* %4)
%15 = icmp ne i32 %14, -1
%16 = zext i1 %15 to i32
ret i32 %16
}