#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 ENOTTY;
int EPERM;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_RDWR;
unsigned long TCFLSH;
unsigned long TCIOFLUSH;
unsigned long TIOCSTI;
int /*<<< orphan*/ close(int);
int errno;
int ioctl64(int, unsigned long, unsigned long);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int res;
  int saved_errno;
  char pushmeback = '#';
  int fd = open("/dev/null", O_RDWR);
  int rc = EXIT_FAILURE;
  if (fd < 0) {
    perror("cannot open /dev/null");
    return rc;
  }
  if (argc == 2 && strcmp(argv[1], "--evil") == 0) {
    res = ioctl64(fd, TIOCSTI, (unsigned long)&pushmeback);
    saved_errno = errno;
    printf("normal TIOCSTI: %d (%m) (expect EPERM)\n", res);
    if (res < 0 && saved_errno == EPERM) {
      rc = EXIT_SUCCESS;
    }
  } else if (argc == 2 && strcmp(argv[1], "--evil-high") == 0) {
    res = ioctl64(fd, TIOCSTI | (1UL << 32UL), (unsigned long)&pushmeback);
    saved_errno = errno;
    printf("high-bit-set TIOCSTI: %d (%m) (expect EPERM)\n", res);
    if (res < 0 && saved_errno == EPERM) {
      rc = EXIT_SUCCESS;
    }
  } else if (argc == 2 && strcmp(argv[1], "--good") == 0) {
    res = ioctl64(fd, TCFLSH, TCIOFLUSH);
    saved_errno = errno;
    printf("unrelated TCFLSH: %d (%m) (expect ENOTTY)\n", res);
    if (res < 0 && saved_errno == ENOTTY) {
      rc = EXIT_SUCCESS;
    }
  } else if (argc == 2 && strcmp(argv[1], "--good-high") == 0) {
    res = ioctl64(fd, TCFLSH | (1UL << 32UL), TCIOFLUSH);
    saved_errno = errno;
    printf("unrelated TCFLSH: %d (%m) (expect ENOTTY)\n", res);
    if (res < 0 && saved_errno == ENOTTY) {
      rc = EXIT_SUCCESS;
    }
  } else {
    printf("Usage: lp-1812973 --{evil,good}{,-high}\n");
    rc = EXIT_SUCCESS;
  }
  close(fd);
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x23,-0x19(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
lea    0xe82(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    11bf <main+0x5f>
lea    0xe51(%rip),%rdi
call   1070 <perror@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1442 <main+0x2e2>
cmpl   $0x2,-0x8(%rbp)
jne    124a <main+0xea>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    124a <main+0xea>
mov    -0x20(%rbp),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%rsi
lea    -0x19(%rbp),%rdx
call   1080 <ioctl64@plt>
mov    %eax,-0x14(%rbp)
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    1245 <main+0xe5>
mov    -0x18(%rbp),%eax
mov    0x2d67(%rip),%rcx
cmp    (%rcx),%eax
jne    1245 <main+0xe5>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1434 <main+0x2d4>
cmpl   $0x2,-0x8(%rbp)
jne    12df <main+0x17f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde2(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12df <main+0x17f>
mov    -0x20(%rbp),%edi
mov    0x2d64(%rip),%rax
movabs $0x100000000,%rsi
or     (%rax),%rsi
lea    -0x19(%rbp),%rdx
call   1080 <ioctl64@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    12da <main+0x17a>
mov    -0x18(%rbp),%eax
mov    0x2cd2(%rip),%rcx
cmp    (%rcx),%eax
jne    12da <main+0x17a>
mov    0x2cd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    142f <main+0x2cf>
cmpl   $0x2,-0x8(%rbp)
jne    1370 <main+0x210>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd87(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1370 <main+0x210>
mov    -0x20(%rbp),%edi
mov    0x2cb7(%rip),%rax
mov    (%rax),%rsi
mov    0x2c9d(%rip),%rax
mov    (%rax),%rdx
call   1080 <ioctl64@plt>
mov    %eax,-0x14(%rbp)
mov    0x2c93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    136b <main+0x20b>
mov    -0x18(%rbp),%eax
mov    0x2c81(%rip),%rcx
cmp    (%rcx),%eax
jne    136b <main+0x20b>
mov    0x2c42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    142a <main+0x2ca>
cmpl   $0x2,-0x8(%rbp)
jne    140b <main+0x2ab>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd28(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    140b <main+0x2ab>
mov    -0x20(%rbp),%edi
mov    0x2c26(%rip),%rax
movabs $0x100000000,%rsi
or     (%rax),%rsi
mov    0x2c02(%rip),%rax
mov    (%rax),%rdx
call   1080 <ioctl64@plt>
mov    %eax,-0x14(%rbp)
mov    0x2bf8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    1406 <main+0x2a6>
mov    -0x18(%rbp),%eax
mov    0x2be6(%rip),%rcx
cmp    (%rcx),%eax
jne    1406 <main+0x2a6>
mov    0x2ba7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1425 <main+0x2c5>
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2b88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    142a <main+0x2ca>
jmp    142f <main+0x2cf>
jmp    1434 <main+0x2d4>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%ebx
movb   $0x23,0x7(%rsp)
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
lea    0xe7b(%rip),%rdi
call   1070 <open@plt>
mov    %eax,%r14d
mov    0x2e10(%rip),%rax
mov    (%rax),%r15d
test   %r14d,%r14d
js     12a4 <main+0x134>
cmp    $0x2,%ebx
jne    120d <main+0x9d>
mov    0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1228 <main+0xb8>
mov    0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1253 <main+0xe3>
mov    0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1298 <main+0x128>
mov    0x8(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12b2 <main+0x142>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%r15d
jmp    1310 <main+0x1a0>
mov    0x2db1(%rip),%rax
mov    (%rax),%rsi
lea    0x7(%rsp),%rdx
mov    %r14d,%edi
call   1090 <ioctl64@plt>
mov    %eax,%ebp
mov    0x2d78(%rip),%rax
mov    (%rax),%ebx
lea    0xdcc(%rip),%rdi
jmp    1286 <main+0x116>
mov    0x2d86(%rip),%rax
movabs $0x100000000,%rsi
or     (%rax),%rsi
lea    0x7(%rsp),%rdx
mov    %r14d,%edi
call   1090 <ioctl64@plt>
mov    %eax,%ebp
mov    0x2d43(%rip),%rax
mov    (%rax),%ebx
lea    0xdcb(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d02(%rip),%rcx
jmp    12fa <main+0x18a>
mov    0x2d29(%rip),%rax
mov    (%rax),%rsi
jmp    12c6 <main+0x156>
lea    0xd55(%rip),%rdi
call   1080 <perror@plt>
jmp    1318 <main+0x1a8>
mov    0x2d0f(%rip),%rax
movabs $0x100000000,%rsi
or     (%rax),%rsi
mov    0x2ceb(%rip),%rax
mov    (%rax),%rdx
mov    %r14d,%edi
call   1090 <ioctl64@plt>
mov    %eax,%ebp
mov    0x2cdf(%rip),%rax
mov    (%rax),%ebx
lea    0xd9c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2cde(%rip),%rcx
mov    %r15d,%eax
cmp    (%rcx),%ebx
jne    130a <main+0x19a>
mov    0x2ca0(%rip),%rax
mov    (%rax),%eax
test   %ebp,%ebp
cmovs  %eax,%r15d
mov    %r14d,%edi
call   1050 <close@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [22 x i8] c"cannot open /dev/null\00"
@.str.2 = [7 x i8] c"--evil\00"
@TIOCSTI = global i64 0
@errno = global i32 0
@.str.3 = [40 x i8] c"normal TIOCSTI: %d (%m) (expect EPERM)\0A\00"
@EPERM = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.4 = [12 x i8] c"--evil-high\00"
@.str.5 = [46 x i8] c"high-bit-set TIOCSTI: %d (%m) (expect EPERM)\0A\00"
@.str.6 = [7 x i8] c"--good\00"
@TCFLSH = global i64 0
@TCIOFLUSH = global i64 0
@.str.7 = [43 x i8] c"unrelated TCFLSH: %d (%m) (expect ENOTTY)\0A\00"
@ENOTTY = global i32 0
@.str.8 = [12 x i8] c"--good-high\00"
@.str.9 = [41 x i8] c"Usage: lp-1812973 --{evil,good}{,-high}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 35, i8* %8
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %9
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %10
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* %10
store i32 %18, i32* %3
br label %135
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %45
22: ; preds = %19
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %45
28: ; preds = %22
%29 = load i32, i32* %9
%30 = load i64, i64* @TIOCSTI
%31 = ptrtoint i8* %8 to i64
%32 = call i32 @ioctl64(i32 %29, i64 %30, i64 %31)
store i32 %32, i32* %6
%33 = load i32, i32* @errno
store i32 %33, i32* %7
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %28
%39 = load i32, i32* %7
%40 = load i32, i32* @EPERM
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = load i32, i32* @EXIT_SUCCESS
store i32 %43, i32* %10
br label %44
44: ; preds = %42, %38, %28
br label %131
45: ; preds = %22, %19
%46 = load i32, i32* %4
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %72
48: ; preds = %45
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %72
54: ; preds = %48
%55 = load i32, i32* %9
%56 = load i64, i64* @TIOCSTI
%57 = or i64 %56, 4294967296
%58 = ptrtoint i8* %8 to i64
%59 = call i32 @ioctl64(i32 %55, i64 %57, i64 %58)
store i32 %59, i32* %6
%60 = load i32, i32* @errno
store i32 %60, i32* %7
%61 = load i32, i32* %6
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %6
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %54
%66 = load i32, i32* %7
%67 = load i32, i32* @EPERM
%68 = icmp eq i32 %66, %67
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = load i32, i32* @EXIT_SUCCESS
store i32 %70, i32* %10
br label %71
71: ; preds = %69, %65, %54
br label %130
72: ; preds = %48, %45
%73 = load i32, i32* %4
%74 = icmp eq i32 %73, 2
br i1 %74, label %75, label %98
75: ; preds = %72
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 1
%78 = load i8*, i8** %77
%79 = call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %98
81: ; preds = %75
%82 = load i32, i32* %9
%83 = load i64, i64* @TCFLSH
%84 = load i64, i64* @TCIOFLUSH
%85 = call i32 @ioctl64(i32 %82, i64 %83, i64 %84)
store i32 %85, i32* %6
%86 = load i32, i32* @errno
store i32 %86, i32* %7
%87 = load i32, i32* %6
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %87)
%89 = load i32, i32* %6
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %97
91: ; preds = %81
%92 = load i32, i32* %7
%93 = load i32, i32* @ENOTTY
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %97
95: ; preds = %91
%96 = load i32, i32* @EXIT_SUCCESS
store i32 %96, i32* %10
br label %97
97: ; preds = %95, %91, %81
br label %129
98: ; preds = %75, %72
%99 = load i32, i32* %4
%100 = icmp eq i32 %99, 2
br i1 %100, label %101, label %125
101: ; preds = %98
%102 = load i8**, i8*** %5
%103 = getelementptr inbounds i8*, i8** %102, i64 1
%104 = load i8*, i8** %103
%105 = call i64 @strcmp(i8* %104, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %125
107: ; preds = %101
%108 = load i32, i32* %9
%109 = load i64, i64* @TCFLSH
%110 = or i64 %109, 4294967296
%111 = load i64, i64* @TCIOFLUSH
%112 = call i32 @ioctl64(i32 %108, i64 %110, i64 %111)
store i32 %112, i32* %6
%113 = load i32, i32* @errno
store i32 %113, i32* %7
%114 = load i32, i32* %6
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %114)
%116 = load i32, i32* %6
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %124
118: ; preds = %107
%119 = load i32, i32* %7
%120 = load i32, i32* @ENOTTY
%121 = icmp eq i32 %119, %120
br i1 %121, label %122, label %124
122: ; preds = %118
%123 = load i32, i32* @EXIT_SUCCESS
store i32 %123, i32* %10
br label %124
124: ; preds = %122, %118, %107
br label %128
125: ; preds = %101, %98
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
%127 = load i32, i32* @EXIT_SUCCESS
store i32 %127, i32* %10
br label %128
128: ; preds = %125, %124
br label %129
129: ; preds = %128, %97
br label %130
130: ; preds = %129, %71
br label %131
131: ; preds = %130, %44
%132 = load i32, i32* %9
%133 = call i32 @close(i32 %132)
%134 = load i32, i32* %10
store i32 %134, i32* %3
br label %135
135: ; preds = %131, %16
%136 = load i32, i32* %3
ret i32 %136
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/null\00"
@O_RDWR = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [22 x i8] c"cannot open /dev/null\00"
@.str.2 = [7 x i8] c"--evil\00"
@TIOCSTI = global i64 0
@errno = global i32 0
@.str.3 = [40 x i8] c"normal TIOCSTI: %d (%m) (expect EPERM)\0A\00"
@EPERM = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.4 = [12 x i8] c"--evil-high\00"
@.str.5 = [46 x i8] c"high-bit-set TIOCSTI: %d (%m) (expect EPERM)\0A\00"
@.str.6 = [7 x i8] c"--good\00"
@TCFLSH = global i64 0
@TCIOFLUSH = global i64 0
@.str.7 = [43 x i8] c"unrelated TCFLSH: %d (%m) (expect ENOTTY)\0A\00"
@ENOTTY = global i32 0
@.str.8 = [12 x i8] c"--good-high\00"
@str = [40 x i8] c"Usage: lp-1812973 --{evil,good}{,-high}\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
store i8 35, i8* %3
%4 = load i32, i32* @O_RDWR
%5 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @EXIT_FAILURE
%7 = icmp slt i32 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %85
10: ; preds = %2
%11 = icmp eq i32 %0, 2
br i1 %11, label %12, label %79
12: ; preds = %10
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i64, i64* @TIOCSTI
%19 = ptrtoint i8* %3 to i64
%20 = call i32 @ioctl64(i32 %5, i64 %18, i64 %19)
%21 = load i32, i32* @errno
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%23 = icmp slt i32 %20, 0
%24 = load i32, i32* @EPERM
%25 = icmp eq i32 %21, %24
%26 = select i1 %23, i1 %25, i1 false
%27 = load i32, i32* @EXIT_SUCCESS
%28 = select i1 %26, i32 %27, i32 %6
br label %82
29: ; preds = %12
%30 = load i8*, i8** %13
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %46
33: ; preds = %29
%34 = load i64, i64* @TIOCSTI
%35 = or i64 %34, 4294967296
%36 = ptrtoint i8* %3 to i64
%37 = call i32 @ioctl64(i32 %5, i64 %35, i64 %36)
%38 = load i32, i32* @errno
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%40 = icmp slt i32 %37, 0
%41 = load i32, i32* @EPERM
%42 = icmp eq i32 %38, %41
%43 = select i1 %40, i1 %42, i1 false
%44 = load i32, i32* @EXIT_SUCCESS
%45 = select i1 %43, i32 %44, i32 %6
br label %82
46: ; preds = %29
%47 = load i8*, i8** %13
%48 = tail call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %62
50: ; preds = %46
%51 = load i64, i64* @TCFLSH
%52 = load i64, i64* @TCIOFLUSH
%53 = tail call i32 @ioctl64(i32 %5, i64 %51, i64 %52)
%54 = load i32, i32* @errno
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%56 = icmp slt i32 %53, 0
%57 = load i32, i32* @ENOTTY
%58 = icmp eq i32 %54, %57
%59 = select i1 %56, i1 %58, i1 false
%60 = load i32, i32* @EXIT_SUCCESS
%61 = select i1 %59, i32 %60, i32 %6
br label %82
62: ; preds = %46
%63 = load i8*, i8** %13
%64 = tail call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %79
66: ; preds = %62
%67 = load i64, i64* @TCFLSH
%68 = or i64 %67, 4294967296
%69 = load i64, i64* @TCIOFLUSH
%70 = tail call i32 @ioctl64(i32 %5, i64 %68, i64 %69)
%71 = load i32, i32* @errno
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), i32 %70)
%73 = icmp slt i32 %70, 0
%74 = load i32, i32* @ENOTTY
%75 = icmp eq i32 %71, %74
%76 = select i1 %73, i1 %75, i1 false
%77 = load i32, i32* @EXIT_SUCCESS
%78 = select i1 %76, i32 %77, i32 %6
br label %82
79: ; preds = %10, %62
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%81 = load i32, i32* @EXIT_SUCCESS
br label %82
82: ; preds = %66, %50, %33, %17, %79
%83 = phi i32 [ %81, %79 ], [ %28, %17 ], [ %45, %33 ], [ %61, %50 ], [ %78, %66 ]
%84 = call i32 @close(i32 %5)
br label %85
85: ; preds = %82, %8
%86 = phi i32 [ %6, %8 ], [ %83, %82 ]
ret i32 %86
}