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

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/ *, int);
void extract_id_string(__u16 *idw, int words, char *dst) {
  char *e;
  int bytes = words * 2;
  memcpy(dst, idw, bytes);
  dst[bytes] = '\0';
  for (e = dst + bytes; --e != dst;) {
    if (*e && *e != ' ')
      break;
    *e = '\0';
  }
}


x86 assembly (clang, -O0):
<extract_id_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    -0x18(%rbp),%rax
je     119e <extract_id_string+0x8e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1192 <extract_id_string+0x82>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1192 <extract_id_string+0x82>
jmp    119e <extract_id_string+0x8e>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1157 <extract_id_string+0x47>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_id_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rax
movslq %esi,%r15
lea    (%r15,%r15,1),%rbx
mov    %rdx,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
call   1030 <memcpy@plt>
movb   $0x0,(%r14,%r15,2)
lea    (%r14,%r15,2),%rax
add    $0xffffffffffffffff,%rax
cmp    %r14,%rax
je     1162 <extract_id_string+0x52>
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
testb  $0xdf,(%r14,%rbx,1)
jne    1162 <extract_id_string+0x52>
movb   $0x0,(%r14,%rbx,1)
add    $0xffffffffffffffff,%rbx
jne    1150 <extract_id_string+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @extract_id_string(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* %5
%10 = mul nsw i32 %9, 2
store i32 %10, i32* %8
%11 = load i8*, i8** %6
%12 = load i32*, i32** %4
%13 = load i32, i32* %8
%14 = call i32 @memcpy(i8* %11, i32* %12, i32 %13)
%15 = load i8*, i8** %6
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 0, i8* %18
%19 = load i8*, i8** %6
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8* %22, i8** %7
br label %23
23: ; preds = %39, %3
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i32 -1
store i8* %25, i8** %7
%26 = load i8*, i8** %6
%27 = icmp ne i8* %25, %26
br i1 %27, label %28, label %41
28: ; preds = %23
%29 = load i8*, i8** %7
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %28
%34 = load i8*, i8** %7
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 32
br i1 %37, label %38, label %39
38: ; preds = %33
br label %41
39: ; preds = %33, %28
%40 = load i8*, i8** %7
store i8 0, i8* %40
br label %23
41: ; preds = %38, %23
ret void
}

LLVM IR (-O2):
define void @extract_id_string(i32* %0, i32 %1, i8* %2) {
%4 = shl nsw i32 %1, 1
%5 = tail call i32 @memcpy(i8* %2, i32* %0, i32 %4)
%6 = sext i32 %4 to i64
%7 = getelementptr inbounds i8, i8* %2, i64 %6
store i8 0, i8* %7
%8 = getelementptr inbounds i8, i8* %7, i64 -1
%9 = icmp eq i8* %8, %2
br i1 %9, label %16, label %10
10: ; preds = %3, %13
%11 = phi i8* [ %14, %13 ], [ %8, %3 ]
%12 = load i8, i8* %11
switch i8 %12, label %16 [
i8 0, label %13
i8 32, label %13
]
13: ; preds = %10, %10
store i8 0, i8* %11
%14 = getelementptr inbounds i8, i8* %11, i64 -1
%15 = icmp eq i8* %14, %2
br i1 %15, label %16, label %10
16: ; preds = %13, %10, %3
ret void
}