#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 uint8_t;
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int *, int const *, int);
int *ptls_encode_quicint(int *, int /*<<< orphan*/);
uint8_t *quicly_encode_new_connection_id_frame(
    uint8_t *dst, uint64_t sequence, uint64_t retire_prior_to,
    const uint8_t *cid, uint8_t cid_len, const uint8_t *stateless_reset_token) {
  *dst++ = 24;
  dst = ptls_encode_quicint(dst, sequence);
  dst = ptls_encode_quicint(dst, retire_prior_to);
  *dst++ = cid_len;
  memcpy(dst, cid, cid_len);
  dst += cid_len;
  memcpy(dst, stateless_reset_token, 16);
  dst += 16;
  return dst;
}


x86 assembly (clang, -O0):
<quicly_encode_new_connection_id_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
movl   $0x18,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <ptls_encode_quicint@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <ptls_encode_quicint@plt>
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicly_encode_new_connection_id_frame>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8d,%ebp
mov    %rcx,%r15
mov    %edx,%ebx
movl   $0x18,(%rdi)
add    $0x4,%rdi
call   1030 <ptls_encode_quicint@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <ptls_encode_quicint@plt>
mov    %rax,%rbx
lea    0x4(%rax),%rdi
mov    %ebp,(%rax)
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
movslq %ebp,%rbp
lea    (%rbx,%rbp,4),%rdi
add    $0x4,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1040 <memcpy@plt>
lea    (%rbx,%rbp,4),%rax
add    $0x44,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @quicly_encode_new_connection_id_frame(i32* %0, i32 %1, i32 %2, i32* %3, i32 %4, i32* %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32*
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i32* %5, i32** %12
%13 = load i32*, i32** %7
%14 = getelementptr inbounds i32, i32* %13, i32 1
store i32* %14, i32** %7
store i32 24, i32* %13
%15 = load i32*, i32** %7
%16 = load i32, i32* %8
%17 = call i32* @ptls_encode_quicint(i32* %15, i32 %16)
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = load i32, i32* %9
%20 = call i32* @ptls_encode_quicint(i32* %18, i32 %19)
store i32* %20, i32** %7
%21 = load i32, i32* %11
%22 = load i32*, i32** %7
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %7
store i32 %21, i32* %22
%24 = load i32*, i32** %7
%25 = load i32*, i32** %10
%26 = load i32, i32* %11
%27 = call i32 @memcpy(i32* %24, i32* %25, i32 %26)
%28 = load i32, i32* %11
%29 = load i32*, i32** %7
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i32, i32* %29, i64 %30
store i32* %31, i32** %7
%32 = load i32*, i32** %7
%33 = load i32*, i32** %12
%34 = call i32 @memcpy(i32* %32, i32* %33, i32 16)
%35 = load i32*, i32** %7
%36 = getelementptr inbounds i32, i32* %35, i64 16
store i32* %36, i32** %7
%37 = load i32*, i32** %7
ret i32* %37
}

LLVM IR (-O2):
define i32* @quicly_encode_new_connection_id_frame(i32* %0, i32 %1, i32 %2, i32* %3, i32 %4, i32* %5) {
%7 = getelementptr inbounds i32, i32* %0, i64 1
store i32 24, i32* %0
%8 = tail call i32* @ptls_encode_quicint(i32* %7, i32 %1)
%9 = tail call i32* @ptls_encode_quicint(i32* %8, i32 %2)
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32 %4, i32* %9
%11 = tail call i32 @memcpy(i32* %10, i32* %3, i32 %4)
%12 = sext i32 %4 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = tail call i32 @memcpy(i32* %13, i32* %5, i32 16)
%15 = getelementptr inbounds i32, i32* %13, i64 16
ret i32* %15
}