#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*/ EINVAL;
#define TCIOFF 131
#define TCION 130
#define TCOOFF 129
#define TCOON 128
int /*<<< orphan*/ TCXONC;
int /*<<< orphan*/ errno;
int ioctl(int, int /*<<< orphan*/, int);
int tcflow(int fd, int action) {
  int arg = 0;
  switch (action) {
  case TCION:
    arg++;
  case TCIOFF:
    arg++;
  case TCOON:
    arg++;
  case TCOOFF:
    return ioctl(fd, TCXONC, arg);
  default:
    errno = EINVAL;
    return -1;
  }
}


x86 assembly (clang, -O0):
<tcflow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1185 <tcflow+0x75>
mov    -0x18(%rbp),%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%edx
call   1030 <ioctl@plt>
mov    %eax,-0x4(%rbp)
jmp    119e <tcflow+0x8e>
mov    0x2e44(%rip),%rax
mov    (%rax),%ecx
mov    0x2e43(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcflow>:
add    $0xffffff80,%esi
cmp    $0x3,%esi
ja     114e <tcflow+0x3e>
xor    %edx,%edx
mov    $0x1,%ecx
mov    $0x2,%r8d
lea    0xed4(%rip),%rax
movslq (%rax,%rsi,4),%rsi
add    %rax,%rsi
jmp    *%rsi
mov    $0x3,%r8d
mov    %r8d,%ecx
mov    %ecx,%edx
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
jmp    1030 <ioctl@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    0x2e7a(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@TCXONC = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
define i32 @tcflow(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* %5
switch i32 %7, label %22 [
i32 130, label %8
i32 131, label %11
i32 128, label %14
i32 129, label %17
]
8: ; preds = %2
%9 = load i32, i32* %6
%10 = add nsw i32 %9, 1
store i32 %10, i32* %6
br label %11
11: ; preds = %2, %8
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 1
store i32 %13, i32* %6
br label %14
14: ; preds = %2, %11
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
store i32 %16, i32* %6
br label %17
17: ; preds = %2, %14
%18 = load i32, i32* %4
%19 = load i32, i32* @TCXONC
%20 = load i32, i32* %6
%21 = call i32 @ioctl(i32 %18, i32 %19, i32 %20)
store i32 %21, i32* %3
br label %24
22: ; preds = %2
%23 = load i32, i32* @EINVAL
store i32 %23, i32* @errno
store i32 -1, i32* %3
br label %24
24: ; preds = %22, %17
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@TCXONC = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
define i32 @tcflow(i32 %0, i32 %1) {
switch i32 %1, label %12 [
i32 130, label %3
i32 131, label %4
i32 128, label %6
i32 129, label %8
]
3: ; preds = %2
br label %4
4: ; preds = %2, %3
%5 = phi i32 [ 2, %2 ], [ 3, %3 ]
br label %6
6: ; preds = %2, %4
%7 = phi i32 [ 1, %2 ], [ %5, %4 ]
br label %8
8: ; preds = %2, %6
%9 = phi i32 [ 0, %2 ], [ %7, %6 ]
%10 = load i32, i32* @TCXONC
%11 = tail call i32 @ioctl(i32 %0, i32 %10, i32 %9)
br label %14
12: ; preds = %2
%13 = load i32, i32* @EINVAL
store i32 %13, i32* @errno
br label %14
14: ; preds = %12, %8
%15 = phi i32 [ -1, %12 ], [ %11, %8 ]
ret i32 %15
}