void writes(char const *str) {
  char const *word_addr;
  unsigned word;
  unsigned index;
  unsigned c;
  word_addr = (char const *const)((unsigned const)str & ~0x3);
  word = *(unsigned const *const)word_addr;
  do {
    index = (unsigned const)str & 0x3;
    if (index == 0) {
      word_addr = (char const *const)((unsigned const)str & ~0x3);
      word = *(unsigned const *const)word_addr;
    }
    c = (word >> (index << 3)) & 0xff;
    if (c != '\0') {
      *(unsigned volatile *const)0x80000000 = c;
      ++str;
    }
  } while (c != '\0');
}


x86 assembly (clang, -O0):
<writes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0xfffffffc,%eax
mov    %eax,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
and    $0x3,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1148 <writes+0x48>
mov    -0x8(%rbp),%rax
and    $0xfffffffc,%eax
mov    %eax,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x3,%ecx
shr    %cl,%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117b <writes+0x7b>
mov    -0x1c(%rbp),%ecx
mov    $0x80000000,%eax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1180 <writes+0x80>
cmpl   $0x0,-0x1c(%rbp)
jne    111e <writes+0x1e>
pop    %rbp
ret

x86 assembly (clang, -O2):
<writes>:
mov    %edi,%eax
and    $0xfffffffc,%eax
mov    (%rax),%edx
mov    $0x80000000,%eax
nopl   0x0(%rax)
mov    %edi,%ecx
and    $0x3,%ecx
jne    111e <writes+0x1e>
mov    %edi,%edx
and    $0xfffffffc,%edx
mov    (%rdx),%edx
shl    $0x3,%ecx
mov    %edx,%esi
shr    %cl,%esi
and    $0xff,%esi
je     1135 <writes+0x35>
mov    %esi,(%rax)
add    $0x1,%rdi
jmp    1110 <writes+0x10>
ret

LLVM IR (-O0):
define void @writes(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = ptrtoint i8* %7 to i32
%9 = and i32 %8, -4
%10 = zext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = bitcast i8* %12 to i32*
%14 = load i32, i32* %13
store i32 %14, i32* %4
br label %15
15: ; preds = %43, %1
%16 = load i8*, i8** %2
%17 = ptrtoint i8* %16 to i32
%18 = and i32 %17, 3
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = ptrtoint i8* %22 to i32
%24 = and i32 %23, -4
%25 = zext i32 %24 to i64
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %3
%27 = load i8*, i8** %3
%28 = bitcast i8* %27 to i32*
%29 = load i32, i32* %28
store i32 %29, i32* %4
br label %30
30: ; preds = %21, %15
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = shl i32 %32, 3
%34 = lshr i32 %31, %33
%35 = and i32 %34, 255
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = load i32, i32* %6
store volatile i32 %39, i32* inttoptr (i64 2147483648 to i32*)
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %2
br label %42
42: ; preds = %38, %30
br label %43
43: ; preds = %42
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %15, label %46
46: ; preds = %43
ret void
}

LLVM IR (-O2):
define void @writes(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = and i64 %2, 4294967292
%4 = inttoptr i64 %3 to i32*
%5 = load i32, i32* %4
br label %6
6: ; preds = %23, %1
%7 = phi i32 [ %5, %1 ], [ %18, %23 ]
%8 = phi i8* [ %0, %1 ], [ %24, %23 ]
%9 = ptrtoint i8* %8 to i64
%10 = trunc i64 %9 to i32
%11 = and i32 %10, 3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = and i64 %9, 4294967292
%15 = inttoptr i64 %14 to i32*
%16 = load i32, i32* %15
br label %17
17: ; preds = %13, %6
%18 = phi i32 [ %16, %13 ], [ %7, %6 ]
%19 = shl nuw nsw i32 %11, 3
%20 = lshr i32 %18, %19
%21 = and i32 %20, 255
%22 = icmp eq i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %17
store volatile i32 %21, i32* inttoptr (i64 2147483648 to i32*)
%24 = getelementptr inbounds i8, i8* %8, i64 1
br label %6
25: ; preds = %17
ret void
}