#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 */
typedef int uint32_t;

/* Variables and functions */
void dcc_write(uint32_t dcc_data) {
  int len = 4;
  while (len--) {
    while ((*((volatile unsigned short *)0xE000EDF8)) & 1)
      ;
    (*((volatile unsigned short *)0xE000EDF8)) =
        (unsigned short)(((dcc_data & 0xff) << 8) | 1);
    dcc_data >>= 8;
  }
}


x86 assembly (clang, -O0):
<dcc_write>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     116a <dcc_write+0x6a>
jmp    1127 <dcc_write+0x27>
mov    $0xe000edf8,%eax
mov    (%rax),%ax
movzwl %ax,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1143 <dcc_write+0x43>
jmp    1127 <dcc_write+0x27>
mov    -0x4(%rbp),%eax
and    $0xff,%eax
shl    $0x8,%eax
or     $0x1,%eax
mov    %ax,%cx
mov    $0xe000edf8,%eax
mov    %cx,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    110e <dcc_write+0xe>
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcc_write>:
mov    $0xe000edf8,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzwl (%rax),%ecx
test   $0x1,%cl
jne    1110 <dcc_write+0x10>
mov    %edi,%ecx
shl    $0x8,%ecx
or     $0x1,%ecx
mov    %cx,(%rax)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzwl (%rax),%ecx
test   $0x1,%cl
jne    1130 <dcc_write+0x30>
mov    %edi,%ecx
and    $0xffffff00,%ecx
or     $0x1,%ecx
mov    %cx,(%rax)
cs nopw 0x0(%rax,%rax,1)
movzwl (%rax),%ecx
test   $0x1,%cl
jne    1150 <dcc_write+0x50>
mov    %edi,%ecx
shr    $0x8,%ecx
and    $0xffff00,%ecx
or     $0x1,%ecx
mov    %cx,(%rax)
nopl   0x0(%rax)
movzwl (%rax),%ecx
test   $0x1,%cl
jne    1170 <dcc_write+0x70>
shr    $0x10,%edi
and    $0xff00,%edi
or     $0x1,%edi
mov    %di,(%rax)
ret

LLVM IR (-O0):
define void @dcc_write(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 4, i32* %3
br label %4
4: ; preds = %15, %1
%5 = load i32, i32* %3
%6 = add nsw i32 %5, -1
store i32 %6, i32* %3
%7 = icmp ne i32 %5, 0
br i1 %7, label %8, label %23
8: ; preds = %4
br label %9
9: ; preds = %14, %8
%10 = load volatile i16, i16* inttoptr (i64 3758157304 to i16*)
%11 = zext i16 %10 to i32
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
br label %9
15: ; preds = %9
%16 = load i32, i32* %2
%17 = and i32 %16, 255
%18 = shl i32 %17, 8
%19 = or i32 %18, 1
%20 = trunc i32 %19 to i16
store volatile i16 %20, i16* inttoptr (i64 3758157304 to i16*)
%21 = load i32, i32* %2
%22 = ashr i32 %21, 8
store i32 %22, i32* %2
br label %4
23: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @dcc_write(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = load volatile i16, i16* inttoptr (i64 3758157304 to i16*)
%4 = and i16 %3, 1
%5 = icmp eq i16 %4, 0
br i1 %5, label %6, label %2
6: ; preds = %2
%7 = trunc i32 %0 to i16
%8 = shl i16 %7, 8
%9 = or i16 %8, 1
store volatile i16 %9, i16* inttoptr (i64 3758157304 to i16*)
br label %10
10: ; preds = %10, %6
%11 = load volatile i16, i16* inttoptr (i64 3758157304 to i16*)
%12 = and i16 %11, 1
%13 = icmp eq i16 %12, 0
br i1 %13, label %14, label %10
14: ; preds = %10
%15 = trunc i32 %0 to i16
%16 = and i16 %15, -256
%17 = or i16 %16, 1
store volatile i16 %17, i16* inttoptr (i64 3758157304 to i16*)
br label %18
18: ; preds = %18, %14
%19 = load volatile i16, i16* inttoptr (i64 3758157304 to i16*)
%20 = and i16 %19, 1
%21 = icmp eq i16 %20, 0
br i1 %21, label %22, label %18
22: ; preds = %18
%23 = lshr i32 %0, 8
%24 = trunc i32 %23 to i16
%25 = and i16 %24, -256
%26 = or i16 %25, 1
store volatile i16 %26, i16* inttoptr (i64 3758157304 to i16*)
br label %27
27: ; preds = %27, %22
%28 = load volatile i16, i16* inttoptr (i64 3758157304 to i16*)
%29 = and i16 %28, 1
%30 = icmp eq i16 %29, 0
br i1 %30, label %31, label %27
31: ; preds = %27
%32 = lshr i32 %0, 16
%33 = trunc i32 %32 to i16
%34 = and i16 %33, -256
%35 = or i16 %34, 1
store volatile i16 %35, i16* inttoptr (i64 3758157304 to i16*)
ret void
}