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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
size_t VERASE;
size_t VKILL;
int /*<<< orphan*/ cfgetospeed(struct termios *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ show_baud(int /*<<< orphan*/);
int /*<<< orphan*/ show_some_flags(struct termios *);
int tcgetattr(int /*<<< orphan*/, struct termios *);
int main(int argc, char *argv[]) {
  struct termios info;
  int val;
  if ((val = tcgetattr(0, &info)) == -1) {
    perror("tcgetattr() failed");
    exit(EXIT_FAILURE);
  }
  show_baud(cfgetospeed(&info));
  printf("The erase character is ascii %d, Ctrl - %c\n", info.c_cc[VERASE],
         info.c_cc[VERASE] - 1 + 'A');
  printf("The line kill character is ascii %d, Ctrl - %c\n", info.c_cc[VKILL],
         info.c_cc[VKILL] - 1 + 'A');
  show_some_flags(&info);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1070 <tcgetattr@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    11b7 <main+0x47>
lea    0xe5c(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    -0x18(%rbp),%rdi
call   1060 <cfgetospeed@plt>
mov    %eax,%edi
call   1050 <show_baud@plt>
mov    -0x18(%rbp),%rax
mov    0x2e0e(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x18(%rbp),%rax
mov    0x2dfd(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x1,%edx
add    $0x41,%edx
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x2de2(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x18(%rbp),%rax
mov    0x2dd1(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x1,%edx
add    $0x41,%edx
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1040 <show_some_flags@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1070 <tcgetattr@plt>
cmp    $0xffffffff,%eax
je     11ec <main+0x7c>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <cfgetospeed@plt>
mov    %eax,%edi
call   1050 <show_baud@plt>
mov    0x8(%rsp),%rax
mov    0x2e3a(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
lea    0x40(%rsi),%edx
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
mov    0x2e21(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
lea    0x40(%rsi),%edx
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <show_some_flags@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe0d(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.termios = type { i32* }
@.str = [19 x i8] c"tcgetattr() failed\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [44 x i8] c"The erase character is ascii %d, Ctrl - %c\0A\00"
@VERASE = global i64 0
@.str.2 = [48 x i8] c"The line kill character is ascii %d, Ctrl - %c\0A\00"
@VKILL = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.termios
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @tcgetattr(i32 0, %struct.termios* %6)
store i32 %8, i32* %7
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = call i32 @cfgetospeed(%struct.termios* %6)
%16 = call i32 @show_baud(i32 %15)
%17 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%18 = load i32*, i32** %17
%19 = load i64, i64* @VERASE
%20 = getelementptr inbounds i32, i32* %18, i64 %19
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%23 = load i32*, i32** %22
%24 = load i64, i64* @VERASE
%25 = getelementptr inbounds i32, i32* %23, i64 %24
%26 = load i32, i32* %25
%27 = sub nsw i32 %26, 1
%28 = add nsw i32 %27, 65
%29 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %28)
%30 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%31 = load i32*, i32** %30
%32 = load i64, i64* @VKILL
%33 = getelementptr inbounds i32, i32* %31, i64 %32
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.termios, %struct.termios* %6, i32 0, i32 0
%36 = load i32*, i32** %35
%37 = load i64, i64* @VKILL
%38 = getelementptr inbounds i32, i32* %36, i64 %37
%39 = load i32, i32* %38
%40 = sub nsw i32 %39, 1
%41 = add nsw i32 %40, 65
%42 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %41)
%43 = call i32 @show_some_flags(%struct.termios* %6)
ret i32 0
}

LLVM IR (-O2):
%struct.termios = type { i32* }
@.str = [19 x i8] c"tcgetattr() failed\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [44 x i8] c"The erase character is ascii %d, Ctrl - %c\0A\00"
@VERASE = global i64 0
@.str.2 = [48 x i8] c"The line kill character is ascii %d, Ctrl - %c\0A\00"
@VKILL = global i64 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.termios
%4 = bitcast %struct.termios* %3 to i8*
%5 = call i32 @tcgetattr(i32 0, %struct.termios* %3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = call i32 @cfgetospeed(%struct.termios* %3)
%13 = call i32 @show_baud(i32 %12)
%14 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%15 = load i32*, i32** %14
%16 = load i64, i64* @VERASE
%17 = getelementptr inbounds i32, i32* %15, i64 %16
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 64
%20 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
%21 = load i32*, i32** %14
%22 = load i64, i64* @VKILL
%23 = getelementptr inbounds i32, i32* %21, i64 %22
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 64
%26 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
%27 = call i32 @show_some_flags(%struct.termios* %3)
ret i32 0
}