#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 INB(int);
int /*<<< orphan*/ OUTB(unsigned short, int);
void gfx_vga_clear_extended(void) {
  int i;
  unsigned short crtcindex, crtcdata;
  crtcindex = (INB(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
  crtcdata = crtcindex + 1;
  OUTB(crtcindex, 0x30);
  OUTB(crtcdata, 0x57);
  OUTB(crtcdata, 0x4C);
  for (i = 0x40; i <= 0x4F; i++) {
    OUTB(crtcindex, (unsigned char)i);
    OUTB(crtcdata, 0);
  }
  OUTB(crtcindex, 0x30);
  OUTB(crtcdata, 0x00);
}


x86 assembly (clang, -O0):
<gfx_vga_clear_extended>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x3cc,%edi
call   1030 <INB@plt>
mov    %eax,%edx
and    $0x1,%edx
mov    $0x3b4,%eax
mov    $0x3d4,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %ax,-0x6(%rbp)
movzwl -0x6(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0x8(%rbp)
mov    $0x30,%esi
movzwl -0x6(%rbp),%edi
call   1040 <OUTB@plt>
mov    $0x57,%esi
movzwl -0x8(%rbp),%edi
call   1040 <OUTB@plt>
mov    $0x4c,%esi
movzwl -0x8(%rbp),%edi
call   1040 <OUTB@plt>
movl   $0x40,-0x4(%rbp)
cmpl   $0x4f,-0x4(%rbp)
jg     11bc <gfx_vga_clear_extended+0x9c>
mov    -0x6(%rbp),%ax
mov    -0x4(%rbp),%ecx
movzbl %cl,%esi
movzwl %ax,%edi
call   1040 <OUTB@plt>
xor    %esi,%esi
movzwl -0x8(%rbp),%edi
call   1040 <OUTB@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1187 <gfx_vga_clear_extended+0x67>
mov    $0x30,%esi
movzwl -0x6(%rbp),%edi
call   1040 <OUTB@plt>
xor    %esi,%esi
movzwl -0x8(%rbp),%edi
call   1040 <OUTB@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gfx_vga_clear_extended>:
push   %rbp
push   %rbx
push   %rax
mov    $0x3cc,%edi
call   1030 <INB@plt>
mov    %eax,%ebx
shl    $0x5,%ebx
and    $0x20,%ebx
lea    0x3b4(%rbx),%ebp
mov    %ebp,%edi
mov    $0x30,%esi
call   1040 <OUTB@plt>
add    $0x3b5,%ebx
mov    %ebx,%edi
mov    $0x57,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
mov    $0x4c,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x40,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x41,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x42,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x43,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x44,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x45,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x46,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x47,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x48,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x49,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x4a,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x4b,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x4c,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x4d,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x4e,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x4f,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <OUTB@plt>
mov    %ebp,%edi
mov    $0x30,%esi
call   1040 <OUTB@plt>
mov    %ebx,%edi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <OUTB@plt>

LLVM IR (-O0):
define void @gfx_vga_clear_extended() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = call i32 @INB(i32 972)
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 980, i32 948
%9 = trunc i32 %8 to i16
store i16 %9, i16* %2
%10 = load i16, i16* %2
%11 = zext i16 %10 to i32
%12 = add nsw i32 %11, 1
%13 = trunc i32 %12 to i16
store i16 %13, i16* %3
%14 = load i16, i16* %2
%15 = call i32 @OUTB(i16 zeroext %14, i32 48)
%16 = load i16, i16* %3
%17 = call i32 @OUTB(i16 zeroext %16, i32 87)
%18 = load i16, i16* %3
%19 = call i32 @OUTB(i16 zeroext %18, i32 76)
store i32 64, i32* %1
br label %20
20: ; preds = %31, %0
%21 = load i32, i32* %1
%22 = icmp sle i32 %21, 79
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i16, i16* %2
%25 = load i32, i32* %1
%26 = trunc i32 %25 to i8
%27 = zext i8 %26 to i32
%28 = call i32 @OUTB(i16 zeroext %24, i32 %27)
%29 = load i16, i16* %3
%30 = call i32 @OUTB(i16 zeroext %29, i32 0)
br label %31
31: ; preds = %23
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
br label %20
34: ; preds = %20
%35 = load i16, i16* %2
%36 = call i32 @OUTB(i16 zeroext %35, i32 48)
%37 = load i16, i16* %3
%38 = call i32 @OUTB(i16 zeroext %37, i32 0)
ret void
}

LLVM IR (-O2):
define void @gfx_vga_clear_extended() {
%1 = tail call i32 @INB(i32 972)
%2 = and i32 %1, 1
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i16 948, i16 980
%5 = or i16 %4, 1
%6 = tail call i32 @OUTB(i16 zeroext %4, i32 48)
%7 = tail call i32 @OUTB(i16 zeroext %5, i32 87)
%8 = tail call i32 @OUTB(i16 zeroext %5, i32 76)
%9 = tail call i32 @OUTB(i16 zeroext %4, i32 64)
%10 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%11 = tail call i32 @OUTB(i16 zeroext %4, i32 65)
%12 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%13 = tail call i32 @OUTB(i16 zeroext %4, i32 66)
%14 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%15 = tail call i32 @OUTB(i16 zeroext %4, i32 67)
%16 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%17 = tail call i32 @OUTB(i16 zeroext %4, i32 68)
%18 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%19 = tail call i32 @OUTB(i16 zeroext %4, i32 69)
%20 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%21 = tail call i32 @OUTB(i16 zeroext %4, i32 70)
%22 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%23 = tail call i32 @OUTB(i16 zeroext %4, i32 71)
%24 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%25 = tail call i32 @OUTB(i16 zeroext %4, i32 72)
%26 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%27 = tail call i32 @OUTB(i16 zeroext %4, i32 73)
%28 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%29 = tail call i32 @OUTB(i16 zeroext %4, i32 74)
%30 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%31 = tail call i32 @OUTB(i16 zeroext %4, i32 75)
%32 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%33 = tail call i32 @OUTB(i16 zeroext %4, i32 76)
%34 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%35 = tail call i32 @OUTB(i16 zeroext %4, i32 77)
%36 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%37 = tail call i32 @OUTB(i16 zeroext %4, i32 78)
%38 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%39 = tail call i32 @OUTB(i16 zeroext %4, i32 79)
%40 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
%41 = tail call i32 @OUTB(i16 zeroext %4, i32 48)
%42 = tail call i32 @OUTB(i16 zeroext %5, i32 0)
ret void
}