#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 */

/* Variables and functions */
int /*<<< orphan*/ cup(int, int);
int /*<<< orphan*/ dsr(int);
char *get_reply();
int /*<<< orphan*/ padding(int);
int /*<<< orphan*/ restore_ttymodes();
int /*<<< orphan*/ set_tty_raw(int);
char *skip_csi(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int check_8bit_toggle(void) {
  char *report;
  set_tty_raw((1));
  cup(1, 1);
  dsr(6);
  padding(5);
  report = get_reply();
  restore_ttymodes();
  if ((report = skip_csi(report)) != 0 && !strcmp(report, "1;1R"))
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<check_8bit_toggle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1090 <set_tty_raw@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <cup@plt>
mov    $0x6,%edi
call   1080 <dsr@plt>
mov    $0x5,%edi
call   10a0 <padding@plt>
mov    $0x0,%al
call   1050 <get_reply@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <restore_ttymodes@plt>
mov    -0x10(%rbp),%rdi
call   1040 <skip_csi@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1200 <check_8bit_toggle+0x80>
mov    -0x10(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1200 <check_8bit_toggle+0x80>
movl   $0x1,-0x4(%rbp)
jmp    1207 <check_8bit_toggle+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_8bit_toggle>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
mov    $0x1,%edi
call   1090 <set_tty_raw@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <cup@plt>
mov    $0x6,%edi
call   1080 <dsr@plt>
mov    $0x5,%edi
call   10a0 <padding@plt>
xor    %eax,%eax
call   1050 <get_reply@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <restore_ttymodes@plt>
mov    %rbx,%rdi
call   1040 <skip_csi@plt>
test   %rax,%rax
je     11e6 <check_8bit_toggle+0x66>
lea    0xe26(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11e8 <check_8bit_toggle+0x68>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"1;1R\00"
define i32 @check_8bit_toggle() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 @set_tty_raw(i32 1)
%4 = call i32 @cup(i32 1, i32 1)
%5 = call i32 @dsr(i32 6)
%6 = call i32 @padding(i32 5)
%7 = call i8* (...) @get_reply()
store i8* %7, i8** %2
%8 = call i32 (...) @restore_ttymodes()
%9 = load i8*, i8** %2
%10 = call i8* @skip_csi(i8* %9)
store i8* %10, i8** %2
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = load i8*, i8** %2
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12
store i32 1, i32* %1
br label %18
17: ; preds = %12, %0
store i32 0, i32* %1
br label %18
18: ; preds = %17, %16
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [5 x i8] c"1;1R\00"
define i32 @check_8bit_toggle() {
%1 = tail call i32 @set_tty_raw(i32 1)
%2 = tail call i32 @cup(i32 1, i32 1)
%3 = tail call i32 @dsr(i32 6)
%4 = tail call i32 @padding(i32 5)
%5 = tail call i8* (...) @get_reply()
%6 = tail call i32 (...) @restore_ttymodes()
%7 = tail call i8* @skip_csi(i8* %5)
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = tail call i32 @strcmp(i8* %7, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %9, %0
br label %13
13: ; preds = %9, %12
%14 = phi i32 [ 0, %12 ], [ 1, %9 ]
ret i32 %14
}