#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*/ clrscr();
int /*<<< orphan*/ get_vbe_info();
int getchar();
int /*<<< orphan*/ print_edid(int);
int /*<<< orphan*/ printf(char *, ...);
int _main() {
  int key;
  clrscr();
  printf("Video BIOS monitor detection tool v1.7.\n\n");
  do {
    printf("select display port to check (0-7)\n");
    printf("or list video modes (L)\n");
    printf("or ESC to abort: ");
    key = getchar();
    if (key >= ' ')
      printf("%c\n", key);
    if (key >= '0' && key < '8')
      print_edid(key - '0');
    if (key == 'L' || key == 'l')
      get_vbe_info();
  } while (key != 0x1b && key != 3 && key != 4 && key != 'q' && key != 0x11);
  return 0;
}


x86 assembly (clang, -O0):
<_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <clrscr@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jl     11bc <_main+0x6c>
mov    -0x4(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x30,-0x4(%rbp)
jl     11db <_main+0x8b>
cmpl   $0x38,-0x4(%rbp)
jge    11db <_main+0x8b>
mov    -0x4(%rbp),%edi
sub    $0x30,%edi
call   1070 <print_edid@plt>
cmpl   $0x4c,-0x4(%rbp)
je     11ef <_main+0x9f>
cmpl   $0x6c,-0x4(%rbp)
jne    11f6 <_main+0xa6>
mov    $0x0,%al
call   1040 <get_vbe_info@plt>
jmp    11fb <_main+0xab>
xor    %eax,%eax
cmpl   $0x1b,-0x4(%rbp)
mov    %al,-0x5(%rbp)
je     1241 <_main+0xf1>
xor    %eax,%eax
cmpl   $0x3,-0x4(%rbp)
mov    %al,-0x5(%rbp)
je     1241 <_main+0xf1>
xor    %eax,%eax
cmpl   $0x4,-0x4(%rbp)
mov    %al,-0x5(%rbp)
je     1241 <_main+0xf1>
xor    %eax,%eax
cmpl   $0x71,-0x4(%rbp)
mov    %al,-0x5(%rbp)
je     1241 <_main+0xf1>
cmpl   $0x11,-0x4(%rbp)
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    116d <_main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <clrscr@plt>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
lea    0xeba(%rip),%r14
lea    0xed6(%rip),%r15
lea    0xe6d(%rip),%r13
lea    0xe78(%rip),%r12
mov    $0x8020018,%ebp
jmp    11b5 <_main+0x55>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x71,%ebx
je     1216 <_main+0xb6>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%ebx
cmp    $0x20,%eax
jl     11e9 <_main+0x89>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%eax
and    $0xfffffff8,%eax
cmp    $0x30,%eax
jne    11fb <_main+0x9b>
lea    -0x30(%rbx),%edi
call   1080 <print_edid@plt>
mov    %ebx,%eax
and    $0xffffffdf,%eax
cmp    $0x4c,%eax
jne    120c <_main+0xac>
xor    %eax,%eax
call   1050 <get_vbe_info@plt>
cmp    $0x1b,%ebx
ja     11b0 <_main+0x50>
bt     %ebx,%ebp
jae    11b0 <_main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Video BIOS monitor detection tool v1.7.\0A\0A\00"
@.str.1 = [36 x i8] c"select display port to check (0-7)\0A\00"
@.str.2 = [25 x i8] c"or list video modes (L)\0A\00"
@.str.3 = [18 x i8] c"or ESC to abort: \00"
@.str.4 = [4 x i8] c"%c\0A\00"
define i32 @_main() {
%1 = alloca i32
%2 = call i32 (...) @clrscr()
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %48, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 (...) @getchar()
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = icmp sge i32 %9, 32
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i32, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %11, %4
%15 = load i32, i32* %1
%16 = icmp sge i32 %15, 48
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 56
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %1
%22 = sub nsw i32 %21, 48
%23 = call i32 @print_edid(i32 %22)
br label %24
24: ; preds = %20, %17, %14
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 76
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %1
%29 = icmp eq i32 %28, 108
br i1 %29, label %30, label %32
30: ; preds = %27, %24
%31 = call i32 (...) @get_vbe_info()
br label %32
32: ; preds = %30, %27
br label %33
33: ; preds = %32
%34 = load i32, i32* %1
%35 = icmp ne i32 %34, 27
br i1 %35, label %36, label %48
36: ; preds = %33
%37 = load i32, i32* %1
%38 = icmp ne i32 %37, 3
br i1 %38, label %39, label %48
39: ; preds = %36
%40 = load i32, i32* %1
%41 = icmp ne i32 %40, 4
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %1
%44 = icmp ne i32 %43, 113
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %1
%47 = icmp ne i32 %46, 17
br label %48
48: ; preds = %45, %42, %39, %36, %33
%49 = phi i1 [ false, %42 ], [ false, %39 ], [ false, %36 ], [ false, %33 ], [ %47, %45 ]
br i1 %49, label %4, label %50
50: ; preds = %48
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [18 x i8] c"or ESC to abort: \00"
@.str.4 = [4 x i8] c"%c\0A\00"
@str = [41 x i8] c"Video BIOS monitor detection tool v1.7.\0A\00"
@str.5 = [35 x i8] c"select display port to check (0-7)\00"
@str.6 = [24 x i8] c"or list video modes (L)\00"
define i32 @_main() {
%1 = tail call i32 (...) @clrscr()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %22, %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 (...) @getchar()
%8 = icmp sgt i32 %7, 31
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %7)
br label %11
11: ; preds = %9, %3
%12 = and i32 %7, -8
%13 = icmp eq i32 %12, 48
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = add nsw i32 %7, -48
%16 = tail call i32 @print_edid(i32 %15)
br label %17
17: ; preds = %14, %11
%18 = and i32 %7, -33
%19 = icmp eq i32 %18, 76
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 (...) @get_vbe_info()
br label %22
22: ; preds = %20, %17
switch i32 %7, label %3 [
i32 113, label %23
i32 27, label %23
i32 17, label %23
i32 4, label %23
i32 3, label %23
]
23: ; preds = %22, %22, %22, %22, %22
ret i32 0
}