#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 termios {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ error(char *);
int fcntl(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int tcgetattr(int /*<<< orphan*/, struct termios *);
void term_info(struct termios *tty, int *stdinflags) {
  if (tcgetattr(STDIN_FILENO, tty) == -1)
    error("ERROR: I Can't get terminal attributes.");
  *stdinflags = fcntl(STDIN_FILENO, F_GETFL, 0);
}


x86 assembly (clang, -O0):
<term_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1050 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    1167 <term_info+0x37>
lea    0xe9e(%rip),%rdi
call   1040 <error@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_info>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    0x2e97(%rip),%r14
mov    (%r14),%edi
call   1050 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    115a <term_info+0x2a>
lea    0xeab(%rip),%rdi
call   1040 <error@plt>
mov    (%r14),%edi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@.str = [40 x i8] c"ERROR: I Can't get terminal attributes.\00"
@F_GETFL = global i32 0
define void @term_info(%struct.termios* %0, i32* %1) {
%3 = alloca %struct.termios*
%4 = alloca i32*
store %struct.termios* %0, %struct.termios** %3
store i32* %1, i32** %4
%5 = load i32, i32* @STDIN_FILENO
%6 = load %struct.termios*, %struct.termios** %3
%7 = call i32 @tcgetattr(i32 %5, %struct.termios* %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i32, i32* @STDIN_FILENO
%13 = load i32, i32* @F_GETFL
%14 = call i32 @fcntl(i32 %12, i32 %13, i32 0)
%15 = load i32*, i32** %4
store i32 %14, i32* %15
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@STDIN_FILENO = global i32 0
@.str = [40 x i8] c"ERROR: I Can't get terminal attributes.\00"
@F_GETFL = global i32 0
define void @term_info(%struct.termios* %0, i32* nocapture writeonly %1) {
%3 = load i32, i32* @STDIN_FILENO
%4 = tail call i32 @tcgetattr(i32 %3, %struct.termios* %0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = load i32, i32* @STDIN_FILENO
%10 = load i32, i32* @F_GETFL
%11 = tail call i32 @fcntl(i32 %9, i32 %10, i32 0)
store i32 %11, i32* %1
ret void
}