#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;
typedef int uint32_t;

/* Variables and functions */
uint8_t *quicly_encode32(uint8_t *p, uint32_t v) {
  *p++ = (uint8_t)(v >> 24);
  *p++ = (uint8_t)(v >> 16);
  *p++ = (uint8_t)(v >> 8);
  *p++ = (uint8_t)v;
  return p;
}


x86 assembly (clang, -O0):
<quicly_encode32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x18,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x8(%rbp)
mov    %rcx,(%rax)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x8(%rbp)
mov    %rcx,(%rax)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
movslq %eax,%rcx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x8(%rbp)
mov    %rcx,(%rax)
movslq -0xc(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x8(%rbp)
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicly_encode32>:
mov    %esi,%eax
sar    $0x18,%eax
cltq
mov    %rax,(%rdi)
mov    %esi,%eax
sar    $0x10,%eax
cltq
mov    %rax,0x8(%rdi)
movslq %esi,%rax
sar    $0x8,%esi
movslq %esi,%rcx
mov    %rcx,0x10(%rdi)
mov    %rax,0x18(%rdi)
lea    0x20(%rdi),%rax
ret

LLVM IR (-O0):
define i8** @quicly_encode32(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 = ashr i32 %5, 24
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %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 = ashr i32 %11, 16
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %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 = ashr i32 %17, 8
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %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 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i8*
%26 = load i8**, i8*** %3
%27 = getelementptr inbounds i8*, i8** %26, i32 1
store i8** %27, i8*** %3
store i8* %25, i8** %26
%28 = load i8**, i8*** %3
ret i8** %28
}

LLVM IR (-O2):
define i8** @quicly_encode32(i8** writeonly %0, i32 %1) {
%3 = ashr i32 %1, 24
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i8*
%6 = getelementptr inbounds i8*, i8** %0, i64 1
store i8* %5, i8** %0
%7 = ashr i32 %1, 16
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = getelementptr inbounds i8*, i8** %0, i64 2
store i8* %9, i8** %6
%11 = ashr i32 %1, 8
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
%14 = getelementptr inbounds i8*, i8** %0, i64 3
store i8* %13, i8** %10
%15 = sext i32 %1 to i64
%16 = inttoptr i64 %15 to i8*
%17 = getelementptr inbounds i8*, i8** %0, i64 4
store i8* %16, i8** %14
ret i8** %17
}