#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 timeval {
  int tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ TIOCCBRK;
int /*<<< orphan*/ TIOCSBRK;
int ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ select(int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          struct timeval *);
int tcsendbreak(int fildes, int duration) {
  struct timeval sleepytime;
  sleepytime.tv_sec = 0;
  sleepytime.tv_usec = 400000;
  if (ioctl(fildes, TIOCSBRK, 0) != -1) {
    select(0, 0, 0, 0, &sleepytime);
    (void)ioctl(fildes, TIOCCBRK, 0);
  }
}


x86 assembly (clang, -O0):
<tcsendbreak>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x61a80,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <ioctl@plt>
cmp    $0xffffffff,%eax
je     117d <tcsendbreak+0x5d>
xor    %ecx,%ecx
lea    -0x20(%rbp),%r8
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   1040 <select@plt>
mov    -0x8(%rbp),%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <ioctl@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcsendbreak>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movq   $0x0,0x8(%rsp)
movl   $0x61a80,(%rsp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <ioctl@plt>
cmp    $0xffffffff,%eax
je     116e <tcsendbreak+0x4e>
mov    %rsp,%r8
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <select@plt>
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <ioctl@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@TIOCSBRK = global i32 0
@TIOCCBRK = global i32 0
define i32 @tcsendbreak(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.timeval
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
store i64 0, i64* %7
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
store i32 400000, i32* %8
%9 = load i32, i32* %4
%10 = load i32, i32* @TIOCSBRK
%11 = call i32 @ioctl(i32 %9, i32 %10, i32 0)
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = call i32 @select(i32 0, i32 0, i32 0, i32 0, %struct.timeval* %6)
%15 = load i32, i32* %4
%16 = load i32, i32* @TIOCCBRK
%17 = call i32 @ioctl(i32 %15, i32 %16, i32 0)
br label %18
18: ; preds = %13, %2
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@TIOCSBRK = global i32 0
@TIOCCBRK = global i32 0
define i32 @tcsendbreak(i32 %0, i32 %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
store i64 0, i64* %5
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
store i32 400000, i32* %6
%7 = load i32, i32* @TIOCSBRK
%8 = tail call i32 @ioctl(i32 %0, i32 %7, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = call i32 @select(i32 0, i32 0, i32 0, i32 0, %struct.timeval* %3)
%12 = load i32, i32* @TIOCCBRK
%13 = call i32 @ioctl(i32 %0, i32 %12, i32 0)
br label %14
14: ; preds = %10, %2
ret i32 undef
}