#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*/ c;

/* Variables and functions */
void memsetl(void *s, unsigned long c, size_t n) {
  unsigned char *p = (unsigned char *)s;
  size_t i;
  for (i = 0; i < n; i++)
    p[i] = c >> (8 * (i % sizeof(c)));
}


x86 assembly (clang, -O0):
<memsetl>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    115f <memsetl+0x5f>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
and    $0x7,%rcx
shl    $0x3,%rcx
shr    %cl,%rax
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1120 <memsetl+0x20>
pop    %rbp
ret

x86 assembly (clang, -O2):
<memsetl>:
test   %rdx,%rdx
je     157c <memsetl+0x47c>
cmp    $0x10,%rdx
jae    1117 <memsetl+0x17>
xor    %r10d,%r10d
jmp    154d <memsetl+0x44d>
mov    %rdx,%r10
and    $0xfffffffffffffff0,%r10
movq   %rsi,%xmm0
pshufd $0x44,%xmm0,%xmm11
lea    -0x10(%r10),%rax
mov    %rax,%r8
shr    $0x4,%r8
add    $0x1,%r8
test   %rax,%rax
je     157d <memsetl+0x47d>
mov    %r8,%rcx
and    $0xfffffffffffffffe,%rcx
movdqa 0xeef(%rip),%xmm14
movdqa 0xef6(%rip),%xmm8
movdqa 0xefe(%rip),%xmm7
movdqa 0xf06(%rip),%xmm6
movdqa 0xf0e(%rip),%xmm3
movdqa 0xf15(%rip),%xmm12
movdqa 0xf1c(%rip),%xmm15
movdqa 0xf23(%rip),%xmm10
xor    %r9d,%r9d
movdqa %xmm7,-0x48(%rsp)
movdqa %xmm6,-0x38(%rsp)
movdqa %xmm3,-0x28(%rsp)
movdqa %xmm10,-0x18(%rsp)
movdqa %xmm14,%xmm0
psllq  $0x3,%xmm0
movdqa %xmm8,%xmm4
psllq  $0x3,%xmm4
movdqa %xmm7,%xmm2
psllq  $0x3,%xmm2
movdqa %xmm6,%xmm1
psllq  $0x3,%xmm1
movdqa %xmm3,%xmm9
psllq  $0x3,%xmm9
movdqa %xmm12,%xmm13
psllq  $0x3,%xmm13
movdqa %xmm15,%xmm5
psllq  $0x3,%xmm5
movdqa %xmm10,%xmm3
psllq  $0x3,%xmm3
movdqa 0xebf(%rip),%xmm6
pand   %xmm6,%xmm3
pand   %xmm6,%xmm5
pand   %xmm6,%xmm13
pand   %xmm6,%xmm9
pand   %xmm6,%xmm1
pand   %xmm6,%xmm2
pand   %xmm6,%xmm4
pand   %xmm6,%xmm0
movdqa %xmm11,%xmm6
psrlq  %xmm0,%xmm6
pshufd $0xee,%xmm0,%xmm10
movdqa %xmm11,%xmm0
psrlq  %xmm10,%xmm0
movdqa %xmm11,%xmm7
psrlq  %xmm4,%xmm7
movsd  %xmm6,%xmm0
pshufd $0xee,%xmm4,%xmm6
movdqa %xmm11,%xmm4
psrlq  %xmm6,%xmm4
movsd  %xmm7,%xmm4
movdqa %xmm11,%xmm6
psrlq  %xmm2,%xmm6
pshufd $0xee,%xmm2,%xmm7
movdqa %xmm11,%xmm10
psrlq  %xmm7,%xmm10
movdqa %xmm11,%xmm7
psrlq  %xmm1,%xmm7
movsd  %xmm6,%xmm10
pshufd $0xee,%xmm1,%xmm6
movdqa %xmm11,%xmm1
psrlq  %xmm6,%xmm1
movsd  %xmm7,%xmm1
movdqa %xmm11,%xmm7
psrlq  %xmm9,%xmm7
pshufd $0xee,%xmm9,%xmm9
movdqa %xmm11,%xmm6
psrlq  %xmm9,%xmm6
movdqa %xmm11,%xmm2
psrlq  %xmm13,%xmm2
movsd  %xmm7,%xmm6
pshufd $0xee,%xmm13,%xmm9
movdqa %xmm11,%xmm7
psrlq  %xmm9,%xmm7
movsd  %xmm2,%xmm7
movdqa %xmm11,%xmm13
psrlq  %xmm5,%xmm13
pshufd $0xee,%xmm5,%xmm9
movdqa %xmm11,%xmm5
psrlq  %xmm9,%xmm5
movdqa %xmm11,%xmm2
psrlq  %xmm3,%xmm2
movsd  %xmm13,%xmm5
pshufd $0xee,%xmm3,%xmm9
movdqa %xmm11,%xmm3
psrlq  %xmm9,%xmm3
movsd  %xmm2,%xmm3
movapd 0xdbd(%rip),%xmm2
andpd  %xmm2,%xmm3
andpd  %xmm2,%xmm5
packuswb %xmm5,%xmm3
andpd  %xmm2,%xmm7
andpd  %xmm2,%xmm6
packuswb %xmm6,%xmm7
movdqa -0x38(%rsp),%xmm6
packuswb %xmm7,%xmm3
andpd  %xmm2,%xmm1
andpd  %xmm2,%xmm10
packuswb %xmm10,%xmm1
movdqa -0x48(%rsp),%xmm7
movdqa -0x18(%rsp),%xmm10
andpd  %xmm2,%xmm4
andpd  %xmm2,%xmm0
packuswb %xmm0,%xmm4
packuswb %xmm4,%xmm1
packuswb %xmm1,%xmm3
movdqu %xmm3,(%rdi,%r9,1)
movdqu %xmm3,0x10(%rdi,%r9,1)
movdqa -0x28(%rsp),%xmm3
add    $0x20,%r9
movdqa 0xd5d(%rip),%xmm0
paddq  %xmm0,%xmm10
paddq  %xmm0,%xmm15
paddq  %xmm0,%xmm12
paddq  %xmm0,%xmm3
paddq  %xmm0,%xmm6
paddq  %xmm0,%xmm7
paddq  %xmm0,%xmm8
paddq  %xmm0,%xmm14
add    $0xfffffffffffffffe,%rcx
jne    1190 <memsetl+0x90>
psllq  $0x3,%xmm14
psllq  $0x3,%xmm8
psllq  $0x3,%xmm7
psllq  $0x3,%xmm6
psllq  $0x3,%xmm3
psllq  $0x3,%xmm12
psllq  $0x3,%xmm15
psllq  $0x3,%xmm10
movdqa 0xcd9(%rip),%xmm0
pand   %xmm0,%xmm10
pand   %xmm0,%xmm15
pand   %xmm0,%xmm12
pand   %xmm0,%xmm3
pand   %xmm0,%xmm6
pand   %xmm0,%xmm7
pand   %xmm0,%xmm8
pand   %xmm0,%xmm14
test   $0x1,%r8b
je     1548 <memsetl+0x448>
movdqa %xmm11,%xmm1
psrlq  %xmm14,%xmm1
pshufd $0xee,%xmm14,%xmm2
movdqa %xmm11,%xmm9
psrlq  %xmm2,%xmm9
movsd  %xmm1,%xmm9
movdqa %xmm11,%xmm1
psrlq  %xmm8,%xmm1
pshufd $0xee,%xmm8,%xmm2
movdqa %xmm11,%xmm4
psrlq  %xmm2,%xmm4
movdqa %xmm11,%xmm2
psrlq  %xmm7,%xmm2
movsd  %xmm1,%xmm4
pshufd $0xee,%xmm7,%xmm1
movdqa %xmm11,%xmm7
psrlq  %xmm1,%xmm7
movsd  %xmm2,%xmm7
movdqa %xmm11,%xmm2
psrlq  %xmm6,%xmm2
pshufd $0xee,%xmm6,%xmm5
movdqa %xmm11,%xmm1
psrlq  %xmm5,%xmm1
movdqa %xmm11,%xmm5
psrlq  %xmm3,%xmm5
movsd  %xmm2,%xmm1
pshufd $0xee,%xmm3,%xmm6
movdqa %xmm11,%xmm2
psrlq  %xmm6,%xmm2
movsd  %xmm5,%xmm2
movdqa %xmm11,%xmm5
psrlq  %xmm12,%xmm5
pshufd $0xee,%xmm12,%xmm6
movdqa %xmm11,%xmm3
psrlq  %xmm6,%xmm3
movdqa %xmm11,%xmm6
psrlq  %xmm15,%xmm6
movsd  %xmm5,%xmm3
pshufd $0xee,%xmm15,%xmm8
movdqa %xmm11,%xmm5
psrlq  %xmm8,%xmm5
movsd  %xmm6,%xmm5
movdqa %xmm11,%xmm6
psrlq  %xmm10,%xmm6
pshufd $0xee,%xmm10,%xmm0
psrlq  %xmm0,%xmm11
movsd  %xmm6,%xmm11
movapd 0xbd0(%rip),%xmm0
andpd  %xmm0,%xmm11
andpd  %xmm0,%xmm5
packuswb %xmm5,%xmm11
andpd  %xmm0,%xmm3
andpd  %xmm0,%xmm2
packuswb %xmm2,%xmm3
packuswb %xmm3,%xmm11
andpd  %xmm0,%xmm1
andpd  %xmm0,%xmm7
packuswb %xmm7,%xmm1
andpd  %xmm0,%xmm4
andpd  %xmm0,%xmm9
packuswb %xmm9,%xmm4
packuswb %xmm4,%xmm1
packuswb %xmm1,%xmm11
movdqu %xmm11,(%rdi,%r9,1)
cmp    %rdx,%r10
je     157c <memsetl+0x47c>
lea    0x0(,%r10,8),%rax
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%ecx
and    $0x38,%cl
mov    %rsi,%r8
shr    %cl,%r8
mov    %r8b,(%rdi,%r10,1)
add    $0x1,%r10
add    $0x8,%rax
cmp    %r10,%rdx
jne    1560 <memsetl+0x460>
ret
movdqa 0xa7b(%rip),%xmm3
movdqa 0xa82(%rip),%xmm12
movdqa 0xa89(%rip),%xmm15
movdqa 0xa90(%rip),%xmm10
xor    %r9d,%r9d
movdqa %xmm10,%xmm6
movdqa %xmm15,%xmm7
movdqa %xmm12,%xmm8
movdqa %xmm3,%xmm14
test   $0x1,%r8b
jne    1416 <memsetl+0x316>
jmp    1548 <memsetl+0x448>

LLVM IR (-O0):
define void @memsetl(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %7
store i64 0, i64* %8
br label %10
10: ; preds = %24, %3
%11 = load i64, i64* %8
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i64, i64* %5
%16 = load i64, i64* %8
%17 = urem i64 %16, 8
%18 = mul i64 8, %17
%19 = lshr i64 %15, %18
%20 = trunc i64 %19 to i8
%21 = load i8*, i8** %7
%22 = load i64, i64* %8
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8 %20, i8* %23
br label %24
24: ; preds = %14
%25 = load i64, i64* %8
%26 = add i64 %25, 1
store i64 %26, i64* %8
br label %10
27: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @memsetl(i8* nocapture writeonly %0, i64 %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %64, label %5
5: ; preds = %3
%6 = icmp ult i64 %2, 16
br i1 %6, label %53, label %7
7: ; preds = %5
%8 = and i64 %2, -16
%9 = insertelement <16 x i64> poison, i64 %1, i64 0
%10 = shufflevector <16 x i64> %9, <16 x i64> poison, <16 x i32> zeroinitializer
%11 = add i64 %8, -16
%12 = lshr exact i64 %11, 4
%13 = add nuw nsw i64 %12, 1
%14 = and i64 %13, 1
%15 = icmp eq i64 %11, 0
br i1 %15, label %42, label %16
16: ; preds = %7
%17 = and i64 %13, 2305843009213693950
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %35, %18 ]
%20 = phi <16 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, %16 ], [ %36, %18 ]
%21 = phi i64 [ 0, %16 ], [ %37, %18 ]
%22 = shl <16 x i64> %20, <i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3>
%23 = and <16 x i64> %22, <i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56>
%24 = lshr <16 x i64> %10, %23
%25 = trunc <16 x i64> %24 to <16 x i8>
%26 = getelementptr inbounds i8, i8* %0, i64 %19
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> %25, <16 x i8>* %27
%28 = or i64 %19, 16
%29 = shl <16 x i64> %20, <i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3>
%30 = and <16 x i64> %29, <i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56>
%31 = lshr <16 x i64> %10, %30
%32 = trunc <16 x i64> %31 to <16 x i8>
%33 = getelementptr inbounds i8, i8* %0, i64 %28
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %34
%35 = add nuw i64 %19, 32
%36 = add <16 x i64> %20, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32>
%37 = add i64 %21, 2
%38 = icmp eq i64 %37, %17
br i1 %38, label %39, label %18
39: ; preds = %18
%40 = shl <16 x i64> %36, <i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3, i64 3>
%41 = and <16 x i64> %40, <i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56>
br label %42
42: ; preds = %39, %7
%43 = phi i64 [ 0, %7 ], [ %35, %39 ]
%44 = phi <16 x i64> [ <i64 0, i64 8, i64 16, i64 24, i64 32, i64 40, i64 48, i64 56, i64 0, i64 8, i64 16, i64 24, i64 32, i64 40, i64 48, i64 56>, %7 ], [ %41, %39 ]
%45 = icmp eq i64 %14, 0
br i1 %45, label %51, label %46
46: ; preds = %42
%47 = lshr <16 x i64> %10, %44
%48 = trunc <16 x i64> %47 to <16 x i8>
%49 = getelementptr inbounds i8, i8* %0, i64 %43
%50 = bitcast i8* %49 to <16 x i8>*
store <16 x i8> %48, <16 x i8>* %50
br label %51
51: ; preds = %42, %46
%52 = icmp eq i64 %8, %2
br i1 %52, label %64, label %53
53: ; preds = %5, %51
%54 = phi i64 [ 0, %5 ], [ %8, %51 ]
br label %55
55: ; preds = %53, %55
%56 = phi i64 [ %62, %55 ], [ %54, %53 ]
%57 = shl i64 %56, 3
%58 = and i64 %57, 56
%59 = lshr i64 %1, %58
%60 = trunc i64 %59 to i8
%61 = getelementptr inbounds i8, i8* %0, i64 %56
store i8 %60, i8* %61
%62 = add nuw i64 %56, 1
%63 = icmp eq i64 %62, %2
br i1 %63, label %64, label %55
64: ; preds = %55, %51, %3
ret void
}