#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 uint16_t;

/* Variables and functions */
void adts_set_length(uint8_t *p_adts, uint16_t i_length) {
  p_adts[3] &= ~0x03;
  p_adts[3] |= (i_length >> 11) & 0x03;
  p_adts[4] = i_length >> 3;
  p_adts[5] &= ~0xe0;
  p_adts[5] |= (i_length << 5) & 0xe0;
}


x86 assembly (clang, -O0):
<adts_set_length>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%ecx
and    $0xfffffffc,%ecx
mov    %ecx,0xc(%rax)
mov    -0xc(%rbp),%ecx
sar    $0xb,%ecx
and    $0x3,%ecx
mov    -0x8(%rbp),%rax
or     0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x3,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%ecx
and    $0xffffff1f,%ecx
mov    %ecx,0x14(%rax)
mov    -0xc(%rbp),%ecx
shl    $0x5,%ecx
and    $0xe0,%ecx
mov    -0x8(%rbp),%rax
or     0x14(%rax),%ecx
mov    %ecx,0x14(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<adts_set_length>:
mov    0xc(%rdi),%eax
and    $0xfffffffc,%eax
mov    %esi,%ecx
shr    $0xb,%ecx
and    $0x3,%ecx
or     %eax,%ecx
mov    %ecx,0xc(%rdi)
mov    %esi,%eax
sar    $0x3,%eax
mov    %eax,0x10(%rdi)
mov    $0xffffff1f,%eax
and    0x14(%rdi),%eax
shl    $0x5,%esi
movzbl %sil,%ecx
or     %eax,%ecx
mov    %ecx,0x14(%rdi)
ret

LLVM IR (-O0):
define void @adts_set_length(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32*, i32** %3
%6 = getelementptr inbounds i32, i32* %5, i64 3
%7 = load i32, i32* %6
%8 = and i32 %7, -4
store i32 %8, i32* %6
%9 = load i32, i32* %4
%10 = ashr i32 %9, 11
%11 = and i32 %10, 3
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 3
%14 = load i32, i32* %13
%15 = or i32 %14, %11
store i32 %15, i32* %13
%16 = load i32, i32* %4
%17 = ashr i32 %16, 3
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 4
store i32 %17, i32* %19
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 5
%22 = load i32, i32* %21
%23 = and i32 %22, -225
store i32 %23, i32* %21
%24 = load i32, i32* %4
%25 = shl i32 %24, 5
%26 = and i32 %25, 224
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 5
%29 = load i32, i32* %28
%30 = or i32 %29, %26
store i32 %30, i32* %28
ret void
}

LLVM IR (-O2):
define void @adts_set_length(i32* nocapture %0, i32 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 3
%4 = load i32, i32* %3
%5 = and i32 %4, -4
%6 = lshr i32 %1, 11
%7 = and i32 %6, 3
%8 = or i32 %5, %7
store i32 %8, i32* %3
%9 = ashr i32 %1, 3
%10 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %9, i32* %10
%11 = getelementptr inbounds i32, i32* %0, i64 5
%12 = load i32, i32* %11
%13 = and i32 %12, -225
%14 = shl i32 %1, 5
%15 = and i32 %14, 224
%16 = or i32 %13, %15
store i32 %16, i32* %11
ret void
}