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


x86 assembly (clang, -O0):
<init_serial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x5fffeca,%eax
movb   $0x0,(%rax)
mov    $0x5fffec8,%eax
movb   $0x0,(%rax)
mov    $0x5fffec9,%eax
movb   $0x9,(%rax)
mov    $0x5fffeca,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xfffffffc,%eax
mov    %al,%cl
mov    $0x5fffeca,%eax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    116f <init_serial+0x5f>
mov    $0x0,%al
call   1030 <nop@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114d <init_serial+0x3d>
mov    $0x5fffeca,%eax
mov    (%rax),%al
movzbl %al,%eax
or     $0x30,%eax
mov    %al,%cl
mov    $0x5fffeca,%eax
mov    %cl,(%rax)
mov    $0x5ffffcc,%eax
mov    (%rax),%ax
movzwl %ax,%eax
and    $0xffffff5f,%eax
mov    %ax,%cx
mov    $0x5ffffcc,%eax
mov    %cx,(%rax)
mov    $0x5ffffcc,%eax
mov    (%rax),%ax
movzwl %ax,%eax
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
movb   $0x0,0x5fffeca
movb   $0x0,0x5fffec8
movb   $0x9,0x5fffec9
09
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
store volatile i8 0, i8* inttoptr (i64 100662986 to i8*)
store volatile i8 0, i8* inttoptr (i64 100662984 to i8*)
store volatile i8 9, i8* inttoptr (i64 100662985 to i8*)
%2 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%3 = zext i8 %2 to i32
%4 = and i32 %3, -4
%5 = trunc i32 %4 to i8
store volatile i8 %5, i8* inttoptr (i64 100662986 to i8*)
store i32 0, i32* %1
br label %6
6: ; preds = %11, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1000
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = call i32 (...) @nop()
br label %11
11: ; preds = %9
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %6
14: ; preds = %6
%15 = load volatile i8, i8* inttoptr (i64 100662986 to i8*)
%16 = zext i8 %15 to i32
%17 = or i32 %16, 48
%18 = trunc i32 %17 to i8
store volatile i8 %18, i8* inttoptr (i64 100662986 to i8*)
%19 = load volatile i16, i16* inttoptr (i64 100663244 to i16*)
%20 = zext i16 %19 to i32
%21 = and i32 %20, -161
%22 = trunc i32 %21 to i16
store volatile i16 %22, i16* inttoptr (i64 100663244 to i16*)
%23 = load volatile i16, i16* inttoptr (i64 100663244 to i16*)
%24 = zext i16 %23 to i32
%25 = or i32 %24, 160
%26 = trunc i32 %25 to i16
store volatile i16 %26, i16* inttoptr (i64 100663244 to i16*)
ret void
}

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