#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 c_oflag;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int OLCUC;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int tcgetattr(int /*<<< orphan*/, struct termios *);
int main(void) {
  struct termios info;
  int respone = tcgetattr(0, &info);
  if (respone == -1) {
    perror("tcgetatter");
    exit(EXIT_FAILURE);
  }
  if (info.c_oflag & OLCUC)
    printf("OLCUC is on.\n");
  else
    printf("OLCUC is off.\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1040 <tcgetattr@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1181 <main+0x41>
lea    0xe92(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%eax
mov    0x2e5d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11a7 <main+0x67>
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
jmp    11b3 <main+0x73>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rsi
xor    %edi,%edi
call   1040 <tcgetattr@plt>
cmp    $0xffffffff,%eax
je     117e <main+0x3e>
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
lea    0xea8(%rip),%rax
lea    0xeaf(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
lea    0xe7b(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.termios = type { i32 }
@.str = [11 x i8] c"tcgetatter\00"
@EXIT_FAILURE = global i32 0
@OLCUC = global i32 0
@.str.1 = [14 x i8] c"OLCUC is on.\0A\00"
@.str.2 = [15 x i8] c"OLCUC is off.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.termios
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @tcgetattr(i32 0, %struct.termios* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @OLCUC
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %11
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* @EXIT_SUCCESS
ret i32 %22
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@.str = [11 x i8] c"tcgetatter\00"
@EXIT_FAILURE = global i32 0
@OLCUC = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [14 x i8] c"OLCUC is off.\00"
@str.3 = [13 x i8] c"OLCUC is on.\00"
define i32 @main() {
%1 = alloca %struct.termios
%2 = bitcast %struct.termios* %1 to i8*
%3 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = load i32, i32* @OLCUC
%13 = and i32 %12, %11
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.3, i64 0, i64 0)
%16 = call i32 @puts(i8* dereferenceable(1) %15)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}