#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 TIOCM_DTR;
int TIOCM_RTS;
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int *);
int /*<<< orphan*/ printf(char *, char *, char *);
void report_state(int fd) {
  int pins = 0;
  ioctl(fd, TIOCMGET, &pins);
  printf("Current State: DTR(RST)=%s RTS(PGM)=%s\n",
         (pins & TIOCM_DTR) ? "0V" : "3V3", (pins & TIOCM_RTS) ? "0V" : "3V3");
}


x86 assembly (clang, -O0):
<report_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x8(%rbp),%ecx
mov    0x2e8f(%rip),%rax
and    (%rax),%ecx
lea    0xed1(%rip),%rsi
lea    0xec7(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
mov    -0x8(%rbp),%ecx
mov    0x2e76(%rip),%rax
and    (%rax),%ecx
lea    0xeb0(%rip),%rdx
lea    0xea6(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report_state>:
push   %rax
movl   $0x0,0x4(%rsp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
call   1040 <ioctl@plt>
mov    0x4(%rsp),%eax
mov    0x2e99(%rip),%rcx
mov    (%rcx),%ecx
and    %eax,%ecx
lea    0xed9(%rip),%rcx
lea    0xecf(%rip),%rdx
mov    %rdx,%rsi
cmove  %rcx,%rsi
mov    0x2e81(%rip),%rdi
and    (%rdi),%eax
cmove  %rcx,%rdx
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@TIOCMGET = global i32 0
@.str = [40 x i8] c"Current State: DTR(RST)=%s RTS(PGM)=%s\0A\00"
@TIOCM_DTR = global i32 0
@.str.1 = [3 x i8] c"0V\00"
@.str.2 = [4 x i8] c"3V3\00"
@TIOCM_RTS = global i32 0
define void @report_state(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* @TIOCMGET
%6 = call i32 @ioctl(i32 %4, i32 %5, i32* %3)
%7 = load i32, i32* %3
%8 = load i32, i32* @TIOCM_DTR
%9 = and i32 %7, %8
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%13 = load i32, i32* %3
%14 = load i32, i32* @TIOCM_RTS
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %18)
ret void
}

LLVM IR (-O2):
@TIOCMGET = global i32 0
@.str = [40 x i8] c"Current State: DTR(RST)=%s RTS(PGM)=%s\0A\00"
@TIOCM_DTR = global i32 0
@.str.1 = [3 x i8] c"0V\00"
@.str.2 = [4 x i8] c"3V3\00"
@TIOCM_RTS = global i32 0
define void @report_state(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = load i32, i32* @TIOCMGET
%5 = call i32 @ioctl(i32 %0, i32 %4, i32* %2)
%6 = load i32, i32* %2
%7 = load i32, i32* @TIOCM_DTR
%8 = and i32 %7, %6
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%11 = load i32, i32* @TIOCM_RTS
%12 = and i32 %11, %6
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %14)
ret void
}