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

/* Variables and functions */
int fill_normal_config_req(unsigned char *, int, int, int, unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, char *, short);
int strlen(char *);
int fill_auth_set_cmd(unsigned char *buf, char *netid) {
  short netid_len = strlen(netid) + 1;
  unsigned char param[netid_len + 4];
  param[0] = 0x0;
  param[1] = 0x10;
  param[2] = netid_len >> 8;
  param[3] = netid_len & 0xff;
  memcpy(param + 4, netid, netid_len);
  return fill_normal_config_req(buf, 0x20, 0x20, sizeof(param), param);
}


x86 assembly (clang, -O0):
<fill_auth_set_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %ax,-0x12(%rbp)
movswl -0x12(%rbp),%eax
add    $0x4,%eax
mov    %rax,-0x30(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
movb   $0x0,(%rdi)
movb   $0x10,0x1(%rdi)
movswl -0x12(%rbp),%eax
sar    $0x8,%eax
mov    %al,0x2(%rdi)
movswl -0x12(%rbp),%eax
and    $0xff,%eax
mov    %al,0x3(%rdi)
add    $0x4,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x12(%rbp),%ax
movswl %ax,%edx
call   1050 <memcpy@plt>
mov    -0x38(%rbp),%r8
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    %eax,%ecx
mov    $0x20,%edx
mov    %edx,%esi
call   1030 <fill_normal_config_req@plt>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_auth_set_cmd>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
movswl %ax,%edx
lea    0x4(%rdx),%r12d
mov    %rsp,%rcx
lea    0xf(%r12),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rcx,%rbx
sub    %rsi,%rbx
mov    %rbx,%rsp
movw   $0x1000,(%rbx)
neg    %rsi
mov    %ah,0x2(%rcx,%rsi,1)
mov    %al,0x3(%rbx)
lea    0x4(%rbx),%rdi
mov    %r15,%rsi
call   1050 <memcpy@plt>
mov    %r14,%rdi
mov    $0x20,%esi
mov    $0x20,%edx
mov    %r12d,%ecx
mov    %rbx,%r8
call   1030 <fill_normal_config_req@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fill_auth_set_cmd(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 1
%11 = trunc i32 %10 to i16
store i16 %11, i16* %5
%12 = load i16, i16* %5
%13 = sext i16 %12 to i32
%14 = add nsw i32 %13, 4
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %6
%17 = alloca i8, i64 %15
store i64 %15, i64* %7
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 0, i8* %18
%19 = getelementptr inbounds i8, i8* %17, i64 1
store i8 16, i8* %19
%20 = load i16, i16* %5
%21 = sext i16 %20 to i32
%22 = ashr i32 %21, 8
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds i8, i8* %17, i64 2
store i8 %23, i8* %24
%25 = load i16, i16* %5
%26 = sext i16 %25 to i32
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = getelementptr inbounds i8, i8* %17, i64 3
store i8 %28, i8* %29
%30 = getelementptr inbounds i8, i8* %17, i64 4
%31 = load i8*, i8** %4
%32 = load i16, i16* %5
%33 = call i32 @memcpy(i8* %30, i8* %31, i16 signext %32)
%34 = load i8*, i8** %3
%35 = trunc i64 %15 to i32
%36 = call i32 @fill_normal_config_req(i8* %34, i32 32, i32 32, i32 %35, i8* %17)
%37 = load i8*, i8** %6
ret i32 %36
}

LLVM IR (-O2):
define i32 @fill_auth_set_cmd(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = trunc i32 %3 to i16
%5 = add i16 %4, 1
%6 = sext i16 %5 to i32
%7 = add nsw i32 %6, 4
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
store i8 0, i8* %9
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8 16, i8* %10
%11 = lshr i16 %5, 8
%12 = trunc i16 %11 to i8
%13 = getelementptr inbounds i8, i8* %9, i64 2
store i8 %12, i8* %13
%14 = trunc i16 %5 to i8
%15 = getelementptr inbounds i8, i8* %9, i64 3
store i8 %14, i8* %15
%16 = getelementptr inbounds i8, i8* %9, i64 4
%17 = call i32 @memcpy(i8* %16, i8* %1, i16 signext %5)
%18 = call i32 @fill_normal_config_req(i8* %0, i32 32, i32 32, i32 %7, i8* %9)
ret i32 %18
}