#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 */
size_t VERASE;
size_t VKILL;
scalar_t__ cfgetospeed(struct termios *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ show_some_flag(struct termios *);
int /*<<< orphan*/ showbaud(int);
int tcgetattr(int /*<<< orphan*/, struct termios *);
int main() {
  struct termios ttyinfo;
  if (tcgetattr(0, &ttyinfo) == -1) {
    perror("cann't not get params about stdin");
    exit(1);
  }
  showbaud((int)cfgetospeed(&ttyinfo));
  printf("The erase character is ascii %d, Ctrl-%c\n", ttyinfo.c_cc[VERASE],
         ttyinfo.c_cc[VERASE] - 1 + 'A');
  printf("The line kill character is ascii %d, Ctrl-%c\n", ttyinfo.c_cc[VKILL],
         ttyinfo.c_cc[VKILL] - 1 + 'A');
  show_some_flag(&ttyinfo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
lea    -0x10(%rbp),%rsi
call   1060 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    11a9 <main+0x39>
lea    0xe66(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x10(%rbp),%rdi
call   1050 <cfgetospeed@plt>
mov    %eax,%edi
call   1030 <showbaud@plt>
mov    -0x10(%rbp),%rax
mov    0x2e1c(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rax
mov    0x2e0b(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x1,%edx
add    $0x41,%edx
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x2df0(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rax
mov    0x2ddf(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x1,%edx
add    $0x41,%edx
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1090 <show_some_flag@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.termios = type { i32* }
@.str = [34 x i8] c"cann't not get params about stdin\00"
@.str.1 = [42 x i8] c"The erase character is ascii %d, Ctrl-%c\0A\00"
@VERASE = global i64 0
@.str.2 = [46 x i8] c"The line kill character is ascii %d, Ctrl-%c\0A\00"
@VKILL = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.termios
store i32 0, i32* %1
%3 = call i32 @tcgetattr(i32 0, %struct.termios* %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i64 @cfgetospeed(%struct.termios* %2)
%10 = trunc i64 %9 to i32
%11 = call i32 @showbaud(i32 %10)
%12 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%13 = load i32*, i32** %12
%14 = load i64, i64* @VERASE
%15 = getelementptr inbounds i32, i32* %13, i64 %14
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.termios, %struct.termios* %2, 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 = sub nsw i32 %21, 1
%23 = add nsw i32 %22, 65
%24 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %23)
%25 = getelementptr inbounds %struct.termios, %struct.termios* %2, i32 0, i32 0
%26 = load i32*, i32** %25
%27 = load i64, i64* @VKILL
%28 = getelementptr inbounds i32, i32* %26, i64 %27
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.termios, %struct.termios* %2, 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 = sub nsw i32 %34, 1
%36 = add nsw i32 %35, 65
%37 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %36)
%38 = call i32 @show_some_flag(%struct.termios* %2)
ret i32 0
}

LLVM IR (-O2):
%struct.termios = type { i32* }
@.str = [34 x i8] c"cann't not get params about stdin\00"
@.str.1 = [42 x i8] c"The erase character is ascii %d, Ctrl-%c\0A\00"
@VERASE = global i64 0
@.str.2 = [46 x i8] c"The line kill character is ascii %d, Ctrl-%c\0A\00"
@VKILL = global i64 0
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 %8
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i64 @cfgetospeed(%struct.termios* %1)
%10 = trunc i64 %9 to i32
%11 = call i32 @showbaud(i32 %10)
%12 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%13 = load i32*, i32** %12
%14 = load i64, i64* @VERASE
%15 = getelementptr inbounds i32, i32* %13, i64 %14
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 64
%18 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
%19 = load i32*, i32** %12
%20 = load i64, i64* @VKILL
%21 = getelementptr inbounds i32, i32* %19, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 64
%24 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
%25 = call i32 @show_some_flag(%struct.termios* %1)
ret i32 0
}