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

/* Variables and functions */
int /*<<< orphan*/ *ptls_encode_quicint(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/);
uint8_t *quicly_encode_reset_stream_frame(uint8_t *dst, uint64_t stream_id,
                                          uint16_t app_error_code,
                                          uint64_t final_size) {
  *dst++ = 4;
  dst = ptls_encode_quicint(dst, stream_id);
  dst = ptls_encode_quicint(dst, app_error_code);
  dst = ptls_encode_quicint(dst, final_size);
  return dst;
}


x86 assembly (clang, -O0):
<quicly_encode_reset_stream_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
movl   $0x4,(%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    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <ptls_encode_quicint@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicly_encode_reset_stream_frame>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
movl   $0x4,(%rdi)
add    $0x4,%rdi
call   1030 <ptls_encode_quicint@plt>
mov    %rax,%rdi
mov    %ebp,%esi
call   1030 <ptls_encode_quicint@plt>
mov    %rax,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ptls_encode_quicint@plt>

LLVM IR (-O0):
define i32* @quicly_encode_reset_stream_frame(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32*, i32** %5
%10 = getelementptr inbounds i32, i32* %9, i32 1
store i32* %10, i32** %5
store i32 4, i32* %9
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = call i32* @ptls_encode_quicint(i32* %11, i32 %12)
store i32* %13, i32** %5
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = call i32* @ptls_encode_quicint(i32* %14, i32 %15)
store i32* %16, i32** %5
%17 = load i32*, i32** %5
%18 = load i32, i32* %8
%19 = call i32* @ptls_encode_quicint(i32* %17, i32 %18)
store i32* %19, i32** %5
%20 = load i32*, i32** %5
ret i32* %20
}

LLVM IR (-O2):
define i32* @quicly_encode_reset_stream_frame(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = getelementptr inbounds i32, i32* %0, i64 1
store i32 4, i32* %0
%6 = tail call i32* @ptls_encode_quicint(i32* %5, i32 %1)
%7 = tail call i32* @ptls_encode_quicint(i32* %6, i32 %2)
%8 = tail call i32* @ptls_encode_quicint(i32* %7, i32 %3)
ret i32* %8
}