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

/* Variables and functions */
void *i64c(unsigned int);
void to64_msb_first(char *s, unsigned v) {
  *s++ = i64c(v >> 18);
  *s++ = i64c(v >> 12);
  *s++ = i64c(v >> 6);
  *s = i64c(v);
}


x86 assembly (clang, -O0):
<to64_msb_first>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
shr    $0x12,%edi
call   1030 <i64c@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%edi
shr    $0xc,%edi
call   1030 <i64c@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%edi
shr    $0x6,%edi
call   1030 <i64c@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%edi
call   1030 <i64c@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to64_msb_first>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
shr    $0x12,%edi
call   1030 <i64c@plt>
mov    %al,(%rbx)
mov    %ebp,%edi
shr    $0xc,%edi
call   1030 <i64c@plt>
mov    %al,0x1(%rbx)
mov    %ebp,%edi
shr    $0x6,%edi
call   1030 <i64c@plt>
mov    %al,0x2(%rbx)
mov    %ebp,%edi
call   1030 <i64c@plt>
mov    %al,0x3(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @to64_msb_first(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = lshr i32 %5, 18
%7 = call i8* @i64c(i32 %6)
%8 = ptrtoint i8* %7 to i8
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %3
store i8 %8, i8* %9
%11 = load i32, i32* %4
%12 = lshr i32 %11, 12
%13 = call i8* @i64c(i32 %12)
%14 = ptrtoint i8* %13 to i8
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
store i8 %14, i8* %15
%17 = load i32, i32* %4
%18 = lshr i32 %17, 6
%19 = call i8* @i64c(i32 %18)
%20 = ptrtoint i8* %19 to i8
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 %20, i8* %21
%23 = load i32, i32* %4
%24 = call i8* @i64c(i32 %23)
%25 = ptrtoint i8* %24 to i8
%26 = load i8*, i8** %3
store i8 %25, i8* %26
ret void
}

LLVM IR (-O2):
define void @to64_msb_first(i8* nocapture writeonly %0, i32 %1) {
%3 = lshr i32 %1, 18
%4 = tail call i8* @i64c(i32 %3)
%5 = ptrtoint i8* %4 to i64
%6 = trunc i64 %5 to i8
%7 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %6, i8* %0
%8 = lshr i32 %1, 12
%9 = tail call i8* @i64c(i32 %8)
%10 = ptrtoint i8* %9 to i64
%11 = trunc i64 %10 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %11, i8* %7
%13 = lshr i32 %1, 6
%14 = tail call i8* @i64c(i32 %13)
%15 = ptrtoint i8* %14 to i64
%16 = trunc i64 %15 to i8
%17 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %16, i8* %12
%18 = tail call i8* @i64c(i32 %1)
%19 = ptrtoint i8* %18 to i64
%20 = trunc i64 %19 to i8
store i8 %20, i8* %17
ret void
}