#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 */
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok_r(int /*<<< orphan*/ *, char *, char **);
int getParamValueStr(char *pcmdStr, char *pParam, char *paramValue,
                     int paramValLen) {
  char *str;
  if (strcasecmp(pcmdStr, pParam) == 0) {
    str = strtok_r(NULL, ",", &pcmdStr);
    strncpy(paramValue, str, (paramValLen - 1));
    paramValue[paramValLen] = 0;
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<getParamValueStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11a1 <getParamValueStr+0x71>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe97(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
call   1040 <strncpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x4(%rbp)
jmp    11a8 <getParamValueStr+0x78>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getParamValueStr>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rdi,0x8(%rsp)
call   1030 <strcasecmp@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    117f <getParamValueStr+0x4f>
lea    0xea6(%rip),%rsi
xor    %ebx,%ebx
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1050 <strtok_r@plt>
lea    -0x1(%r14),%edx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <strncpy@plt>
movslq %r14d,%rax
movb   $0x0,(%r15,%rax,1)
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i32 @getParamValueStr(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = call i64 @strcasecmp(i8* %11, i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %4
%16 = call i8* @strtok_r(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6)
store i8* %16, i8** %10
%17 = load i8*, i8** %8
%18 = load i8*, i8** %10
%19 = load i32, i32* %9
%20 = sub nsw i32 %19, 1
%21 = call i32 @strncpy(i8* %17, i8* %18, i32 %20)
%22 = load i8*, i8** %8
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 0, i8* %25
store i32 0, i32* %5
br label %27
26: ; preds = %4
store i32 -1, i32* %5
br label %27
27: ; preds = %26, %15
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i32 @getParamValueStr(i8* %0, i8* nocapture %1, i8* %2, i32 %3) {
%5 = alloca i8*
store i8* %0, i8** %5
%6 = tail call i64 @strcasecmp(i8* %0, i8* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = call i8* @strtok_r(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5)
%10 = add nsw i32 %3, -1
%11 = call i32 @strncpy(i8* %2, i8* %9, i32 %10)
%12 = sext i32 %3 to i64
%13 = getelementptr inbounds i8, i8* %2, i64 %12
store i8 0, i8* %13
br label %14
14: ; preds = %4, %8
%15 = phi i32 [ 0, %8 ], [ -1, %4 ]
ret i32 %15
}