#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_cable_delivery_descriptor(struct ts_nit *nit, uint16_t ts_id,
                                         uint16_t org_net_id, uint32_t freq,
                                         uint8_t modulation,
                                         uint32_t symbol_rate) {
  int desc_size = 13;
  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;
  return ts_nit_add_stream(nit, ts_id, org_net_id, desc, desc_size);
}


x86 assembly (clang, -O0):
<ts_nit_add_cable_delivery_descriptor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movl   $0xd,-0x20(%rbp)
mov    -0x20(%rbp),%esi
mov    $0x1,%edi
call   1030 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x44,(%rax)
mov    -0x28(%rbp),%rax
movl   $0xb,0x4(%rax)
mov    -0x14(%rbp),%ecx
and    $0xff000000,%ecx
sar    $0x18,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x14(%rbp),%ecx
and    $0xff0000,%ecx
shr    $0x10,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x14(%rbp),%ecx
and    $0xff00,%ecx
shr    $0x8,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x14(%rbp),%ecx
and    $0xff,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x28(%rbp),%rax
movl   $0xff,0x18(%rax)
mov    -0x28(%rbp),%rax
movl   $0xf0,0x1c(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x14,%ecx
and    $0xff,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0xc,%ecx
and    $0xff,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x4,%ecx
and    $0xff,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0x1c(%rbp),%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x28(%rbp),%rax
mov    0x30(%rax),%ecx
or     $0x0,%ecx
mov    %ecx,0x30(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8d
call   1040 <ts_nit_add_stream@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_nit_add_cable_delivery_descriptor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebp
mov    %r8d,%r13d
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
mov    $0x1,%edi
mov    $0xd,%esi
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    %r13d,0x20(%rax)
mov    %ebp,%ecx
shr    $0x14,%ecx
movzbl %cl,%ecx
mov    %ecx,0x24(%rax)
mov    %ebp,%ecx
shr    $0xc,%ecx
movzbl %cl,%ecx
mov    %ecx,0x28(%rax)
mov    %ebp,%ecx
shr    $0x4,%ecx
movzbl %cl,%ecx
mov    %ecx,0x2c(%rax)
shl    $0x4,%ebp
movzbl %bpl,%ecx
mov    %ecx,0x30(%rax)
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %rax,%rcx
mov    $0xd,%r8d
add    $0x8,%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_cable_delivery_descriptor(%struct.ts_nit* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca %struct.ts_nit*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
store %struct.ts_nit* %0, %struct.ts_nit** %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
store i32 13, i32* %13
%15 = load i32, i32* %13
%16 = call i32* @calloc(i32 1, i32 %15)
store i32* %16, i32** %14
%17 = load i32*, i32** %14
%18 = getelementptr inbounds i32, i32* %17, i64 0
store i32 68, i32* %18
%19 = load i32*, i32** %14
%20 = getelementptr inbounds i32, i32* %19, i64 1
store i32 11, i32* %20
%21 = load i32, i32* %10
%22 = and i32 %21, -16777216
%23 = ashr i32 %22, 24
%24 = load i32*, i32** %14
%25 = getelementptr inbounds i32, i32* %24, i64 2
store i32 %23, i32* %25
%26 = load i32, i32* %10
%27 = and i32 %26, 16711680
%28 = lshr i32 %27, 16
%29 = load i32*, i32** %14
%30 = getelementptr inbounds i32, i32* %29, i64 3
store i32 %28, i32* %30
%31 = load i32, i32* %10
%32 = and i32 %31, 65280
%33 = lshr i32 %32, 8
%34 = load i32*, i32** %14
%35 = getelementptr inbounds i32, i32* %34, i64 4
store i32 %33, i32* %35
%36 = load i32, i32* %10
%37 = and i32 %36, 255
%38 = load i32*, i32** %14
%39 = getelementptr inbounds i32, i32* %38, i64 5
store i32 %37, i32* %39
%40 = load i32*, i32** %14
%41 = getelementptr inbounds i32, i32* %40, i64 6
store i32 255, i32* %41
%42 = load i32*, i32** %14
%43 = getelementptr inbounds i32, i32* %42, i64 7
store i32 240, i32* %43
%44 = load i32, i32* %11
%45 = load i32*, i32** %14
%46 = getelementptr inbounds i32, i32* %45, i64 8
store i32 %44, i32* %46
%47 = load i32, i32* %12
%48 = ashr i32 %47, 20
%49 = and i32 %48, 255
%50 = load i32*, i32** %14
%51 = getelementptr inbounds i32, i32* %50, i64 9
store i32 %49, i32* %51
%52 = load i32, i32* %12
%53 = ashr i32 %52, 12
%54 = and i32 %53, 255
%55 = load i32*, i32** %14
%56 = getelementptr inbounds i32, i32* %55, i64 10
store i32 %54, i32* %56
%57 = load i32, i32* %12
%58 = ashr i32 %57, 4
%59 = and i32 %58, 255
%60 = load i32*, i32** %14
%61 = getelementptr inbounds i32, i32* %60, i64 11
store i32 %59, i32* %61
%62 = load i32, i32* %12
%63 = and i32 %62, 15
%64 = shl i32 %63, 4
%65 = load i32*, i32** %14
%66 = getelementptr inbounds i32, i32* %65, i64 12
store i32 %64, i32* %66
%67 = load i32*, i32** %14
%68 = getelementptr inbounds i32, i32* %67, i64 12
%69 = load i32, i32* %68
%70 = or i32 %69, 0
store i32 %70, i32* %68
%71 = load %struct.ts_nit*, %struct.ts_nit** %7
%72 = load i32, i32* %8
%73 = load i32, i32* %9
%74 = load i32*, i32** %14
%75 = load i32, i32* %13
%76 = call i32 @ts_nit_add_stream(%struct.ts_nit* %71, i32 %72, i32 %73, i32* %74, i32 %75)
ret i32 %76
}

LLVM IR (-O2):
%struct.ts_nit = type { i32 }
define i32 @ts_nit_add_cable_delivery_descriptor(%struct.ts_nit* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32* @calloc(i32 1, i32 13)
store i32 68, i32* %7
%8 = getelementptr inbounds i32, i32* %7, i64 1
store i32 11, i32* %8
%9 = ashr i32 %3, 24
%10 = getelementptr inbounds i32, i32* %7, i64 2
store i32 %9, i32* %10
%11 = lshr i32 %3, 16
%12 = and i32 %11, 255
%13 = getelementptr inbounds i32, i32* %7, i64 3
store i32 %12, i32* %13
%14 = lshr i32 %3, 8
%15 = and i32 %14, 255
%16 = getelementptr inbounds i32, i32* %7, i64 4
store i32 %15, i32* %16
%17 = and i32 %3, 255
%18 = getelementptr inbounds i32, i32* %7, i64 5
store i32 %17, i32* %18
%19 = getelementptr inbounds i32, i32* %7, i64 6
store i32 255, i32* %19
%20 = getelementptr inbounds i32, i32* %7, i64 7
store i32 240, i32* %20
%21 = getelementptr inbounds i32, i32* %7, i64 8
store i32 %4, i32* %21
%22 = lshr i32 %5, 20
%23 = and i32 %22, 255
%24 = getelementptr inbounds i32, i32* %7, i64 9
store i32 %23, i32* %24
%25 = lshr i32 %5, 12
%26 = and i32 %25, 255
%27 = getelementptr inbounds i32, i32* %7, i64 10
store i32 %26, i32* %27
%28 = lshr i32 %5, 4
%29 = and i32 %28, 255
%30 = getelementptr inbounds i32, i32* %7, i64 11
store i32 %29, i32* %30
%31 = shl i32 %5, 4
%32 = and i32 %31, 240
%33 = getelementptr inbounds i32, i32* %7, i64 12
store i32 %32, i32* %33
%34 = tail call i32 @ts_nit_add_stream(%struct.ts_nit* %0, i32 %1, i32 %2, i32* %7, i32 13)
ret i32 %34
}