#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*/ print_to_console(char *);
void start(void) {
  unsigned char buffer;
  unsigned short total_bytes = 0x0001;
  *((volatile unsigned short *)(0x98000000)) = total_bytes;
  print_to_console("!!!ECHO SERVER!!!\n");
  while (1) {
    while (*((volatile unsigned char *)(0x98010000 + 1)) == ((unsigned char)0))
      ;
    buffer = *((volatile unsigned char *)(0x98010000 + 0));
    *((volatile unsigned char *)(0x98010000 + 2)) = ((unsigned char)1);
    total_bytes++;
    *((volatile unsigned short *)(0x98000000)) = total_bytes;
    while (*((volatile unsigned char *)(0x98010000 + 4)) == ((unsigned char)0))
      ;
    *((volatile unsigned char *)(0x98010000 + 3)) = buffer;
    *((volatile unsigned char *)(0x98010000 + 5)) = ((unsigned char)1);
  }
}


x86 assembly (clang, -O0):
<start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movw   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%cx
mov    $0x98000000,%eax
mov    %cx,(%rax)
lea    0xecf(%rip),%rdi
call   1030 <print_to_console@plt>
jmp    113b <start+0x2b>
mov    $0x98010001,%eax
mov    (%rax),%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    1153 <start+0x43>
jmp    113b <start+0x2b>
mov    $0x98010000,%eax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
mov    $0x98010002,%eax
movb   $0x1,(%rax)
mov    -0x4(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x4(%rbp)
mov    -0x4(%rbp),%cx
mov    $0x98000000,%eax
mov    %cx,(%rax)
mov    $0x98010004,%eax
mov    (%rax),%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    1195 <start+0x85>
jmp    117d <start+0x6d>
mov    -0x1(%rbp),%cl
mov    $0x98010003,%eax
mov    %cl,(%rax)
mov    $0x98010005,%eax
movb   $0x1,(%rax)
jmp    1136 <start+0x26>

x86 assembly (clang, -O2):
<start>:
push   %rbx
mov    $0x98000000,%ebx
movw   $0x1,(%rbx)
lea    0xede(%rip),%rdi
call   1030 <print_to_console@plt>
mov    $0x1,%ax
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x10001(%rbx)
je     1130 <start+0x20>
mov    0x10000(%rbx),%cl
movb   $0x1,0x10002(%rbx)
add    $0x1,%eax
mov    %ax,(%rbx)
nopl   0x0(%rax)
cmpb   $0x0,0x10004(%rbx)
je     1150 <start+0x40>
mov    %cl,0x10003(%rbx)
movb   $0x1,0x10005(%rbx)
jmp    1130 <start+0x20>

LLVM IR (-O0):
@.str = [19 x i8] c"!!!ECHO SERVER!!!\0A\00"
define void @start() {
%1 = alloca i8
%2 = alloca i16
store i16 1, i16* %2
%3 = load i16, i16* %2
store volatile i16 %3, i16* inttoptr (i64 2550136832 to i16*)
%4 = call i32 @print_to_console(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0, %21
br label %6
6: ; preds = %10, %5
%7 = load volatile i8, i8* inttoptr (i64 2550202369 to i8*)
%8 = zext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %6
11: ; preds = %6
%12 = load volatile i8, i8* inttoptr (i64 2550202368 to i8*)
store i8 %12, i8* %1
store volatile i8 1, i8* inttoptr (i64 2550202370 to i8*)
%13 = load i16, i16* %2
%14 = add i16 %13, 1
store i16 %14, i16* %2
%15 = load i16, i16* %2
store volatile i16 %15, i16* inttoptr (i64 2550136832 to i16*)
br label %16
16: ; preds = %20, %11
%17 = load volatile i8, i8* inttoptr (i64 2550202372 to i8*)
%18 = zext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %16
21: ; preds = %16
%22 = load i8, i8* %1
store volatile i8 %22, i8* inttoptr (i64 2550202371 to i8*)
store volatile i8 1, i8* inttoptr (i64 2550202373 to i8*)
br label %5
}

LLVM IR (-O2):
@.str = [19 x i8] c"!!!ECHO SERVER!!!\0A\00"
define void @start() {
store volatile i16 1, i16* inttoptr (i64 2550136832 to i16*)
%1 = tail call i32 @print_to_console(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %13, %0
%3 = phi i16 [ 1, %0 ], [ %9, %13 ]
br label %4
4: ; preds = %4, %2
%5 = load volatile i8, i8* inttoptr (i64 2550202369 to i8*)
%6 = icmp eq i8 %5, 0
br i1 %6, label %4, label %7
7: ; preds = %4
%8 = load volatile i8, i8* inttoptr (i64 2550202368 to i8*)
store volatile i8 1, i8* inttoptr (i64 2550202370 to i8*)
%9 = add i16 %3, 1
store volatile i16 %9, i16* inttoptr (i64 2550136832 to i16*)
br label %10
10: ; preds = %10, %7
%11 = load volatile i8, i8* inttoptr (i64 2550202372 to i8*)
%12 = icmp eq i8 %11, 0
br i1 %12, label %10, label %13
13: ; preds = %10
store volatile i8 %8, i8* inttoptr (i64 2550202371 to i8*)
store volatile i8 1, i8* inttoptr (i64 2550202373 to i8*)
br label %2
}