#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 void *uint8_t;

/* Variables and functions */
void memset_fwd_until_dst_word_aligned(uint8_t *ptr, uint8_t c, size_t al) {
  switch (al) {
  case 1:
    *ptr++ = c;
  case 2:
    *ptr++ = c;
  case 3:
    *ptr++ = c;
  }
}


x86 assembly (clang, -O0):
<memset_fwd_until_dst_word_aligned>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
sub    $0x1,%rax
je     114d <memset_fwd_until_dst_word_aligned+0x4d>
jmp    1127 <memset_fwd_until_dst_word_aligned+0x27>
mov    -0x20(%rbp),%rax
sub    $0x2,%rax
je     1163 <memset_fwd_until_dst_word_aligned+0x63>
jmp    113a <memset_fwd_until_dst_word_aligned+0x3a>
mov    -0x20(%rbp),%rax
sub    $0x3,%rax
je     1179 <memset_fwd_until_dst_word_aligned+0x79>
jmp    118f <memset_fwd_until_dst_word_aligned+0x8f>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x8(%rbp)
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x8(%rbp)
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x8(%rbp)
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<memset_fwd_until_dst_word_aligned>:
cmp    $0x3,%rdx
je     1120 <memset_fwd_until_dst_word_aligned+0x20>
cmp    $0x2,%rdx
je     1119 <memset_fwd_until_dst_word_aligned+0x19>
cmp    $0x1,%rdx
jne    1123 <memset_fwd_until_dst_word_aligned+0x23>
mov    %rsi,(%rdi)
add    $0x8,%rdi
mov    %rsi,(%rdi)
add    $0x8,%rdi
mov    %rsi,(%rdi)
ret

LLVM IR (-O0):
define void @memset_fwd_until_dst_word_aligned(i8** %0, i8* %1, i64 %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i64, i64* %6
switch i64 %7, label %20 [
i64 1, label %8
i64 2, label %12
i64 3, label %16
]
8: ; preds = %3
%9 = load i8*, i8** %5
%10 = load i8**, i8*** %4
%11 = getelementptr inbounds i8*, i8** %10, i32 1
store i8** %11, i8*** %4
store i8* %9, i8** %10
br label %12
12: ; preds = %3, %8
%13 = load i8*, i8** %5
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %4
store i8* %13, i8** %14
br label %16
16: ; preds = %3, %12
%17 = load i8*, i8** %5
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %4
store i8* %17, i8** %18
br label %20
20: ; preds = %16, %3
ret void
}

LLVM IR (-O2):
define void @memset_fwd_until_dst_word_aligned(i8** nocapture writeonly %0, i8* %1, i64 %2) {
switch i64 %2, label %11 [
i64 1, label %4
i64 2, label %6
i64 3, label %9
]
4: ; preds = %3
%5 = getelementptr inbounds i8*, i8** %0, i64 1
store i8* %1, i8** %0
br label %6
6: ; preds = %3, %4
%7 = phi i8** [ %0, %3 ], [ %5, %4 ]
%8 = getelementptr inbounds i8*, i8** %7, i64 1
store i8* %1, i8** %7
br label %9
9: ; preds = %3, %6
%10 = phi i8** [ %0, %3 ], [ %8, %6 ]
store i8* %1, i8** %10
br label %11
11: ; preds = %9, %3
ret void
}