#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;
  int /*<<< orphan*/ c_lflag;
};

/* Variables and functions */
int /*<<< orphan*/ ECHO;
int /*<<< orphan*/ ICANON;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ TCSAFLUSH;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ tcgetattr(int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/,
                             struct termios *);
void ft_switch_icanon(void) {
  struct termios tattr;
  tcgetattr(0, &tattr);
  tattr.c_lflag ^= ECHO;
  tattr.c_lflag ^= ICANON;
  tattr.c_cc[VMIN] = 1;
  tattr.c_cc[VTIME] = 0;
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &tattr);
}


x86 assembly (clang, -O0):
<ft_switch_icanon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
lea    -0x10(%rbp),%rsi
call   1030 <tcgetattr@plt>
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e7c(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    0x2e57(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    0x2e5d(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_switch_icanon>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <tcgetattr@plt>
mov    0x2ea7(%rip),%rax
mov    0x8(%rsp),%ecx
xor    (%rax),%ecx
mov    0x2e72(%rip),%rax
xor    (%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    (%rsp),%rax
mov    0x2e81(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2e60(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdx
call   1040 <tcsetattr@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.termios = type { i32*, i32 }
@ECHO = global i32 0
@ICANON = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@STDIN_FILENO = global i32 0
@TCSAFLUSH = global i32 0
define void @ft_switch_icanon() {
%1 = alloca %struct.termios
%2 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%3 = load i32, i32* @ECHO
%4 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 1
%5 = load i32, i32* %4
%6 = xor i32 %5, %3
store i32 %6, i32* %4
%7 = load i32, i32* @ICANON
%8 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 1
%9 = load i32, i32* %8
%10 = xor i32 %9, %7
store i32 %10, i32* %8
%11 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 0
%12 = load i32*, i32** %11
%13 = load i64, i64* @VMIN
%14 = getelementptr inbounds i32, i32* %12, i64 %13
store i32 1, i32* %14
%15 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 0
%16 = load i32*, i32** %15
%17 = load i64, i64* @VTIME
%18 = getelementptr inbounds i32, i32* %16, i64 %17
store i32 0, i32* %18
%19 = load i32, i32* @STDIN_FILENO
%20 = load i32, i32* @TCSAFLUSH
%21 = call i32 @tcsetattr(i32 %19, i32 %20, %struct.termios* %1)
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32*, i32 }
@ECHO = global i32 0
@ICANON = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@STDIN_FILENO = global i32 0
@TCSAFLUSH = global i32 0
define void @ft_switch_icanon() {
%1 = alloca %struct.termios
%2 = bitcast %struct.termios* %1 to i8*
%3 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%4 = load i32, i32* @ECHO
%5 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 1
%6 = load i32, i32* %5
%7 = xor i32 %6, %4
%8 = load i32, i32* @ICANON
%9 = xor i32 %8, %7
store i32 %9, i32* %5
%10 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%11 = load i32*, i32** %10
%12 = load i64, i64* @VMIN
%13 = getelementptr inbounds i32, i32* %11, i64 %12
store i32 1, i32* %13
%14 = load i64, i64* @VTIME
%15 = getelementptr inbounds i32, i32* %11, i64 %14
store i32 0, i32* %15
%16 = load i32, i32* @STDIN_FILENO
%17 = load i32, i32* @TCSAFLUSH
%18 = call i32 @tcsetattr(i32 %16, i32 %17, %struct.termios* %1)
ret void
}