#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*/ TIOCMGET;
int /*<<< orphan*/ TIOCMSET;
int TIOCM_RTS;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int *);
int rts(int fd, int rtsEnable) {
  int flags;
  ioctl(fd, TIOCMGET, &flags);
  if (rtsEnable != 0)
    flags |= TIOCM_RTS;
  else
    flags &= ~TIOCM_RTS;
  ioctl(fd, TIOCMSET, &flags);
  return 0;
}


x86 assembly (clang, -O0):
<rts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2eb0(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1030 <ioctl@plt>
cmpl   $0x0,-0x8(%rbp)
je     1151 <rts+0x41>
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <rts+0x53>
mov    0x2e88(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1030 <ioctl@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rts>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    0x2eba(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
call   1030 <ioctl@plt>
mov    0x2eaf(%rip),%rax
mov    (%rax),%eax
test   %ebp,%ebp
je     113d <rts+0x2d>
or     0x4(%rsp),%eax
jmp    1143 <rts+0x33>
not    %eax
and    0x4(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %ebx,%edi
call   1030 <ioctl@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@TIOCMGET = global i32 0
@TIOCM_RTS = global i32 0
@TIOCMSET = global i32 0
define i32 @rts(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* @TIOCMGET
%8 = call i32 @ioctl(i32 %6, i32 %7, i32* %5)
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @TIOCM_RTS
%13 = load i32, i32* %5
%14 = or i32 %13, %12
store i32 %14, i32* %5
br label %20
15: ; preds = %2
%16 = load i32, i32* @TIOCM_RTS
%17 = xor i32 %16, -1
%18 = load i32, i32* %5
%19 = and i32 %18, %17
store i32 %19, i32* %5
br label %20
20: ; preds = %15, %11
%21 = load i32, i32* %3
%22 = load i32, i32* @TIOCMSET
%23 = call i32 @ioctl(i32 %21, i32 %22, i32* %5)
ret i32 0
}

LLVM IR (-O2):
@TIOCMGET = global i32 0
@TIOCM_RTS = global i32 0
@TIOCMSET = global i32 0
define i32 @rts(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @TIOCMGET
%6 = call i32 @ioctl(i32 %0, i32 %5, i32* %3)
%7 = icmp eq i32 %1, 0
%8 = load i32, i32* @TIOCM_RTS
br i1 %7, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %3
%11 = or i32 %10, %8
br label %16
12: ; preds = %2
%13 = xor i32 %8, -1
%14 = load i32, i32* %3
%15 = and i32 %14, %13
br label %16
16: ; preds = %12, %9
%17 = phi i32 [ %15, %12 ], [ %11, %9 ]
store i32 %17, i32* %3
%18 = load i32, i32* @TIOCMSET
%19 = call i32 @ioctl(i32 %0, i32 %18, i32* %3)
ret i32 0
}