#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*/ nop();
void init_serial() {
  int i;
  (*(volatile char *)(0x05FFFECA)) &= ~(0x20 | 0x10);
  (*(volatile char *)(0x05FFFEC8)) = 0;
  (*(volatile char *)(0x05FFFEC9)) = 32;
  (*(volatile char *)(0x05FFFECA)) &= ~(0x02 | 0x01);
  for (i = 0; i < 1000; i++)
    nop();
  (*(volatile char *)(0x05FFFECA)) |= 0x10 | 0x20;
  (*(volatile short *)(0x05FFFFCC)) &= ~(0x0080 | 0x0020);
  (*(volatile short *)(0x05FFFFCC)) |= 0x0080 | 0x0020;
}


x86 assembly (clang, -O0):
<init_serial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x5fffeca,%eax
mov    (%rax),%al
movsbl %al,%eax
and    $0xffffffcf,%eax
mov    %al,%cl
mov    $0x5fffeca,%eax
mov    %cl,(%rax)
mov    $0x5fffec8,%eax
movb   $0x0,(%rax)
mov    $0x5fffec9,%eax
movb   $0x20,(%rax)
mov    $0x5fffeca,%eax
mov    (%rax),%al
movsbl %al,%eax
and    $0xfffffffc,%eax
mov    %al,%cl
mov    $0x5fffeca,%eax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    117d <init_serial+0x6d>
mov    $0x0,%al
call   1030 <nop@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115b <init_serial+0x4b>
mov    $0x5fffeca,%eax
mov    (%rax),%al
movsbl %al,%eax
or     $0x30,%eax
mov    %al,%cl
mov    $0x5fffeca,%eax
mov    %cl,(%rax)
mov    $0x5ffffcc,%eax
mov    (%rax),%ax
cwtl
and    $0xffffff5f,%eax
mov    %ax,%cx
mov    $0x5ffffcc,%eax
mov    %cx,(%rax)
mov    $0x5ffffcc,%eax
mov    (%rax),%ax
cwtl
or     $0xa0,%eax
mov    %ax,%cx
mov    $0x5ffffcc,%eax
mov    %cx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_serial>:
push   %rbx
andb   $0xcf,0x5fffeca
cf
movb   $0x0,0x5fffec8
movb   $0x20,0x5fffec9
20
andb   $0xfc,0x5fffeca
fc
mov    $0x3e8,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <nop@plt>
add    $0xffffffff,%ebx
jne    1140 <init_serial+0x30>
orb    $0x30,0x5fffeca
30
andw   $0xff5f,0x5ffffcc
05 5f ff
orw    $0xa0,0x5ffffcc
pop    %rbx
ret

LLVM IR (-O0):
define void @init_serial() {
%1 = alloca i32
%2 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%3 = sext i8 %2 to i32
%4 = and i32 %3, -49
%5 = trunc i32 %4 to i8
store volatile i8 %5, i8* inttoptr (i64 100662986 to i8*)
store volatile i8 0, i8* inttoptr (i64 100662984 to i8*)
store volatile i8 32, i8* inttoptr (i64 100662985 to i8*)
%6 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%7 = sext i8 %6 to i32
%8 = and i32 %7, -4
%9 = trunc i32 %8 to i8
store volatile i8 %9, i8* inttoptr (i64 100662986 to i8*)
store i32 0, i32* %1
br label %10
10: ; preds = %15, %0
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 1000
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = call i32 (...) @nop()
br label %15
15: ; preds = %13
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %10
18: ; preds = %10
%19 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%20 = sext i8 %19 to i32
%21 = or i32 %20, 48
%22 = trunc i32 %21 to i8
store volatile i8 %22, i8* inttoptr (i64 100662986 to i8*)
%23 = load volatile i16, i16* inttoptr (i64 100663244 to i16*)
%24 = sext i16 %23 to i32
%25 = and i32 %24, -161
%26 = trunc i32 %25 to i16
store volatile i16 %26, i16* inttoptr (i64 100663244 to i16*)
%27 = load volatile i16, i16* inttoptr (i64 100663244 to i16*)
%28 = sext i16 %27 to i32
%29 = or i32 %28, 160
%30 = trunc i32 %29 to i16
store volatile i16 %30, i16* inttoptr (i64 100663244 to i16*)
ret void
}

LLVM IR (-O2):
define void @init_serial() {
%1 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%2 = and i8 %1, -49
store volatile i8 %2, i8* inttoptr (i64 100662986 to i8*)
store volatile i8 0, i8* inttoptr (i64 100662984 to i8*)
store volatile i8 32, i8* inttoptr (i64 100662985 to i8*)
%3 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%4 = and i8 %3, -4
store volatile i8 %4, i8* inttoptr (i64 100662986 to i8*)
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %8, %5 ]
%7 = tail call i32 (...) @nop()
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 1000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%12 = or i8 %11, 48
store volatile i8 %12, i8* inttoptr (i64 100662986 to i8*)
%13 = load volatile i16, i16* inttoptr (i64 100663244 to i16*)
%14 = and i16 %13, -161
store volatile i16 %14, i16* inttoptr (i64 100663244 to i16*)
%15 = load volatile i16, i16* inttoptr (i64 100663244 to i16*)
%16 = or i16 %15, 160
store volatile i16 %16, i16* inttoptr (i64 100663244 to i16*)
ret void
}