#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*/ TIOCMGET;
int /*<<< orphan*/ TIOCMSET;
unsigned int TIOCM_DTR;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, unsigned int *);
int /*<<< orphan*/ printf(char *, int);
void setDTR(int fd, int high) {
  unsigned int result = 0;
  ioctl(fd, TIOCMGET, &result);
  if (high)
    result |= TIOCM_DTR;
  else
    result &= ~TIOCM_DTR;
  ioctl(fd, TIOCMSET, &result);
  printf("setDTR( %i )\n", high);
}


x86 assembly (clang, -O0):
<setDTR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1040 <ioctl@plt>
cmpl   $0x0,-0x8(%rbp)
je     1168 <setDTR+0x48>
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    117a <setDTR+0x5a>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    -0xc(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x8(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setDTR>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
movl   $0x0,0x4(%rsp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
call   1040 <ioctl@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
test   %ebx,%ebx
je     1155 <setDTR+0x35>
or     0x4(%rsp),%eax
jmp    115b <setDTR+0x3b>
not    %eax
and    0x4(%rsp),%eax
mov    %eax,0x4(%rsp)
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %ebp,%edi
call   1040 <ioctl@plt>
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@TIOCMGET = global i32 0
@TIOCM_DTR = global i32 0
@TIOCMSET = global i32 0
@.str = [14 x i8] c"setDTR( %i )\0A\00"
define void @setDTR(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = load i32, i32* @TIOCMGET
%8 = call i32 @ioctl(i32 %6, i32 %7, i32* %5)
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @TIOCM_DTR
%13 = load i32, i32* %5
%14 = or i32 %13, %12
store i32 %14, i32* %5
br label %20
15: ; preds = %2
%16 = load i32, i32* @TIOCM_DTR
%17 = xor i32 %16, -1
%18 = load i32, i32* %5
%19 = and i32 %18, %17
store i32 %19, i32* %5
br label %20
20: ; preds = %15, %11
%21 = load i32, i32* %3
%22 = load i32, i32* @TIOCMSET
%23 = call i32 @ioctl(i32 %21, i32 %22, i32* %5)
%24 = load i32, i32* %4
%25 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %24)
ret void
}

LLVM IR (-O2):
@TIOCMGET = global i32 0
@TIOCM_DTR = global i32 0
@TIOCMSET = global i32 0
@.str = [14 x i8] c"setDTR( %i )\0A\00"
define void @setDTR(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = load i32, i32* @TIOCMGET
%6 = call i32 @ioctl(i32 %0, i32 %5, i32* %3)
%7 = icmp eq i32 %1, 0
%8 = load i32, i32* @TIOCM_DTR
br i1 %7, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %3
%11 = or i32 %10, %8
br label %16
12: ; preds = %2
%13 = xor i32 %8, -1
%14 = load i32, i32* %3
%15 = and i32 %14, %13
br label %16
16: ; preds = %12, %9
%17 = phi i32 [ %15, %12 ], [ %11, %9 ]
store i32 %17, i32* %3
%18 = load i32, i32* @TIOCMSET
%19 = call i32 @ioctl(i32 %0, i32 %18, i32* %3)
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %1)
ret void
}