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

/* Variables and functions */
int copy_fwd_until_dst_word_aligned(uint8_t *d, const uint8_t *s) {
  int dstal = ((uint32_t)d) % sizeof(uint32_t);
  switch (dstal) {
  case 1:
    *d++ = *s++;
  case 2:
    *d++ = *s++;
  case 3:
    *d++ = *s++;
  case 4:
    *d++ = *s++;
  case 5:
    *d++ = *s++;
  case 6:
    *d++ = *s++;
  case 7:
    *d = *s;
  }
  return dstal;
}


x86 assembly (clang, -O0):
<copy_fwd_until_dst_word_aligned>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x6,%eax
ja     1216 <copy_fwd_until_dst_word_aligned+0x116>
mov    -0x20(%rbp),%rax
lea    0xecb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_fwd_until_dst_word_aligned>:
mov    %edi,%eax
and    $0x3,%eax
cmp    $0x3,%eax
je     112c <copy_fwd_until_dst_word_aligned+0x2c>
cmp    $0x2,%eax
je     1120 <copy_fwd_until_dst_word_aligned+0x20>
cmp    $0x1,%eax
jne    1148 <copy_fwd_until_dst_word_aligned+0x48>
mov    (%rsi),%ecx
add    $0x4,%rsi
mov    %ecx,(%rdi)
add    $0x4,%rdi
mov    (%rsi),%ecx
add    $0x4,%rsi
mov    %ecx,(%rdi)
add    $0x4,%rdi
mov    (%rsi),%ecx
mov    %ecx,(%rdi)
mov    0x4(%rsi),%ecx
mov    %ecx,0x4(%rdi)
mov    0x8(%rsi),%ecx
mov    %ecx,0x8(%rdi)
mov    0xc(%rsi),%ecx
mov    %ecx,0xc(%rdi)
mov    0x10(%rsi),%ecx
mov    %ecx,0x10(%rdi)
ret

LLVM IR (-O0):
define i32 @copy_fwd_until_dst_word_aligned(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = ptrtoint i32* %6 to i32
%8 = sext i32 %7 to i64
%9 = urem i64 %8, 4
%10 = trunc i64 %9 to i32
store i32 %10, i32* %5
%11 = load i32, i32* %5
switch i32 %11, label %52 [
i32 1, label %12
i32 2, label %18
i32 3, label %24
i32 4, label %30
i32 5, label %36
i32 6, label %42
i32 7, label %48
]
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = getelementptr inbounds i32, i32* %13, i32 1
store i32* %14, i32** %4
%15 = load i32, i32* %13
%16 = load i32*, i32** %3
%17 = getelementptr inbounds i32, i32* %16, i32 1
store i32* %17, i32** %3
store i32 %15, i32* %16
br label %18
18: ; preds = %2, %12
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %4
%21 = load i32, i32* %19
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %3
store i32 %21, i32* %22
br label %24
24: ; preds = %2, %18
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i32 1
store i32* %26, i32** %4
%27 = load i32, i32* %25
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i32 1
store i32* %29, i32** %3
store i32 %27, i32* %28
br label %30
30: ; preds = %2, %24
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i32 1
store i32* %32, i32** %4
%33 = load i32, i32* %31
%34 = load i32*, i32** %3
%35 = getelementptr inbounds i32, i32* %34, i32 1
store i32* %35, i32** %3
store i32 %33, i32* %34
br label %36
36: ; preds = %2, %30
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i32 1
store i32* %38, i32** %4
%39 = load i32, i32* %37
%40 = load i32*, i32** %3
%41 = getelementptr inbounds i32, i32* %40, i32 1
store i32* %41, i32** %3
store i32 %39, i32* %40
br label %42
42: ; preds = %2, %36
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i32 1
store i32* %44, i32** %4
%45 = load i32, i32* %43
%46 = load i32*, i32** %3
%47 = getelementptr inbounds i32, i32* %46, i32 1
store i32* %47, i32** %3
store i32 %45, i32* %46
br label %48
48: ; preds = %2, %42
%49 = load i32*, i32** %4
%50 = load i32, i32* %49
%51 = load i32*, i32** %3
store i32 %50, i32* %51
br label %52
52: ; preds = %48, %2
%53 = load i32, i32* %5
ret i32 %53
}

LLVM IR (-O2):
define i32 @copy_fwd_until_dst_word_aligned(i32* %0, i32* nocapture %1) {
%3 = ptrtoint i32* %0 to i64
%4 = trunc i64 %3 to i32
%5 = and i32 %4, 3
switch i32 %5, label %32 [
i32 1, label %6
i32 2, label %10
i32 3, label %16
]
6: ; preds = %2
%7 = getelementptr inbounds i32, i32* %1, i64 1
%8 = load i32, i32* %1
%9 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %8, i32* %0
br label %10
10: ; preds = %2, %6
%11 = phi i32* [ %1, %2 ], [ %7, %6 ]
%12 = phi i32* [ %0, %2 ], [ %9, %6 ]
%13 = getelementptr inbounds i32, i32* %11, i64 1
%14 = load i32, i32* %11
%15 = getelementptr inbounds i32, i32* %12, i64 1
store i32 %14, i32* %12
br label %16
16: ; preds = %2, %10
%17 = phi i32* [ %1, %2 ], [ %13, %10 ]
%18 = phi i32* [ %0, %2 ], [ %15, %10 ]
%19 = load i32, i32* %17
store i32 %19, i32* %18
%20 = getelementptr inbounds i32, i32* %18, i64 1
%21 = getelementptr inbounds i32, i32* %17, i64 1
%22 = load i32, i32* %21
store i32 %22, i32* %20
%23 = getelementptr inbounds i32, i32* %18, i64 2
%24 = getelementptr inbounds i32, i32* %17, i64 2
%25 = load i32, i32* %24
store i32 %25, i32* %23
%26 = getelementptr inbounds i32, i32* %18, i64 3
%27 = getelementptr inbounds i32, i32* %17, i64 3
%28 = load i32, i32* %27
store i32 %28, i32* %26
%29 = getelementptr inbounds i32, i32* %18, i64 4
%30 = getelementptr inbounds i32, i32* %17, i64 4
%31 = load i32, i32* %30
store i32 %31, i32* %29
br label %32
32: ; preds = %16, %2
ret i32 %5
}