#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;
scalar_t__ ioctl(int, int /*<<< orphan*/, int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int ttyControlGet(int fd, char *name) {
  int control;
  control = 0;
  if (ioctl(fd, TIOCMGET, &control)) {
    char error[256];
    sprintf(error, "%s: Can't get the modem control bits of interface %s",
            "jpnevulator", name);
    perror(error);
  }
  return control;
}


x86 assembly (clang, -O0):
<ttyControlGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
lea    -0x14(%rbp),%rdx
call   1030 <ioctl@plt>
cmp    $0x0,%rax
je     1192 <ttyControlGet+0x62>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rcx
lea    0xe86(%rip),%rsi
lea    0xeb4(%rip),%rdx
call   1050 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1040 <perror@plt>
mov    -0x14(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ttyControlGet>:
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
movl   $0x0,0xc(%rsp)
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
call   1030 <ioctl@plt>
test   %rax,%rax
jne    116c <ttyControlGet+0x3c>
mov    0xc(%rsp),%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe8d(%rip),%rsi
lea    0xebb(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rcx
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1040 <perror@plt>
jmp    115d <ttyControlGet+0x2d>

LLVM IR (-O0):
@TIOCMGET = global i32 0
@.str = [53 x i8] c"%s: Can't get the modem control bits of interface %s\00"
@.str.1 = [12 x i8] c"jpnevulator\00"
define i32 @ttyControlGet(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [256 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
%7 = load i32, i32* %3
%8 = load i32, i32* @TIOCMGET
%9 = call i64 @ioctl(i32 %7, i32 %8, i32* %5)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = call i32 @perror(i8* %15)
br label %17
17: ; preds = %11, %2
%18 = load i32, i32* %5
ret i32 %18
}

LLVM IR (-O2):
@TIOCMGET = global i32 0
@.str = [53 x i8] c"%s: Can't get the modem control bits of interface %s\00"
@.str.1 = [12 x i8] c"jpnevulator\00"
define i32 @ttyControlGet(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = load i32, i32* @TIOCMGET
%7 = call i64 @ioctl(i32 %0, i32 %6, i32* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%12 = call i32 @perror(i8* %10)
br label %13
13: ; preds = %9, %2
%14 = load i32, i32* %3
ret i32 %14
}