#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*/ EBADF;
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ENOSYS;
#define TCIOFF 131
#define TCION 130
#define TCOOFF 129
#define TCOON 128
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int tcflow(int fd, int action) {
  if (fd < 0) {
    __set_errno(EBADF);
    return -1;
  }
  switch (action) {
  case TCOOFF:
  case TCOON:
  case TCIOFF:
  case TCION:
    break;
  default:
    __set_errno(EINVAL);
    return -1;
  }
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<tcflow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1142 <tcflow+0x32>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118a <tcflow+0x7a>
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
sub    $0x3,%eax
ja     115b <tcflow+0x4b>
jmp    1156 <tcflow+0x46>
jmp    1175 <tcflow+0x65>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118a <tcflow+0x7a>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcflow>:
push   %rax
and    $0xfffffffc,%esi
cmp    $0x80,%esi
jne    1129 <tcflow+0x19>
mov    0x2ec5(%rip),%rax
test   %edi,%edi
js     1134 <tcflow+0x24>
jmp    113b <tcflow+0x2b>
mov    0x2ea8(%rip),%rax
test   %edi,%edi
jns    113b <tcflow+0x2b>
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@EBADF = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i32 @tcflow(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @EBADF
%10 = call i32 @__set_errno(i32 %9)
store i32 -1, i32* %3
br label %20
11: ; preds = %2
%12 = load i32, i32* %5
switch i32 %12, label %14 [
i32 129, label %13
i32 128, label %13
i32 131, label %13
i32 130, label %13
]
13: ; preds = %11, %11, %11, %11
br label %17
14: ; preds = %11
%15 = load i32, i32* @EINVAL
%16 = call i32 @__set_errno(i32 %15)
store i32 -1, i32* %3
br label %20
17: ; preds = %13
%18 = load i32, i32* @ENOSYS
%19 = call i32 @__set_errno(i32 %18)
store i32 -1, i32* %3
br label %20
20: ; preds = %17, %14, %8
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@EBADF = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i32 @tcflow(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
%4 = and i32 %1, -4
%5 = icmp eq i32 %4, 128
%6 = load i32, i32* @EBADF
%7 = load i32, i32* @ENOSYS
%8 = load i32, i32* @EINVAL
%9 = select i1 %5, i32 %7, i32 %8
%10 = select i1 %3, i32 %6, i32 %9
%11 = tail call i32 @__set_errno(i32 %10)
ret i32 -1
}