#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 */
struct termios {
  int c_cflag;
  int c_iflag;
};

/* Variables and functions */
int CRTSCTS;
int CS5;
int CS6;
int CS7;
int CS8;
int CSIZE;
int CSTOPB;
int FileDescrForEntry(int);
int IXOFF;
int IXON;
int PARENB;
int PARODD;
int /*<<< orphan*/ TIOCMGET;
int TIOCM_CD;
int TIOCM_CTS;
int TIOCM_DSR;
int TIOCM_DTR;
int TIOCM_RI;
int TIOCM_RTS;
scalar_t__ cfgetispeed(struct termios *);
int ioctl(int, int /*<<< orphan*/, int *);
int tcgetattr(int, struct termios *);
int SerialPortGetOption(int portNum, int optionNum) {
  int fDescr, handshake = -1;
  struct termios options;
  if ((fDescr = FileDescrForEntry(portNum)) < 0)
    return -1;
  if (tcgetattr(fDescr, &options) == -1)
    return -1;
  if (ioctl(fDescr, TIOCMGET, &handshake) == -1)
    return -1;
  switch (optionNum) {
  case 1:
    return (int)cfgetispeed(&options);
  case 2:
    if ((options.c_cflag & CSIZE) == CS5)
      return 5;
    if ((options.c_cflag & CSIZE) == CS6)
      return 6;
    if ((options.c_cflag & CSIZE) == CS7)
      return 7;
    if ((options.c_cflag & CSIZE) == CS8)
      return 8;
    return -1;
  case 3:
    return (options.c_cflag & CSTOPB) ? 2 : 1;
  case 4:
    if (!(options.c_cflag & PARENB))
      return 0;
    return (options.c_cflag & PARODD) ? 1 : 2;
  case 5:
    if (options.c_iflag & IXOFF)
      return 1;
    if (options.c_cflag & CRTSCTS)
      return 2;
    return 0;
  case 6:
    if (options.c_iflag & IXON)
      return 1;
    if (options.c_cflag & CRTSCTS)
      return 2;
    return 0;
  case 20:
    return (handshake & TIOCM_DTR) > 0;
  case 21:
    return (handshake & TIOCM_RTS) > 0;
  case 22:
    return (handshake & TIOCM_CTS) > 0;
  case 23:
    return (handshake & TIOCM_DSR) > 0;
  case 24:
    return (handshake & TIOCM_CD) > 0;
  case 25:
    return (handshake & TIOCM_RI) > 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<SerialPortGetOption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <FileDescrForEntry@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1175 <SerialPortGetOption+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x10(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1060 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    1196 <SerialPortGetOption+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x10(%rbp),%edi
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
lea    -0x14(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    11c0 <SerialPortGetOption+0x80>
movl   $0xffffffff,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x18,%eax
ja     1461 <SerialPortGetOption+0x321>
mov    -0x28(%rbp),%rax
lea    0xe20(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x20(%rbp),%rdi
call   1030 <cfgetispeed@plt>
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%eax
mov    0x2d94(%rip),%rcx
and    (%rcx),%eax
mov    0x2d4b(%rip),%rcx
cmp    (%rcx),%eax
jne    1221 <SerialPortGetOption+0xe1>
movl   $0x5,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%eax
mov    0x2d6d(%rip),%rcx
and    (%rcx),%eax
mov    0x2d74(%rip),%rcx
cmp    (%rcx),%eax
jne    1248 <SerialPortGetOption+0x108>
movl   $0x6,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%eax
mov    0x2d46(%rip),%rcx
and    (%rcx),%eax
mov    0x2cf5(%rip),%rcx
cmp    (%rcx),%eax
jne    126f <SerialPortGetOption+0x12f>
movl   $0x7,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%eax
mov    0x2d1f(%rip),%rcx
and    (%rcx),%eax
mov    0x2d1e(%rip),%rcx
cmp    (%rcx),%eax
jne    1296 <SerialPortGetOption+0x156>
movl   $0x8,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
movl   $0xffffffff,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%edx
mov    0x2cb4(%rip),%rax
and    (%rax),%edx
mov    $0x1,%eax
mov    $0x2,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%eax
mov    0x2cf8(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    12e7 <SerialPortGetOption+0x1a7>
movl   $0x0,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%edx
mov    0x2cc7(%rip),%rax
and    (%rax),%edx
mov    $0x2,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x1c(%rbp),%eax
mov    0x2cd3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     132c <SerialPortGetOption+0x1ec>
movl   $0x1,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%eax
mov    0x2c32(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     134d <SerialPortGetOption+0x20d>
movl   $0x2,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
movl   $0x0,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x1c(%rbp),%eax
mov    0x2c6d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     137a <SerialPortGetOption+0x23a>
movl   $0x1,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x20(%rbp),%eax
mov    0x2be4(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     139b <SerialPortGetOption+0x25b>
movl   $0x2,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
movl   $0x0,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x14(%rbp),%eax
mov    0x2bff(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x14(%rbp),%eax
mov    0x2bf0(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x14(%rbp),%eax
mov    0x2b91(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x14(%rbp),%eax
mov    0x2bca(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x14(%rbp),%eax
mov    0x2b4b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
mov    -0x14(%rbp),%eax
mov    0x2b94(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1468 <SerialPortGetOption+0x328>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SerialPortGetOption>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
movl   $0xffffffff,0x4(%rsp)
ff
call   1050 <FileDescrForEntry@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
js     12fa <SerialPortGetOption+0x1ba>
mov    %eax,%ebp
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1060 <tcgetattr@plt>
cmp    $0xffffffff,%eax
je     12fa <SerialPortGetOption+0x1ba>
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
call   1040 <ioctl@plt>
cmp    $0xffffffff,%eax
je     12fa <SerialPortGetOption+0x1ba>
add    $0xffffffff,%ebx
cmp    $0x18,%ebx
ja     12fa <SerialPortGetOption+0x1ba>
lea    0xe53(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0x8(%rsp),%rdi
call   1030 <cfgetispeed@plt>
mov    %rax,%r14
jmp    12fa <SerialPortGetOption+0x1ba>
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
and    0x8(%rsp),%eax
cmp    $0x1,%eax
mov    $0x2,%r14d
sbb    $0x0,%r14d
jmp    12fa <SerialPortGetOption+0x1ba>
mov    0x2de2(%rip),%rax
jmp    12a4 <SerialPortGetOption+0x164>
mov    0x2d7e(%rip),%rax
jmp    12ed <SerialPortGetOption+0x1ad>
mov    0x2dda(%rip),%rax
jmp    12ed <SerialPortGetOption+0x1ad>
mov    0x2d86(%rip),%rax
mov    (%rax),%eax
and    0x8(%rsp),%eax
mov    0x2d39(%rip),%rcx
mov    $0x5,%r14d
cmp    (%rcx),%eax
je     12fa <SerialPortGetOption+0x1ba>
mov    0x2d74(%rip),%rcx
mov    $0x6,%r14d
cmp    (%rcx),%eax
je     12fa <SerialPortGetOption+0x1ba>
mov    0x2d07(%rip),%rcx
mov    $0x7,%r14d
cmp    (%rcx),%eax
je     12fa <SerialPortGetOption+0x1ba>
mov    0x2d42(%rip),%rcx
xor    %edx,%edx
cmp    (%rcx),%eax
sete   %dl
lea    (%rdx,%rdx,8),%r14d
add    $0xffffffff,%r14d
jmp    12fa <SerialPortGetOption+0x1ba>
mov    0x8(%rsp),%eax
mov    0x2d4b(%rip),%rcx
test   %eax,(%rcx)
je     1306 <SerialPortGetOption+0x1c6>
mov    0x2d2c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x1,%eax
mov    $0x1,%r14d
adc    $0x0,%r14d
jmp    12fa <SerialPortGetOption+0x1ba>
mov    0x2d44(%rip),%rax
mov    (%rax),%eax
mov    $0x1,%r14d
test   %eax,0xc(%rsp)
jne    12fa <SerialPortGetOption+0x1ba>
mov    0x2caf(%rip),%rax
mov    (%rax),%eax
xor    %r14d,%r14d
test   %eax,0x8(%rsp)
setne  %r14b
add    %r14d,%r14d
jmp    12fa <SerialPortGetOption+0x1ba>
mov    0x2cde(%rip),%rax
jmp    12ed <SerialPortGetOption+0x1ad>
mov    0x2ce5(%rip),%rax
jmp    12ed <SerialPortGetOption+0x1ad>
mov    0x2c9c(%rip),%rax
jmp    12ed <SerialPortGetOption+0x1ad>
mov    0x2ceb(%rip),%rax
mov    (%rax),%eax
xor    %r14d,%r14d
test   %eax,0x4(%rsp)
setg   %r14b
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %r14d,%r14d
jmp    12fa <SerialPortGetOption+0x1ba>

LLVM IR (-O0):
%struct.termios = type { i32, i32 }
@TIOCMGET = global i32 0
@CSIZE = global i32 0
@CS5 = global i32 0
@CS6 = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@CSTOPB = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@IXOFF = global i32 0
@CRTSCTS = global i32 0
@IXON = global i32 0
@TIOCM_DTR = global i32 0
@TIOCM_RTS = global i32 0
@TIOCM_CTS = global i32 0
@TIOCM_DSR = global i32 0
@TIOCM_CD = global i32 0
@TIOCM_RI = global i32 0
define i32 @SerialPortGetOption(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.termios
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 -1, i32* %7
%9 = load i32, i32* %4
%10 = call i32 @FileDescrForEntry(i32 %9)
store i32 %10, i32* %6
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %152
13: ; preds = %2
%14 = load i32, i32* %6
%15 = call i32 @tcgetattr(i32 %14, %struct.termios* %8)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 -1, i32* %3
br label %152
18: ; preds = %13
%19 = load i32, i32* %6
%20 = load i32, i32* @TIOCMGET
%21 = call i32 @ioctl(i32 %19, i32 %20, i32* %7)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %3
br label %152
24: ; preds = %18
%25 = load i32, i32* %5
switch i32 %25, label %151 [
i32 1, label %26
i32 2, label %29
i32 3, label %62
i32 4, label %70
i32 5, label %85
i32 6, label %100
i32 20, label %115
i32 21, label %121
i32 22, label %127
i32 23, label %133
i32 24, label %139
i32 25, label %145
]
26: ; preds = %24
%27 = call i64 @cfgetispeed(%struct.termios* %8)
%28 = trunc i64 %27 to i32
store i32 %28, i32* %3
br label %152
29: ; preds = %24
%30 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%31 = load i32, i32* %30
%32 = load i32, i32* @CSIZE
%33 = and i32 %31, %32
%34 = load i32, i32* @CS5
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %29
store i32 5, i32* %3
br label %152
37: ; preds = %29
%38 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%39 = load i32, i32* %38
%40 = load i32, i32* @CSIZE
%41 = and i32 %39, %40
%42 = load i32, i32* @CS6
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %45
44: ; preds = %37
store i32 6, i32* %3
br label %152
45: ; preds = %37
%46 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%47 = load i32, i32* %46
%48 = load i32, i32* @CSIZE
%49 = and i32 %47, %48
%50 = load i32, i32* @CS7
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %53
52: ; preds = %45
store i32 7, i32* %3
br label %152
53: ; preds = %45
%54 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%55 = load i32, i32* %54
%56 = load i32, i32* @CSIZE
%57 = and i32 %55, %56
%58 = load i32, i32* @CS8
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %61
60: ; preds = %53
store i32 8, i32* %3
br label %152
61: ; preds = %53
store i32 -1, i32* %3
br label %152
62: ; preds = %24
%63 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%64 = load i32, i32* %63
%65 = load i32, i32* @CSTOPB
%66 = and i32 %64, %65
%67 = icmp ne i32 %66, 0
%68 = zext i1 %67 to i64
%69 = select i1 %67, i32 2, i32 1
store i32 %69, i32* %3
br label %152
70: ; preds = %24
%71 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%72 = load i32, i32* %71
%73 = load i32, i32* @PARENB
%74 = and i32 %72, %73
%75 = icmp ne i32 %74, 0
br i1 %75, label %77, label %76
76: ; preds = %70
store i32 0, i32* %3
br label %152
77: ; preds = %70
%78 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%79 = load i32, i32* %78
%80 = load i32, i32* @PARODD
%81 = and i32 %79, %80
%82 = icmp ne i32 %81, 0
%83 = zext i1 %82 to i64
%84 = select i1 %82, i32 1, i32 2
store i32 %84, i32* %3
br label %152
85: ; preds = %24
%86 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 1
%87 = load i32, i32* %86
%88 = load i32, i32* @IXOFF
%89 = and i32 %87, %88
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %92
91: ; preds = %85
store i32 1, i32* %3
br label %152
92: ; preds = %85
%93 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%94 = load i32, i32* %93
%95 = load i32, i32* @CRTSCTS
%96 = and i32 %94, %95
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %92
store i32 2, i32* %3
br label %152
99: ; preds = %92
store i32 0, i32* %3
br label %152
100: ; preds = %24
%101 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 1
%102 = load i32, i32* %101
%103 = load i32, i32* @IXON
%104 = and i32 %102, %103
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %107
106: ; preds = %100
store i32 1, i32* %3
br label %152
107: ; preds = %100
%108 = getelementptr inbounds %struct.termios, %struct.termios* %8, i32 0, i32 0
%109 = load i32, i32* %108
%110 = load i32, i32* @CRTSCTS
%111 = and i32 %109, %110
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %114
113: ; preds = %107
store i32 2, i32* %3
br label %152
114: ; preds = %107
store i32 0, i32* %3
br label %152
115: ; preds = %24
%116 = load i32, i32* %7
%117 = load i32, i32* @TIOCM_DTR
%118 = and i32 %116, %117
%119 = icmp sgt i32 %118, 0
%120 = zext i1 %119 to i32
store i32 %120, i32* %3
br label %152
121: ; preds = %24
%122 = load i32, i32* %7
%123 = load i32, i32* @TIOCM_RTS
%124 = and i32 %122, %123
%125 = icmp sgt i32 %124, 0
%126 = zext i1 %125 to i32
store i32 %126, i32* %3
br label %152
127: ; preds = %24
%128 = load i32, i32* %7
%129 = load i32, i32* @TIOCM_CTS
%130 = and i32 %128, %129
%131 = icmp sgt i32 %130, 0
%132 = zext i1 %131 to i32
store i32 %132, i32* %3
br label %152
133: ; preds = %24
%134 = load i32, i32* %7
%135 = load i32, i32* @TIOCM_DSR
%136 = and i32 %134, %135
%137 = icmp sgt i32 %136, 0
%138 = zext i1 %137 to i32
store i32 %138, i32* %3
br label %152
139: ; preds = %24
%140 = load i32, i32* %7
%141 = load i32, i32* @TIOCM_CD
%142 = and i32 %140, %141
%143 = icmp sgt i32 %142, 0
%144 = zext i1 %143 to i32
store i32 %144, i32* %3
br label %152
145: ; preds = %24
%146 = load i32, i32* %7
%147 = load i32, i32* @TIOCM_RI
%148 = and i32 %146, %147
%149 = icmp sgt i32 %148, 0
%150 = zext i1 %149 to i32
store i32 %150, i32* %3
br label %152
151: ; preds = %24
store i32 -1, i32* %3
br label %152
152: ; preds = %151, %145, %139, %133, %127, %121, %115, %114, %113, %106, %99, %98, %91, %77, %76, %62, %61, %60, %52, %44, %36, %26, %23, %17, %12
%153 = load i32, i32* %3
ret i32 %153
}

LLVM IR (-O2):
%struct.termios = type { i32, i32 }
@TIOCMGET = global i32 0
@CSIZE = global i32 0
@CS5 = global i32 0
@CS6 = global i32 0
@CS7 = global i32 0
@CS8 = global i32 0
@CSTOPB = global i32 0
@PARENB = global i32 0
@PARODD = global i32 0
@IXOFF = global i32 0
@CRTSCTS = global i32 0
@IXON = global i32 0
@TIOCM_DTR = global i32 0
@TIOCM_RTS = global i32 0
@TIOCM_CTS = global i32 0
@TIOCM_DSR = global i32 0
@TIOCM_CD = global i32 0
@TIOCM_RI = global i32 0
define i32 @SerialPortGetOption(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.termios
%5 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%6 = bitcast %struct.termios* %4 to i8*
%7 = tail call i32 @FileDescrForEntry(i32 %0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %117, label %9
9: ; preds = %2
%10 = call i32 @tcgetattr(i32 %7, %struct.termios* %4)
%11 = icmp eq i32 %10, -1
br i1 %11, label %117, label %12
12: ; preds = %9
%13 = load i32, i32* @TIOCMGET
%14 = call i32 @ioctl(i32 %7, i32 %13, i32* %3)
%15 = icmp eq i32 %14, -1
br i1 %15, label %117, label %16
16: ; preds = %12
switch i32 %1, label %117 [
i32 1, label %17
i32 2, label %20
i32 3, label %37
i32 4, label %44
i32 5, label %55
i32 6, label %68
i32 20, label %81
i32 21, label %87
i32 22, label %93
i32 23, label %99
i32 24, label %105
i32 25, label %111
]
17: ; preds = %16
%18 = call i64 @cfgetispeed(%struct.termios* %4)
%19 = trunc i64 %18 to i32
br label %117
20: ; preds = %16
%21 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%22 = load i32, i32* %21
%23 = load i32, i32* @CSIZE
%24 = and i32 %23, %22
%25 = load i32, i32* @CS5
%26 = icmp eq i32 %24, %25
br i1 %26, label %117, label %27
27: ; preds = %20
%28 = load i32, i32* @CS6
%29 = icmp eq i32 %24, %28
br i1 %29, label %117, label %30
30: ; preds = %27
%31 = load i32, i32* @CS7
%32 = icmp eq i32 %24, %31
br i1 %32, label %117, label %33
33: ; preds = %30
%34 = load i32, i32* @CS8
%35 = icmp eq i32 %24, %34
%36 = select i1 %35, i32 8, i32 -1
br label %117
37: ; preds = %16
%38 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%39 = load i32, i32* %38
%40 = load i32, i32* @CSTOPB
%41 = and i32 %40, %39
%42 = icmp eq i32 %41, 0
%43 = select i1 %42, i32 1, i32 2
br label %117
44: ; preds = %16
%45 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%46 = load i32, i32* %45
%47 = load i32, i32* @PARENB
%48 = and i32 %47, %46
%49 = icmp eq i32 %48, 0
br i1 %49, label %117, label %50
50: ; preds = %44
%51 = load i32, i32* @PARODD
%52 = and i32 %51, %46
%53 = icmp eq i32 %52, 0
%54 = select i1 %53, i32 2, i32 1
br label %117
55: ; preds = %16
%56 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 1
%57 = load i32, i32* %56
%58 = load i32, i32* @IXOFF
%59 = and i32 %58, %57
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %117
61: ; preds = %55
%62 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%63 = load i32, i32* %62
%64 = load i32, i32* @CRTSCTS
%65 = and i32 %64, %63
%66 = icmp eq i32 %65, 0
%67 = select i1 %66, i32 0, i32 2
br label %117
68: ; preds = %16
%69 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 1
%70 = load i32, i32* %69
%71 = load i32, i32* @IXON
%72 = and i32 %71, %70
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %117
74: ; preds = %68
%75 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
%76 = load i32, i32* %75
%77 = load i32, i32* @CRTSCTS
%78 = and i32 %77, %76
%79 = icmp eq i32 %78, 0
%80 = select i1 %79, i32 0, i32 2
br label %117
81: ; preds = %16
%82 = load i32, i32* %3
%83 = load i32, i32* @TIOCM_DTR
%84 = and i32 %83, %82
%85 = icmp sgt i32 %84, 0
%86 = zext i1 %85 to i32
br label %117
87: ; preds = %16
%88 = load i32, i32* %3
%89 = load i32, i32* @TIOCM_RTS
%90 = and i32 %89, %88
%91 = icmp sgt i32 %90, 0
%92 = zext i1 %91 to i32
br label %117
93: ; preds = %16
%94 = load i32, i32* %3
%95 = load i32, i32* @TIOCM_CTS
%96 = and i32 %95, %94
%97 = icmp sgt i32 %96, 0
%98 = zext i1 %97 to i32
br label %117
99: ; preds = %16
%100 = load i32, i32* %3
%101 = load i32, i32* @TIOCM_DSR
%102 = and i32 %101, %100
%103 = icmp sgt i32 %102, 0
%104 = zext i1 %103 to i32
br label %117
105: ; preds = %16
%106 = load i32, i32* %3
%107 = load i32, i32* @TIOCM_CD
%108 = and i32 %107, %106
%109 = icmp sgt i32 %108, 0
%110 = zext i1 %109 to i32
br label %117
111: ; preds = %16
%112 = load i32, i32* %3
%113 = load i32, i32* @TIOCM_RI
%114 = and i32 %113, %112
%115 = icmp sgt i32 %114, 0
%116 = zext i1 %115 to i32
br label %117
117: ; preds = %16, %74, %68, %61, %55, %44, %33, %30, %27, %20, %12, %9, %2, %111, %105, %99, %93, %87, %81, %50, %37, %17
%118 = phi i32 [ %116, %111 ], [ %110, %105 ], [ %104, %99 ], [ %98, %93 ], [ %92, %87 ], [ %86, %81 ], [ %54, %50 ], [ %43, %37 ], [ %19, %17 ], [ -1, %2 ], [ -1, %9 ], [ -1, %12 ], [ 5, %20 ], [ 6, %27 ], [ 7, %30 ], [ %36, %33 ], [ 0, %44 ], [ 1, %55 ], [ %67, %61 ], [ 1, %68 ], [ %80, %74 ], [ -1, %16 ]
ret i32 %118
}