#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 scalar_t__ uint8_t;
typedef int uint64_t;

/* Variables and functions */
void *memset64(void *dest, uint8_t c, size_t n) {
  uint64_t pattern = (uint64_t)c;
  pattern |= ((uint64_t)c) << 8;
  pattern |= ((uint64_t)c) << 16;
  pattern |= ((uint64_t)c) << 24;
  pattern |= ((uint64_t)c) << 32;
  pattern |= ((uint64_t)c) << 40;
  pattern |= ((uint64_t)c) << 48;
  pattern |= ((uint64_t)c) << 56;
  do {
    uint64_t *p = (uint64_t *)dest;
    for (; n >= sizeof(uint64_t); n -= sizeof(uint64_t))
      *p++ = pattern;
  } while (0);
  return (dest);
}


x86 assembly (clang, -O0):
<memset64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x8,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x10,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x18,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x20,%ecx
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x28,%ecx
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x30,%ecx
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x38,%ecx
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x4,-0x18(%rbp)
jb     11ba <memset64+0xba>
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x28(%rbp)
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
sub    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    118a <memset64+0x8a>
jmp    11bf <memset64+0xbf>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<memset64>:
mov    %rdi,%rax
ret

LLVM IR (-O0):
define i8* @memset64(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i64, i64* %5
%10 = trunc i64 %9 to i32
store i32 %10, i32* %7
%11 = load i64, i64* %5
%12 = trunc i64 %11 to i32
%13 = shl i32 %12, 8
%14 = load i32, i32* %7
%15 = or i32 %14, %13
store i32 %15, i32* %7
%16 = load i64, i64* %5
%17 = trunc i64 %16 to i32
%18 = shl i32 %17, 16
%19 = load i32, i32* %7
%20 = or i32 %19, %18
store i32 %20, i32* %7
%21 = load i64, i64* %5
%22 = trunc i64 %21 to i32
%23 = shl i32 %22, 24
%24 = load i32, i32* %7
%25 = or i32 %24, %23
store i32 %25, i32* %7
%26 = load i64, i64* %5
%27 = trunc i64 %26 to i32
%28 = shl i32 %27, 32
%29 = load i32, i32* %7
%30 = or i32 %29, %28
store i32 %30, i32* %7
%31 = load i64, i64* %5
%32 = trunc i64 %31 to i32
%33 = shl i32 %32, 40
%34 = load i32, i32* %7
%35 = or i32 %34, %33
store i32 %35, i32* %7
%36 = load i64, i64* %5
%37 = trunc i64 %36 to i32
%38 = shl i32 %37, 48
%39 = load i32, i32* %7
%40 = or i32 %39, %38
store i32 %40, i32* %7
%41 = load i64, i64* %5
%42 = trunc i64 %41 to i32
%43 = shl i32 %42, 56
%44 = load i32, i32* %7
%45 = or i32 %44, %43
store i32 %45, i32* %7
br label %46
46: ; preds = %3
%47 = load i8*, i8** %4
%48 = bitcast i8* %47 to i32*
store i32* %48, i32** %8
br label %49
49: ; preds = %56, %46
%50 = load i64, i64* %6
%51 = icmp uge i64 %50, 4
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load i32, i32* %7
%54 = load i32*, i32** %8
%55 = getelementptr inbounds i32, i32* %54, i32 1
store i32* %55, i32** %8
store i32 %53, i32* %54
br label %56
56: ; preds = %52
%57 = load i64, i64* %6
%58 = sub i64 %57, 4
store i64 %58, i64* %6
br label %49
59: ; preds = %49
br label %60
60: ; preds = %59
%61 = load i8*, i8** %4
ret i8* %61
}

LLVM IR (-O2):
define i8* @memset64(i8* readnone returned %0, i64 %1, i64 %2) {
ret i8* %0
}