#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*/ uint32_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ ntohl(int);
scalar_t__ ntohs(scalar_t__);
int /*<<< orphan*/ stun_init_buffer_str(unsigned char *, size_t *);
int /*<<< orphan*/ stun_tid_generate_in_message_str(unsigned char *,
                                                    int /*<<< orphan*/ *);
void stun_init_command_str(uint16_t message_type, unsigned char *buf,
                           size_t *len) {
  stun_init_buffer_str(buf, len);
  message_type &= (uint16_t)(0x3FFF);
  ((uint16_t *)buf)[0] = ntohs(message_type);
  ((uint16_t *)buf)[1] = 0;
  ((uint32_t *)buf)[1] = ntohl((0x2112A442));
  stun_tid_generate_in_message_str(buf, NULL);
}


x86 assembly (clang, -O0):
<stun_init_command_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <stun_init_buffer_str@plt>
mov    -0x8(%rbp),%rax
and    $0x3fff,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <ntohs@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    $0x2112a442,%edi
call   1060 <ntohl@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <stun_tid_generate_in_message_str@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stun_init_command_str>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1030 <stun_init_buffer_str@plt>
and    $0x3fff,%r14d
mov    %r14,%rdi
call   1050 <ntohs@plt>
mov    %rax,(%rbx)
movq   $0x0,0x8(%rbx)
mov    $0x2112a442,%edi
call   1060 <ntohl@plt>
mov    %eax,0x4(%rbx)
mov    %rbx,%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <stun_tid_generate_in_message_str@plt>

LLVM IR (-O0):
define void @stun_init_command_str(i64 %0, i8* %1, i64* %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64*
store i64 %0, i64* %4
store i8* %1, i8** %5
store i64* %2, i64** %6
%7 = load i8*, i8** %5
%8 = load i64*, i64** %6
%9 = call i32 @stun_init_buffer_str(i8* %7, i64* %8)
%10 = load i64, i64* %4
%11 = and i64 %10, 16383
store i64 %11, i64* %4
%12 = load i64, i64* %4
%13 = call i64 @ntohs(i64 %12)
%14 = load i8*, i8** %5
%15 = bitcast i8* %14 to i64*
%16 = getelementptr inbounds i64, i64* %15, i64 0
store i64 %13, i64* %16
%17 = load i8*, i8** %5
%18 = bitcast i8* %17 to i64*
%19 = getelementptr inbounds i64, i64* %18, i64 1
store i64 0, i64* %19
%20 = call i32 @ntohl(i32 554869826)
%21 = load i8*, i8** %5
%22 = bitcast i8* %21 to i32*
%23 = getelementptr inbounds i32, i32* %22, i64 1
store i32 %20, i32* %23
%24 = load i8*, i8** %5
%25 = call i32 @stun_tid_generate_in_message_str(i8* %24, i32* null)
ret void
}

LLVM IR (-O2):
define void @stun_init_command_str(i64 %0, i8* %1, i64* %2) {
%4 = tail call i32 @stun_init_buffer_str(i8* %1, i64* %2)
%5 = and i64 %0, 16383
%6 = tail call i64 @ntohs(i64 %5)
%7 = bitcast i8* %1 to i64*
store i64 %6, i64* %7
%8 = getelementptr inbounds i8, i8* %1, i64 8
%9 = bitcast i8* %8 to i64*
store i64 0, i64* %9
%10 = tail call i32 @ntohl(i32 554869826)
%11 = getelementptr inbounds i8, i8* %1, i64 4
%12 = bitcast i8* %11 to i32*
store i32 %10, i32* %12
%13 = tail call i32 @stun_tid_generate_in_message_str(i8* %1, i32* null)
ret void
}