#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;
unsigned int TIOCM_CAR;
unsigned int TIOCM_CTS;
unsigned int TIOCM_DSR;
unsigned int TIOCM_DTR;
unsigned int TIOCM_RNG;
unsigned int TIOCM_RTS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int ioctl(int, int /*<<< orphan*/, unsigned int *);
int /*<<< orphan*/ stderr;
void print_status(int fd) {
  int status;
  unsigned int arg;
  status = ioctl(fd, TIOCMGET, &arg);
  arg &= ~TIOCM_RTS;
  ioctl(fd, TIOCMSET, &arg);
  fprintf(stderr, "[STATUS]: ");
  if (arg & TIOCM_RTS)
    fprintf(stderr, "RTS ");
  if (arg & TIOCM_CTS)
    fprintf(stderr, "CTS ");
  if (arg & TIOCM_DSR)
    fprintf(stderr, "DSR ");
  if (arg & TIOCM_CAR)
    fprintf(stderr, "DCD ");
  if (arg & TIOCM_DTR)
    fprintf(stderr, "DTR ");
  if (arg & TIOCM_RNG)
    fprintf(stderr, "RI ");
  fprintf(stderr, "\r\n");
}


x86 assembly (clang, -O0):
<print_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1030 <ioctl@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1030 <ioctl@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    0x2e47(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11a9 <print_status+0x89>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    0x2ded(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11d3 <print_status+0xb3>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    0x2e03(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11fd <print_status+0xdd>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    0x2dd1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1227 <print_status+0x107>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    0x2d97(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1251 <print_status+0x131>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
mov    0x2d55(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     127b <print_status+0x15b>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%edi
lea    0xd9d(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_status>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2e8e(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%r14
mov    %r14,%rdx
call   1030 <ioctl@plt>
mov    0x2e88(%rip),%r15
mov    (%r15),%eax
not    %eax
and    %eax,0xc(%rsp)
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   1030 <ioctl@plt>
mov    0x2e3d(%rip),%rbx
mov    (%rbx),%edi
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
mov    0xc(%rsp),%eax
test   %eax,(%r15)
je     1194 <print_status+0x74>
mov    (%rbx),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    0xc(%rsp),%eax
mov    0x2e05(%rip),%rcx
test   %eax,(%rcx)
je     11b1 <print_status+0x91>
mov    (%rbx),%edi
lea    0xe68(%rip),%rsi
call   1040 <fprintf@plt>
mov    0xc(%rsp),%eax
mov    0x2e28(%rip),%rcx
test   %eax,(%rcx)
je     11ce <print_status+0xae>
mov    (%rbx),%edi
lea    0xe50(%rip),%rsi
call   1040 <fprintf@plt>
mov    0xc(%rsp),%eax
mov    0x2e03(%rip),%rcx
test   %eax,(%rcx)
je     11eb <print_status+0xcb>
mov    (%rbx),%edi
lea    0xe38(%rip),%rsi
call   1040 <fprintf@plt>
mov    0xc(%rsp),%eax
mov    0x2dd6(%rip),%rcx
test   %eax,(%rcx)
je     1208 <print_status+0xe8>
mov    (%rbx),%edi
lea    0xe20(%rip),%rsi
call   1040 <fprintf@plt>
mov    0xc(%rsp),%eax
mov    0x2da1(%rip),%rcx
test   %eax,(%rcx)
je     1221 <print_status+0x101>
mov    (%rbx),%edi
lea    0xe08(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdfe(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@TIOCMGET = global i32 0
@TIOCM_RTS = global i32 0
@TIOCMSET = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"[STATUS]: \00"
@.str.1 = [5 x i8] c"RTS \00"
@TIOCM_CTS = global i32 0
@.str.2 = [5 x i8] c"CTS \00"
@TIOCM_DSR = global i32 0
@.str.3 = [5 x i8] c"DSR \00"
@TIOCM_CAR = global i32 0
@.str.4 = [5 x i8] c"DCD \00"
@TIOCM_DTR = global i32 0
@.str.5 = [5 x i8] c"DTR \00"
@TIOCM_RNG = global i32 0
@.str.6 = [4 x i8] c"RI \00"
@.str.7 = [3 x i8] c"\0D\0A\00"
define void @print_status(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = load i32, i32* @TIOCMGET
%7 = call i32 @ioctl(i32 %5, i32 %6, i32* %4)
store i32 %7, i32* %3
%8 = load i32, i32* @TIOCM_RTS
%9 = xor i32 %8, -1
%10 = load i32, i32* %4
%11 = and i32 %10, %9
store i32 %11, i32* %4
%12 = load i32, i32* %2
%13 = load i32, i32* @TIOCMSET
%14 = call i32 @ioctl(i32 %12, i32 %13, i32* %4)
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %4
%18 = load i32, i32* @TIOCM_RTS
%19 = and i32 %17, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %1
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %1
%25 = load i32, i32* %4
%26 = load i32, i32* @TIOCM_CTS
%27 = and i32 %25, %26
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %29, %24
%33 = load i32, i32* %4
%34 = load i32, i32* @TIOCM_DSR
%35 = and i32 %33, %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %37, %32
%41 = load i32, i32* %4
%42 = load i32, i32* @TIOCM_CAR
%43 = and i32 %41, %42
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %45, %40
%49 = load i32, i32* %4
%50 = load i32, i32* @TIOCM_DTR
%51 = and i32 %49, %50
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %53, %48
%57 = load i32, i32* %4
%58 = load i32, i32* @TIOCM_RNG
%59 = and i32 %57, %58
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %64
64: ; preds = %61, %56
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@TIOCMGET = global i32 0
@TIOCM_RTS = global i32 0
@TIOCMSET = global i32 0
@stderr = global i32 0
@.str = [11 x i8] c"[STATUS]: \00"
@.str.1 = [5 x i8] c"RTS \00"
@TIOCM_CTS = global i32 0
@.str.2 = [5 x i8] c"CTS \00"
@TIOCM_DSR = global i32 0
@.str.3 = [5 x i8] c"DSR \00"
@TIOCM_CAR = global i32 0
@.str.4 = [5 x i8] c"DCD \00"
@TIOCM_DTR = global i32 0
@.str.5 = [5 x i8] c"DTR \00"
@TIOCM_RNG = global i32 0
@.str.6 = [4 x i8] c"RI \00"
@.str.7 = [3 x i8] c"\0D\0A\00"
define void @print_status(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @TIOCMGET
%5 = call i32 @ioctl(i32 %0, i32 %4, i32* %2)
%6 = load i32, i32* @TIOCM_RTS
%7 = xor i32 %6, -1
%8 = load i32, i32* %2
%9 = and i32 %8, %7
store i32 %9, i32* %2
%10 = load i32, i32* @TIOCMSET
%11 = call i32 @ioctl(i32 %0, i32 %10, i32* %2)
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = load i32, i32* @TIOCM_RTS
%16 = and i32 %15, %14
%17 = icmp eq i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %1
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %2
br label %22
22: ; preds = %18, %1
%23 = phi i32 [ %21, %18 ], [ %14, %1 ]
%24 = load i32, i32* @TIOCM_CTS
%25 = and i32 %24, %23
%26 = icmp eq i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* %2
br label %31
31: ; preds = %27, %22
%32 = phi i32 [ %30, %27 ], [ %23, %22 ]
%33 = load i32, i32* @TIOCM_DSR
%34 = and i32 %33, %32
%35 = icmp eq i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* %2
br label %40
40: ; preds = %36, %31
%41 = phi i32 [ %39, %36 ], [ %32, %31 ]
%42 = load i32, i32* @TIOCM_CAR
%43 = and i32 %42, %41
%44 = icmp eq i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %40
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%48 = load i32, i32* %2
br label %49
49: ; preds = %45, %40
%50 = phi i32 [ %48, %45 ], [ %41, %40 ]
%51 = load i32, i32* @TIOCM_DTR
%52 = and i32 %51, %50
%53 = icmp eq i32 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %49
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%57 = load i32, i32* %2
br label %58
58: ; preds = %54, %49
%59 = phi i32 [ %57, %54 ], [ %50, %49 ]
%60 = load i32, i32* @TIOCM_RNG
%61 = and i32 %60, %59
%62 = icmp eq i32 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %58
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %66
66: ; preds = %63, %58
%67 = load i32, i32* @stderr
%68 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
ret void
}