#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*/ strcpy(char *, char *);
int strlen(char const *);
char *strstr(char *, char const *);
char *strtok(char *, char *);
int getParameterValue(char *source, const char *Parameter, char *Value) {
  char *tmp;
  char *retString = NULL;
  char sourceStr[256];
  int iRet = 0;
  if (!Parameter || !source)
    return 0;
  strcpy(sourceStr, source);
  tmp = strstr(sourceStr, Parameter);
  if (tmp) {
    retString = strtok((tmp + strlen(Parameter) + 1), ";\n ");
    if (retString) {
      strcpy(Value, retString);
      iRet = 1;
    }
  }
  return iRet;
}


x86 assembly (clang, -O0):
<getParameterValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x134(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117f <getParameterValue+0x3f>
cmpq   $0x0,-0x10(%rbp)
jne    118b <getParameterValue+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    121e <getParameterValue+0xde>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1215 <getParameterValue+0xd5>
mov    -0x28(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x140(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
lea    0xe1b(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1210 <getParameterValue+0xd0>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x134(%rbp)
jmp    1215 <getParameterValue+0xd5>
mov    -0x134(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getParameterValue>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
xor    %r15d,%r15d
test   %rdi,%rdi
je     11b5 <getParameterValue+0x75>
mov    %rsi,%rbx
test   %rsi,%rsi
je     11b5 <getParameterValue+0x75>
mov    %rdx,%r14
mov    %rdi,%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     11b5 <getParameterValue+0x75>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rax,%rbp,1),%rdi
add    $0x1,%rdi
lea    0xe66(%rip),%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11b5 <getParameterValue+0x75>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c";\0A \00"
define i32 @getParameterValue(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [256 x i8]
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* null, i8** %9
store i32 0, i32* %11
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %14, %3
store i32 0, i32* %4
br label %44
18: ; preds = %14
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%20 = load i8*, i8** %5
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%23 = load i8*, i8** %6
%24 = call i8* @strstr(i8* %22, i8* %23)
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %42
27: ; preds = %18
%28 = load i8*, i8** %8
%29 = load i8*, i8** %6
%30 = call i32 @strlen(i8* %29)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i8* @strtok(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %34, i8** %9
%35 = load i8*, i8** %9
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %41
37: ; preds = %27
%38 = load i8*, i8** %7
%39 = load i8*, i8** %9
%40 = call i32 @strcpy(i8* %38, i8* %39)
store i32 1, i32* %11
br label %41
41: ; preds = %37, %27
br label %42
42: ; preds = %41, %18
%43 = load i32, i32* %11
store i32 %43, i32* %4
br label %44
44: ; preds = %42, %17
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
@.str = [4 x i8] c";\0A \00"
define i32 @getParameterValue(i8* %0, i8* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = icmp ne i8* %1, null
%7 = icmp ne i8* %0, null
%8 = and i1 %7, %6
br i1 %8, label %9, label %22
9: ; preds = %3
%10 = call i32 @strcpy(i8* %5, i8* %0)
%11 = call i8* @strstr(i8* %5, i8* %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %22, label %13
13: ; preds = %9
%14 = call i32 @strlen(i8* %1)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %11, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %13
%21 = call i32 @strcpy(i8* %2, i8* %18)
br label %22
22: ; preds = %9, %20, %13, %3
%23 = phi i32 [ 0, %3 ], [ 1, %20 ], [ 0, %13 ], [ 0, %9 ]
ret i32 %23
}