#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 uint32_t;
typedef int /*<<< orphan*/ uint16_t;
struct ts_nit {
  int dummy;
};

/* Variables and functions */
int *calloc(int, int);
int ts_nit_add_stream(struct ts_nit *, int /*<<< orphan*/, int /*<<< orphan*/,
                      int *, int);
int ts_nit_add_stream_descriptors(struct ts_nit *nit, uint16_t ts_id,
                                  uint16_t org_net_id, uint32_t freq,
                                  uint8_t modulation, uint32_t symbol_rate,
                                  uint32_t *lcn_services,
                                  uint32_t *svc_services,
                                  uint8_t num_services) {
  if (!num_services || num_services > 85)
    return 0;
  int desc_size = 13 + 6 + 2 + 2 + num_services * 4 + num_services * 3;
  uint8_t *desc = calloc(1, desc_size);
  desc[0] = 0x44;
  desc[1] = 11;
  desc[2] = ((freq & ~0x00ffffff) >> 24);
  desc[3] = ((freq & ~0xff00ffff) >> 16);
  desc[4] = ((freq & ~0xffff00ff) >> 8);
  desc[5] = (freq & ~0xffffff00);
  desc[6] = 0xff;
  desc[7] = 0xf0;
  desc[8] = modulation;
  desc[9] = (symbol_rate >> 20) & ~0xffffff00;
  desc[10] = (symbol_rate >> 12) & ~0xffffff00;
  desc[11] = (symbol_rate >> 4) & ~0xffffff00;
  desc[12] = (symbol_rate & ~0xfffffff0) << 4;
  desc[12] |= 0;
  uint8_t i;
  int desc_svc_size = 2 + num_services * 3;
  int dpos = 13;
  desc[dpos + 0] = 0x41;
  desc[dpos + 1] = desc_svc_size - 2;
  dpos += 2;
  for (i = 0; i < num_services; i++) {
    uint32_t srv = svc_services[i];
    desc[dpos + 0] = (srv & ~0xff00ffff) >> 16;
    desc[dpos + 1] = (srv & ~0xffff00ff) >> 8;
    desc[dpos + 2] = (srv & ~0xffffff00);
    dpos += 3;
  }
  int desc_prv_size = 2 + 4;
  desc[dpos + 0] = 0x5f;
  desc[dpos + 1] = desc_prv_size - 2;
  desc[dpos + 2] = 0x00;
  desc[dpos + 3] = 0x00;
  desc[dpos + 4] = 0x00;
  desc[dpos + 5] = 0x29;
  dpos += 6;
  if (!num_services || num_services > 85)
    return 0;
  int desc_lcn_size = 2 + num_services * 4;
  desc[dpos + 0] = 0x83;
  desc[dpos + 1] = desc_lcn_size - 2;
  dpos += 2;
  for (i = 0; i < (num_services); i++) {
    uint32_t srv = lcn_services[i];
    desc[dpos + 0] = (srv & ~0x00ffffff) >> 24;
    desc[dpos + 1] = (srv & ~0xff00ffff) >> 16;
    desc[dpos + 2] = (srv & ~0xffff00ff) >> 8;
    desc[dpos + 3] = (srv & ~0xffffff00);
    dpos += 4;
  }
  return ts_nit_add_stream(nit, ts_id, org_net_id, desc, desc_size);
}


x86 assembly (clang, -O0):
<ts_nit_add_stream_descriptors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x0,0x20(%rbp)
je     115c <ts_nit_add_stream_descriptors+0x3c>
cmpl   $0x55,0x20(%rbp)
jle    1168 <ts_nit_add_stream_descriptors+0x48>
movl   $0x0,-0x4(%rbp)
jmp    14d4 <ts_nit_add_stream_descriptors+0x3b4>
mov    0x20(%rbp),%eax
shl    $0x2,%eax
add    $0x17,%eax
imul   $0x3,0x20(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
mov    $0x1,%edi
call   1030 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movl   $0x44,(%rax)
mov    -0x30(%rbp),%rax
movl   $0xb,0x4(%rax)
mov    -0x1c(%rbp),%ecx
and    $0xff000000,%ecx
sar    $0x18,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x1c(%rbp),%ecx
and    $0xff0000,%ecx
shr    $0x10,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x1c(%rbp),%ecx
and    $0xff00,%ecx
shr    $0x8,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x1c(%rbp),%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x30(%rbp),%rax
movl   $0xff,0x18(%rax)
mov    -0x30(%rbp),%rax
movl   $0xf0,0x1c(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x24(%rbp),%ecx
sar    $0x14,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x24(%rbp),%ecx
sar    $0xc,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x24(%rbp),%ecx
sar    $0x4,%ecx
and    $0xff,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0x24(%rbp),%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x30(%rbp),%rax
mov    0x30(%rax),%ecx
or     $0x0,%ecx
mov    %ecx,0x30(%rax)
imul   $0x3,0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x38(%rbp)
movl   $0xd,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movl   $0x41,(%rax,%rcx,4)
mov    -0x38(%rbp),%edx
sub    $0x2,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    132c <ts_nit_add_stream_descriptors+0x20c>
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edx
and    $0xff0000,%edx
shr    $0x10,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x40(%rbp),%edx
and    $0xff00,%edx
shr    $0x8,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x40(%rbp),%edx
and    $0xff,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12aa <ts_nit_add_stream_descriptors+0x18a>
movl   $0x6,-0x44(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movl   $0x5f,(%rax,%rcx,4)
mov    -0x44(%rbp),%edx
sub    $0x2,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
movl   $0x29,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x6,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,0x20(%rbp)
je     13ca <ts_nit_add_stream_descriptors+0x2aa>
cmpl   $0x55,0x20(%rbp)
jle    13d6 <ts_nit_add_stream_descriptors+0x2b6>
movl   $0x0,-0x4(%rbp)
jmp    14d4 <ts_nit_add_stream_descriptors+0x3b4>
mov    0x20(%rbp),%eax
shl    $0x2,%eax
add    $0x2,%eax
mov    %eax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movl   $0x83,(%rax,%rcx,4)
mov    -0x48(%rbp),%edx
sub    $0x2,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    14ba <ts_nit_add_stream_descriptors+0x39a>
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edx
and    $0xff000000,%edx
sar    $0x18,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4c(%rbp),%edx
and    $0xff0000,%edx
shr    $0x10,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4c(%rbp),%edx
and    $0xff00,%edx
shr    $0x8,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4c(%rbp),%edx
and    $0xff,%edx
mov    -0x30(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    141c <ts_nit_add_stream_descriptors+0x2fc>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8d
call   1040 <ts_nit_add_stream@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_nit_add_stream_descriptors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x70(%rsp),%r12d
test   %r12d,%r12d
je     124b <ts_nit_add_stream_descriptors+0x12b>
cmp    $0x55,%r12d
jg     124b <ts_nit_add_stream_descriptors+0x12b>
mov    %r9d,%r14d
mov    %r8d,%ebp
mov    %ecx,%ebx
mov    %rdi,0x20(%rsp)
mov    %esi,0x10(%rsp)
mov    %edx,0x14(%rsp)
mov    0x68(%rsp),%r13
mov    0x60(%rsp),%r15
lea    0x0(,%r12,4),%eax
mov    %eax,0x8(%rsp)
lea    (%r12,%r12,2),%eax
mov    %rax,0x18(%rsp)
lea    (%rax,%r12,4),%esi
add    $0x17,%esi
mov    $0x1,%edi
mov    %esi,0xc(%rsp)
call   1030 <calloc@plt>
movabs $0xb00000044,%rcx
mov    %rcx,(%rax)
mov    %ebx,%ecx
sar    $0x18,%ecx
mov    %ecx,0x8(%rax)
mov    %ebx,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %ecx,0xc(%rax)
movzbl %bh,%ecx
mov    %ecx,0x10(%rax)
movzbl %bl,%ecx
mov    %ecx,0x14(%rax)
movabs $0xf0000000ff,%rcx
mov    %rcx,0x18(%rax)
mov    %ebp,0x20(%rax)
mov    %r14d,%ecx
shr    $0x14,%ecx
movzbl %cl,%ecx
mov    %ecx,0x24(%rax)
mov    %r14d,%ecx
shr    $0xc,%ecx
movzbl %cl,%ecx
mov    %ecx,0x28(%rax)
mov    %r14d,%ecx
shr    $0x4,%ecx
movzbl %cl,%ecx
mov    %ecx,0x2c(%rax)
shl    $0x4,%r14d
movzbl %r14b,%ecx
mov    %ecx,0x30(%rax)
movl   $0x41,0x34(%rax)
mov    0x18(%rsp),%rcx
mov    %ecx,0x38(%rax)
mov    %r12d,%r8d
test   %r12d,%r12d
jle    125c <ts_nit_add_stream_descriptors+0x13c>
mov    $0xf,%edx
xor    %esi,%esi
nopl   0x0(%rax)
mov    0x0(%r13,%rsi,4),%ebx
movzbl %bh,%edi
movzbl %bl,%ebp
shr    $0x10,%ebx
movzbl %bl,%ebx
mov    %ebx,(%rax,%rdx,4)
mov    %edi,0x4(%rax,%rdx,4)
mov    %ebp,0x8(%rax,%rdx,4)
add    $0x3,%rdx
add    $0x1,%rsi
cmp    %rsi,%r8
jne    1220 <ts_nit_add_stream_descriptors+0x100>
jmp    1261 <ts_nit_add_stream_descriptors+0x141>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xf,%edx
mov    %edx,%esi
movaps 0xd96(%rip),%xmm0
movups %xmm0,(%rax,%rsi,4)
movabs $0x2900000000,%rdi
mov    %rdi,0x10(%rax,%rsi,4)
movl   $0x83,0x18(%rax,%rsi,4)
mov    0x8(%rsp),%ecx
mov    %ecx,0x1c(%rax,%rsi,4)
test   %r12d,%r12d
jle    12de <ts_nit_add_stream_descriptors+0x1be>
add    $0x8,%edx
lea    (%rax,%rdx,4),%rdx
add    $0xc,%rdx
shl    $0x2,%r8
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rsi,1),%ebx
mov    %ebx,%edi
movzbl %bh,%ebp
movzbl %bl,%ecx
sar    $0x18,%ebx
mov    %ebx,-0xc(%rdx,%rsi,4)
shr    $0x10,%edi
movzbl %dil,%edi
mov    %edi,-0x8(%rdx,%rsi,4)
mov    %ebp,-0x4(%rdx,%rsi,4)
mov    %ecx,(%rdx,%rsi,4)
add    $0x4,%rsi
cmp    %rsi,%r8
jne    12b0 <ts_nit_add_stream_descriptors+0x190>
mov    0x20(%rsp),%rdi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    %rax,%rcx
mov    0xc(%rsp),%r8d
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ts_nit_add_stream@plt>

LLVM IR (-O0):
%struct.ts_nit = type { i32 }
define i32 @ts_nit_add_stream_descriptors(%struct.ts_nit* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* %6, i32* %7, i32 %8) {
%10 = alloca i32
%11 = alloca %struct.ts_nit*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32*
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
store %struct.ts_nit* %0, %struct.ts_nit** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store i32* %6, i32** %17
store i32* %7, i32** %18
store i32 %8, i32* %19
%29 = load i32, i32* %19
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %9
%32 = load i32, i32* %19
%33 = icmp sgt i32 %32, 85
br i1 %33, label %34, label %35
34: ; preds = %31, %9
store i32 0, i32* %10
br label %265
35: ; preds = %31
%36 = load i32, i32* %19
%37 = mul nsw i32 %36, 4
%38 = add nsw i32 23, %37
%39 = load i32, i32* %19
%40 = mul nsw i32 %39, 3
%41 = add nsw i32 %38, %40
store i32 %41, i32* %20
%42 = load i32, i32* %20
%43 = call i32* @calloc(i32 1, i32 %42)
store i32* %43, i32** %21
%44 = load i32*, i32** %21
%45 = getelementptr inbounds i32, i32* %44, i64 0
store i32 68, i32* %45
%46 = load i32*, i32** %21
%47 = getelementptr inbounds i32, i32* %46, i64 1
store i32 11, i32* %47
%48 = load i32, i32* %14
%49 = and i32 %48, -16777216
%50 = ashr i32 %49, 24
%51 = load i32*, i32** %21
%52 = getelementptr inbounds i32, i32* %51, i64 2
store i32 %50, i32* %52
%53 = load i32, i32* %14
%54 = and i32 %53, 16711680
%55 = lshr i32 %54, 16
%56 = load i32*, i32** %21
%57 = getelementptr inbounds i32, i32* %56, i64 3
store i32 %55, i32* %57
%58 = load i32, i32* %14
%59 = and i32 %58, 65280
%60 = lshr i32 %59, 8
%61 = load i32*, i32** %21
%62 = getelementptr inbounds i32, i32* %61, i64 4
store i32 %60, i32* %62
%63 = load i32, i32* %14
%64 = and i32 %63, 255
%65 = load i32*, i32** %21
%66 = getelementptr inbounds i32, i32* %65, i64 5
store i32 %64, i32* %66
%67 = load i32*, i32** %21
%68 = getelementptr inbounds i32, i32* %67, i64 6
store i32 255, i32* %68
%69 = load i32*, i32** %21
%70 = getelementptr inbounds i32, i32* %69, i64 7
store i32 240, i32* %70
%71 = load i32, i32* %15
%72 = load i32*, i32** %21
%73 = getelementptr inbounds i32, i32* %72, i64 8
store i32 %71, i32* %73
%74 = load i32, i32* %16
%75 = ashr i32 %74, 20
%76 = and i32 %75, 255
%77 = load i32*, i32** %21
%78 = getelementptr inbounds i32, i32* %77, i64 9
store i32 %76, i32* %78
%79 = load i32, i32* %16
%80 = ashr i32 %79, 12
%81 = and i32 %80, 255
%82 = load i32*, i32** %21
%83 = getelementptr inbounds i32, i32* %82, i64 10
store i32 %81, i32* %83
%84 = load i32, i32* %16
%85 = ashr i32 %84, 4
%86 = and i32 %85, 255
%87 = load i32*, i32** %21
%88 = getelementptr inbounds i32, i32* %87, i64 11
store i32 %86, i32* %88
%89 = load i32, i32* %16
%90 = and i32 %89, 15
%91 = shl i32 %90, 4
%92 = load i32*, i32** %21
%93 = getelementptr inbounds i32, i32* %92, i64 12
store i32 %91, i32* %93
%94 = load i32*, i32** %21
%95 = getelementptr inbounds i32, i32* %94, i64 12
%96 = load i32, i32* %95
%97 = or i32 %96, 0
store i32 %97, i32* %95
%98 = load i32, i32* %19
%99 = mul nsw i32 %98, 3
%100 = add nsw i32 2, %99
store i32 %100, i32* %23
store i32 13, i32* %24
%101 = load i32*, i32** %21
%102 = load i32, i32* %24
%103 = add nsw i32 %102, 0
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32, i32* %101, i64 %104
store i32 65, i32* %105
%106 = load i32, i32* %23
%107 = sub nsw i32 %106, 2
%108 = load i32*, i32** %21
%109 = load i32, i32* %24
%110 = add nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i32, i32* %108, i64 %111
store i32 %107, i32* %112
%113 = load i32, i32* %24
%114 = add nsw i32 %113, 2
store i32 %114, i32* %24
store i32 0, i32* %22
br label %115
115: ; preds = %150, %35
%116 = load i32, i32* %22
%117 = load i32, i32* %19
%118 = icmp slt i32 %116, %117
br i1 %118, label %119, label %153
119: ; preds = %115
%120 = load i32*, i32** %18
%121 = load i32, i32* %22
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i32, i32* %120, i64 %122
%124 = load i32, i32* %123
store i32 %124, i32* %25
%125 = load i32, i32* %25
%126 = and i32 %125, 16711680
%127 = lshr i32 %126, 16
%128 = load i32*, i32** %21
%129 = load i32, i32* %24
%130 = add nsw i32 %129, 0
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i32, i32* %128, i64 %131
store i32 %127, i32* %132
%133 = load i32, i32* %25
%134 = and i32 %133, 65280
%135 = lshr i32 %134, 8
%136 = load i32*, i32** %21
%137 = load i32, i32* %24
%138 = add nsw i32 %137, 1
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i32, i32* %136, i64 %139
store i32 %135, i32* %140
%141 = load i32, i32* %25
%142 = and i32 %141, 255
%143 = load i32*, i32** %21
%144 = load i32, i32* %24
%145 = add nsw i32 %144, 2
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds i32, i32* %143, i64 %146
store i32 %142, i32* %147
%148 = load i32, i32* %24
%149 = add nsw i32 %148, 3
store i32 %149, i32* %24
br label %150
150: ; preds = %119
%151 = load i32, i32* %22
%152 = add nsw i32 %151, 1
store i32 %152, i32* %22
br label %115
153: ; preds = %115
store i32 6, i32* %26
%154 = load i32*, i32** %21
%155 = load i32, i32* %24
%156 = add nsw i32 %155, 0
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i32, i32* %154, i64 %157
store i32 95, i32* %158
%159 = load i32, i32* %26
%160 = sub nsw i32 %159, 2
%161 = load i32*, i32** %21
%162 = load i32, i32* %24
%163 = add nsw i32 %162, 1
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i32, i32* %161, i64 %164
store i32 %160, i32* %165
%166 = load i32*, i32** %21
%167 = load i32, i32* %24
%168 = add nsw i32 %167, 2
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i32, i32* %166, i64 %169
store i32 0, i32* %170
%171 = load i32*, i32** %21
%172 = load i32, i32* %24
%173 = add nsw i32 %172, 3
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i32, i32* %171, i64 %174
store i32 0, i32* %175
%176 = load i32*, i32** %21
%177 = load i32, i32* %24
%178 = add nsw i32 %177, 4
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i32, i32* %176, i64 %179
store i32 0, i32* %180
%181 = load i32*, i32** %21
%182 = load i32, i32* %24
%183 = add nsw i32 %182, 5
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds i32, i32* %181, i64 %184
store i32 41, i32* %185
%186 = load i32, i32* %24
%187 = add nsw i32 %186, 6
store i32 %187, i32* %24
%188 = load i32, i32* %19
%189 = icmp ne i32 %188, 0
br i1 %189, label %190, label %193
190: ; preds = %153
%191 = load i32, i32* %19
%192 = icmp sgt i32 %191, 85
br i1 %192, label %193, label %194
193: ; preds = %190, %153
store i32 0, i32* %10
br label %265
194: ; preds = %190
%195 = load i32, i32* %19
%196 = mul nsw i32 %195, 4
%197 = add nsw i32 2, %196
store i32 %197, i32* %27
%198 = load i32*, i32** %21
%199 = load i32, i32* %24
%200 = add nsw i32 %199, 0
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds i32, i32* %198, i64 %201
store i32 131, i32* %202
%203 = load i32, i32* %27
%204 = sub nsw i32 %203, 2
%205 = load i32*, i32** %21
%206 = load i32, i32* %24
%207 = add nsw i32 %206, 1
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds i32, i32* %205, i64 %208
store i32 %204, i32* %209
%210 = load i32, i32* %24
%211 = add nsw i32 %210, 2
store i32 %211, i32* %24
store i32 0, i32* %22
br label %212
212: ; preds = %255, %194
%213 = load i32, i32* %22
%214 = load i32, i32* %19
%215 = icmp slt i32 %213, %214
br i1 %215, label %216, label %258
216: ; preds = %212
%217 = load i32*, i32** %17
%218 = load i32, i32* %22
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i32, i32* %217, i64 %219
%221 = load i32, i32* %220
store i32 %221, i32* %28
%222 = load i32, i32* %28
%223 = and i32 %222, -16777216
%224 = ashr i32 %223, 24
%225 = load i32*, i32** %21
%226 = load i32, i32* %24
%227 = add nsw i32 %226, 0
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds i32, i32* %225, i64 %228
store i32 %224, i32* %229
%230 = load i32, i32* %28
%231 = and i32 %230, 16711680
%232 = lshr i32 %231, 16
%233 = load i32*, i32** %21
%234 = load i32, i32* %24
%235 = add nsw i32 %234, 1
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds i32, i32* %233, i64 %236
store i32 %232, i32* %237
%238 = load i32, i32* %28
%239 = and i32 %238, 65280
%240 = lshr i32 %239, 8
%241 = load i32*, i32** %21
%242 = load i32, i32* %24
%243 = add nsw i32 %242, 2
%244 = sext i32 %243 to i64
%245 = getelementptr inbounds i32, i32* %241, i64 %244
store i32 %240, i32* %245
%246 = load i32, i32* %28
%247 = and i32 %246, 255
%248 = load i32*, i32** %21
%249 = load i32, i32* %24
%250 = add nsw i32 %249, 3
%251 = sext i32 %250 to i64
%252 = getelementptr inbounds i32, i32* %248, i64 %251
store i32 %247, i32* %252
%253 = load i32, i32* %24
%254 = add nsw i32 %253, 4
store i32 %254, i32* %24
br label %255
255: ; preds = %216
%256 = load i32, i32* %22
%257 = add nsw i32 %256, 1
store i32 %257, i32* %22
br label %212
258: ; preds = %212
%259 = load %struct.ts_nit*, %struct.ts_nit** %11
%260 = load i32, i32* %12
%261 = load i32, i32* %13
%262 = load i32*, i32** %21
%263 = load i32, i32* %20
%264 = call i32 @ts_nit_add_stream(%struct.ts_nit* %259, i32 %260, i32 %261, i32* %262, i32 %263)
store i32 %264, i32* %10
br label %265
265: ; preds = %258, %193, %34
%266 = load i32, i32* %10
ret i32 %266
}

LLVM IR (-O2):
%struct.ts_nit = type { i32 }
define i32 @ts_nit_add_stream_descriptors(%struct.ts_nit* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32* nocapture %6, i32* nocapture %7, i32 %8) {
%10 = icmp eq i32 %8, 0
%11 = icmp sgt i32 %8, 85
%12 = or i1 %10, %11
br i1 %12, label %114, label %13
13: ; preds = %9
%14 = shl nsw i32 %8, 2
%15 = add nsw i32 %14, 23
%16 = mul nsw i32 %8, 3
%17 = add nsw i32 %15, %16
%18 = tail call i32* @calloc(i32 1, i32 %17)
store i32 68, i32* %18
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 11, i32* %19
%20 = ashr i32 %3, 24
%21 = getelementptr inbounds i32, i32* %18, i64 2
store i32 %20, i32* %21
%22 = lshr i32 %3, 16
%23 = and i32 %22, 255
%24 = getelementptr inbounds i32, i32* %18, i64 3
store i32 %23, i32* %24
%25 = lshr i32 %3, 8
%26 = and i32 %25, 255
%27 = getelementptr inbounds i32, i32* %18, i64 4
store i32 %26, i32* %27
%28 = and i32 %3, 255
%29 = getelementptr inbounds i32, i32* %18, i64 5
store i32 %28, i32* %29
%30 = getelementptr inbounds i32, i32* %18, i64 6
store i32 255, i32* %30
%31 = getelementptr inbounds i32, i32* %18, i64 7
store i32 240, i32* %31
%32 = getelementptr inbounds i32, i32* %18, i64 8
store i32 %4, i32* %32
%33 = lshr i32 %5, 20
%34 = and i32 %33, 255
%35 = getelementptr inbounds i32, i32* %18, i64 9
store i32 %34, i32* %35
%36 = lshr i32 %5, 12
%37 = and i32 %36, 255
%38 = getelementptr inbounds i32, i32* %18, i64 10
store i32 %37, i32* %38
%39 = lshr i32 %5, 4
%40 = and i32 %39, 255
%41 = getelementptr inbounds i32, i32* %18, i64 11
store i32 %40, i32* %41
%42 = shl i32 %5, 4
%43 = and i32 %42, 240
%44 = getelementptr inbounds i32, i32* %18, i64 12
store i32 %43, i32* %44
%45 = getelementptr inbounds i32, i32* %18, i64 13
store i32 65, i32* %45
%46 = getelementptr inbounds i32, i32* %18, i64 14
store i32 %16, i32* %46
%47 = icmp sgt i32 %8, 0
br i1 %47, label %48, label %70
48: ; preds = %13
%49 = zext i32 %8 to i64
br label %50
50: ; preds = %48, %50
%51 = phi i64 [ 15, %48 ], [ %65, %50 ]
%52 = phi i64 [ 0, %48 ], [ %66, %50 ]
%53 = getelementptr inbounds i32, i32* %7, i64 %52
%54 = load i32, i32* %53
%55 = lshr i32 %54, 16
%56 = and i32 %55, 255
%57 = getelementptr inbounds i32, i32* %18, i64 %51
store i32 %56, i32* %57
%58 = lshr i32 %54, 8
%59 = and i32 %58, 255
%60 = add nuw nsw i64 %51, 1
%61 = getelementptr inbounds i32, i32* %18, i64 %60
store i32 %59, i32* %61
%62 = and i32 %54, 255
%63 = add nuw nsw i64 %51, 2
%64 = getelementptr inbounds i32, i32* %18, i64 %63
store i32 %62, i32* %64
%65 = add nuw nsw i64 %51, 3
%66 = add nuw nsw i64 %52, 1
%67 = icmp eq i64 %66, %49
br i1 %67, label %68, label %50
68: ; preds = %50
%69 = trunc i64 %65 to i32
br label %70
70: ; preds = %68, %13
%71 = phi i32 [ 15, %13 ], [ %69, %68 ]
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %18, i64 %72
%74 = bitcast i32* %73 to <4 x i32>*
store <4 x i32> <i32 95, i32 4, i32 0, i32 0>, <4 x i32>* %74
%75 = add nuw nsw i32 %71, 4
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %18, i64 %76
store i32 0, i32* %77
%78 = add nuw nsw i32 %71, 5
%79 = zext i32 %78 to i64
%80 = getelementptr inbounds i32, i32* %18, i64 %79
store i32 41, i32* %80
%81 = add nuw nsw i32 %71, 6
%82 = zext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %18, i64 %82
store i32 131, i32* %83
%84 = add nuw nsw i32 %71, 7
%85 = zext i32 %84 to i64
%86 = getelementptr inbounds i32, i32* %18, i64 %85
store i32 %14, i32* %86
br i1 %47, label %87, label %112
87: ; preds = %70
%88 = add i32 %71, 8
%89 = zext i32 %88 to i64
%90 = zext i32 %8 to i64
br label %91
91: ; preds = %87, %91
%92 = phi i64 [ %89, %87 ], [ %109, %91 ]
%93 = phi i64 [ 0, %87 ], [ %110, %91 ]
%94 = getelementptr inbounds i32, i32* %6, i64 %93
%95 = load i32, i32* %94
%96 = ashr i32 %95, 24
%97 = getelementptr inbounds i32, i32* %18, i64 %92
store i32 %96, i32* %97
%98 = lshr i32 %95, 16
%99 = and i32 %98, 255
%100 = add nuw nsw i64 %92, 1
%101 = getelementptr inbounds i32, i32* %18, i64 %100
store i32 %99, i32* %101
%102 = lshr i32 %95, 8
%103 = and i32 %102, 255
%104 = add nuw nsw i64 %92, 2
%105 = getelementptr inbounds i32, i32* %18, i64 %104
store i32 %103, i32* %105
%106 = and i32 %95, 255
%107 = add nuw nsw i64 %92, 3
%108 = getelementptr inbounds i32, i32* %18, i64 %107
store i32 %106, i32* %108
%109 = add nuw nsw i64 %92, 4
%110 = add nuw nsw i64 %93, 1
%111 = icmp eq i64 %110, %90
br i1 %111, label %112, label %91
112: ; preds = %91, %70
%113 = tail call i32 @ts_nit_add_stream(%struct.ts_nit* %0, i32 %1, i32 %2, i32* %18, i32 %17)
br label %114
114: ; preds = %9, %112
%115 = phi i32 [ %113, %112 ], [ 0, %9 ]
ret i32 %115
}