#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 */

/* Variables and functions */
int /*<<< orphan*/ fill_config_req(unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, unsigned short);
int fill_normal_config_req(unsigned char *buf, unsigned short type_a,
                           unsigned short type_b, unsigned short param_len,
                           unsigned char *param) {
  int body_len = 0x14 + param_len;
  fill_config_req(buf, body_len);
  buf[0x04] = 0x15;
  buf[0x05] = 0x00;
  buf += 6;
  buf[0x0c] = 0x15;
  buf[0x0d] = 0x00;
  buf[0x0e] = type_a >> 8;
  buf[0x0f] = type_a & 0xff;
  buf[0x10] = type_b >> 8;
  buf[0x11] = type_b & 0xff;
  buf[0x12] = param_len >> 8;
  buf[0x13] = param_len & 0xff;
  memcpy(buf + 0x14, param, param_len);
  return 6 + body_len;
}


x86 assembly (clang, -O0):
<fill_normal_config_req>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %dx,%cx
mov    %si,%dx
mov    %rdi,-0x8(%rbp)
mov    %dx,-0xa(%rbp)
mov    %cx,-0xc(%rbp)
mov    %ax,-0xe(%rbp)
mov    %r8,-0x18(%rbp)
movzwl -0xe(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <fill_config_req@plt>
mov    -0x8(%rbp),%rax
movb   $0x15,0x4(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x5(%rax)
mov    -0x8(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x15,0xc(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0xd(%rax)
movzwl -0xa(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xe(%rax)
movzwl -0xa(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0xf(%rax)
movzwl -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x10(%rax)
movzwl -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x11(%rax)
movzwl -0xe(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x12(%rax)
movzwl -0xe(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x13(%rax)
mov    -0x8(%rbp),%rdi
add    $0x14,%rdi
mov    -0x18(%rbp),%rsi
mov    -0xe(%rbp),%ax
movzwl %ax,%edx
call   1030 <memcpy@plt>
mov    -0x1c(%rbp),%eax
add    $0x6,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_normal_config_req>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
lea    0x14(%rbx),%esi
call   1040 <fill_config_req@plt>
movw   $0x15,0x4(%rbp)
movw   $0x15,0x12(%rbp)
mov    %r12d,%eax
mov    %ah,0x14(%rbp)
mov    %al,0x15(%rbp)
mov    %r15d,%eax
mov    %ah,0x16(%rbp)
mov    %al,0x17(%rbp)
mov    %bh,0x18(%rbp)
mov    %bl,0x19(%rbp)
add    $0x1a,%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <memcpy@plt>
add    $0x1a,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fill_normal_config_req(i8* %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %6
store i16 %1, i16* %7
store i16 %2, i16* %8
store i16 %3, i16* %9
store i8* %4, i8** %10
%12 = load i16, i16* %9
%13 = zext i16 %12 to i32
%14 = add nsw i32 20, %13
store i32 %14, i32* %11
%15 = load i8*, i8** %6
%16 = load i32, i32* %11
%17 = call i32 @fill_config_req(i8* %15, i32 %16)
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 4
store i8 21, i8* %19
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 5
store i8 0, i8* %21
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 6
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 12
store i8 21, i8* %25
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 13
store i8 0, i8* %27
%28 = load i16, i16* %7
%29 = zext i16 %28 to i32
%30 = ashr i32 %29, 8
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 14
store i8 %31, i8* %33
%34 = load i16, i16* %7
%35 = zext i16 %34 to i32
%36 = and i32 %35, 255
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i64 15
store i8 %37, i8* %39
%40 = load i16, i16* %8
%41 = zext i16 %40 to i32
%42 = ashr i32 %41, 8
%43 = trunc i32 %42 to i8
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 16
store i8 %43, i8* %45
%46 = load i16, i16* %8
%47 = zext i16 %46 to i32
%48 = and i32 %47, 255
%49 = trunc i32 %48 to i8
%50 = load i8*, i8** %6
%51 = getelementptr inbounds i8, i8* %50, i64 17
store i8 %49, i8* %51
%52 = load i16, i16* %9
%53 = zext i16 %52 to i32
%54 = ashr i32 %53, 8
%55 = trunc i32 %54 to i8
%56 = load i8*, i8** %6
%57 = getelementptr inbounds i8, i8* %56, i64 18
store i8 %55, i8* %57
%58 = load i16, i16* %9
%59 = zext i16 %58 to i32
%60 = and i32 %59, 255
%61 = trunc i32 %60 to i8
%62 = load i8*, i8** %6
%63 = getelementptr inbounds i8, i8* %62, i64 19
store i8 %61, i8* %63
%64 = load i8*, i8** %6
%65 = getelementptr inbounds i8, i8* %64, i64 20
%66 = load i8*, i8** %10
%67 = load i16, i16* %9
%68 = call i32 @memcpy(i8* %65, i8* %66, i16 zeroext %67)
%69 = load i32, i32* %11
%70 = add nsw i32 6, %69
ret i32 %70
}

LLVM IR (-O2):
define i32 @fill_normal_config_req(i8* %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3, i8* %4) {
%6 = zext i16 %3 to i32
%7 = add nuw nsw i32 %6, 20
%8 = tail call i32 @fill_config_req(i8* %0, i32 %7)
%9 = getelementptr inbounds i8, i8* %0, i64 4
store i8 21, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 5
store i8 0, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 18
store i8 21, i8* %11
%12 = getelementptr inbounds i8, i8* %0, i64 19
store i8 0, i8* %12
%13 = lshr i16 %1, 8
%14 = trunc i16 %13 to i8
%15 = getelementptr inbounds i8, i8* %0, i64 20
store i8 %14, i8* %15
%16 = trunc i16 %1 to i8
%17 = getelementptr inbounds i8, i8* %0, i64 21
store i8 %16, i8* %17
%18 = lshr i16 %2, 8
%19 = trunc i16 %18 to i8
%20 = getelementptr inbounds i8, i8* %0, i64 22
store i8 %19, i8* %20
%21 = trunc i16 %2 to i8
%22 = getelementptr inbounds i8, i8* %0, i64 23
store i8 %21, i8* %22
%23 = lshr i16 %3, 8
%24 = trunc i16 %23 to i8
%25 = getelementptr inbounds i8, i8* %0, i64 24
store i8 %24, i8* %25
%26 = trunc i16 %3 to i8
%27 = getelementptr inbounds i8, i8* %0, i64 25
store i8 %26, i8* %27
%28 = getelementptr inbounds i8, i8* %0, i64 26
%29 = tail call i32 @memcpy(i8* %28, i8* %4, i16 zeroext %3)
%30 = add nuw nsw i32 %6, 26
ret i32 %30
}