#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*/ sTemp;
typedef int /*<<< orphan*/ sRestStr;
typedef int /*<<< orphan*/ sAdcVoltage1Unit;

/* Variables and functions */
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(char *, char *);
unsigned int strcspn(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, unsigned int);
scalar_t__ strstr(char *, char *);
int FetchAdcValuesArray(char sResponseMesg[], char *sAdcValuesArray[]) {
  unsigned int uiPosOfDollar = strcspn(sResponseMesg, "$"),
               uiPosOfSigh = strcspn(sResponseMesg, "!"), uiPosOfColon = 0;
  char sTargetResponseStr[512] = {0}, sRestStr[512] = {0},
       sAdcVoltage1Unit[64] = {0}, sTemp[512] = {0};
  int iCnt = 0;
  if ((uiPosOfDollar != 0) || (uiPosOfSigh != (strlen(sResponseMesg) - 1)))
    return -1;
  strncpy(sTargetResponseStr, sResponseMesg + 1, strlen(sResponseMesg) - 2);
  strcpy(sRestStr, sTargetResponseStr);
  do {
    uiPosOfColon = strcspn(sRestStr, ";");
    strncpy(sAdcVoltage1Unit, sRestStr, uiPosOfColon);
    sAdcValuesArray[iCnt] = malloc(strlen(sAdcVoltage1Unit) + 1);
    strcpy(sAdcValuesArray[iCnt], sAdcVoltage1Unit);
    iCnt++;
    memset(sAdcVoltage1Unit, 0, sizeof(sAdcVoltage1Unit));
    strncpy(sTemp, sRestStr + uiPosOfColon + 1,
            strlen(sRestStr) - uiPosOfColon - 1);
    memset(sRestStr, 0, sizeof(sRestStr));
    strcpy(sRestStr, sTemp);
    memset(sTemp, 0, sizeof(sTemp));
  } while (strstr(sRestStr, ";"));
  sAdcValuesArray[iCnt] = malloc(strlen(sRestStr) + 1);
  strcpy(sAdcValuesArray[iCnt], sRestStr);
  return 0;
}


x86 assembly (clang, -O0):
<FetchAdcValuesArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6a0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1070 <strcspn@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1070 <strcspn@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x230(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x470(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0x670(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
movl   $0x0,-0x674(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1235 <FetchAdcValuesArray+0xc5>
mov    -0x20(%rbp),%eax
mov    %eax,-0x678(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x678(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1241 <FetchAdcValuesArray+0xd1>
movl   $0xffffffff,-0x4(%rbp)
jmp    1410 <FetchAdcValuesArray+0x2a0>
lea    -0x230(%rbp),%rax
mov    %rax,-0x688(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x680(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x688(%rbp),%rdi
mov    -0x680(%rbp),%rsi
mov    %eax,%edx
sub    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x430(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x430(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1070 <strcspn@plt>
mov    %eax,-0x24(%rbp)
lea    -0x470(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0x470(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x674(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x674(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x470(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x674(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x674(%rbp)
lea    -0x470(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
lea    -0x670(%rbp),%rax
mov    %rax,-0x698(%rbp)
lea    -0x430(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x690(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x698(%rbp),%rdi
mov    -0x690(%rbp),%rsi
mov    %eax,%edx
sub    -0x24(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x430(%rbp),%rdi
lea    -0x670(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x670(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
lea    -0x430(%rbp),%rdi
lea    0xc4d(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
jne    1292 <FetchAdcValuesArray+0x122>
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x674(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x674(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x430(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x6a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FetchAdcValuesArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x648,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe72(%rip),%rsi
call   1070 <strcspn@plt>
mov    %eax,%r12d
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcspn@plt>
mov    %eax,%r15d
lea    0x440(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x40(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x240(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    $0xffffffff,%ebp
test   %r12d,%r12d
jne    133e <FetchAdcValuesArray+0x1ce>
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    $0xffffffff,%eax
cmp    %eax,%r15d
jne    133e <FetchAdcValuesArray+0x1ce>
lea    0x1(%rbx),%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    -0x2(%rax),%edx
lea    0x440(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
lea    0x40(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
xor    %r15d,%r15d
xchg   %ax,%ax
mov    %r13,%rdi
lea    0xdaa(%rip),%rsi
call   1070 <strcspn@plt>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,(%r14,%r15,8)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r15
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
mov    %ebp,%eax
mov    %r14,%rbx
lea    (%rsp,%rax,1),%r14
add    $0x41,%r14
mov    %r13,%rdi
call   1050 <strlen@plt>
not    %ebp
add    %eax,%ebp
lea    0x240(%rsp),%r12
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%r14
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
mov    %r13,%rdi
lea    0xcfd(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
jne    1250 <FetchAdcValuesArray+0xe0>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %r15d,%ecx
mov    %rax,(%r14,%rcx,8)
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x648,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"$\00"
@.str.1 = [2 x i8] c"!\00"
@.str.2 = [2 x i8] c";\00"
define i32 @FetchAdcValuesArray(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [512 x i8]
%10 = alloca [512 x i8]
%11 = alloca [64 x i8]
%12 = alloca [512 x i8]
%13 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
%14 = load i8*, i8** %4
%15 = call i32 @strcspn(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
%16 = load i8*, i8** %4
%17 = call i32 @strcspn(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 %17, i32* %7
store i32 0, i32* %8
%18 = bitcast [512 x i8]* %9 to i8*
%19 = bitcast [512 x i8]* %10 to i8*
%20 = bitcast [64 x i8]* %11 to i8*
%21 = bitcast [512 x i8]* %12 to i8*
store i32 0, i32* %13
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %2
%25 = load i32, i32* %7
%26 = load i8*, i8** %4
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 1
%29 = icmp ne i32 %25, %28
br i1 %29, label %30, label %31
30: ; preds = %24, %2
store i32 -1, i32* %3
br label %107
31: ; preds = %24
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8*, i8** %4
%36 = call i32 @strlen(i8* %35)
%37 = sub nsw i32 %36, 2
%38 = call i32 @strncpy(i8* %32, i8* %34, i32 %37)
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%41 = call i32 @strcpy(i8* %39, i8* %40)
br label %42
42: ; preds = %87, %31
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%44 = call i32 @strcspn(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 %44, i32* %8
%45 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%47 = load i32, i32* %8
%48 = call i32 @strncpy(i8* %45, i8* %46, i32 %47)
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = add nsw i32 %50, 1
%52 = call i8* @malloc(i32 %51)
%53 = load i8**, i8*** %5
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
store i8* %52, i8** %56
%57 = load i8**, i8*** %5
%58 = load i32, i32* %13
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%63 = call i32 @strcpy(i8* %61, i8* %62)
%64 = load i32, i32* %13
%65 = add nsw i32 %64, 1
store i32 %65, i32* %13
%66 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%67 = call i32 @memset(i8* %66, i32 0, i32 64)
%68 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%69 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%70 = load i32, i32* %8
%71 = zext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = getelementptr inbounds i8, i8* %72, i64 1
%74 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%75 = call i32 @strlen(i8* %74)
%76 = load i32, i32* %8
%77 = sub i32 %75, %76
%78 = sub i32 %77, 1
%79 = call i32 @strncpy(i8* %68, i8* %73, i32 %78)
%80 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%81 = call i32 @memset(i8* %80, i32 0, i32 512)
%82 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%83 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%84 = call i32 @strcpy(i8* %82, i8* %83)
%85 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%86 = call i32 @memset(i8* %85, i32 0, i32 512)
br label %87
87: ; preds = %42
%88 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%89 = call i64 @strstr(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%90 = icmp ne i64 %89, 0
br i1 %90, label %42, label %91
91: ; preds = %87
%92 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%93 = call i32 @strlen(i8* %92)
%94 = add nsw i32 %93, 1
%95 = call i8* @malloc(i32 %94)
%96 = load i8**, i8*** %5
%97 = load i32, i32* %13
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8*, i8** %96, i64 %98
store i8* %95, i8** %99
%100 = load i8**, i8*** %5
%101 = load i32, i32* %13
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %100, i64 %102
%104 = load i8*, i8** %103
%105 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%106 = call i32 @strcpy(i8* %104, i8* %105)
store i32 0, i32* %3
br label %107
107: ; preds = %91, %30
%108 = load i32, i32* %3
ret i32 %108
}

LLVM IR (-O2):
@.str = [2 x i8] c"$\00"
@.str.1 = [2 x i8] c"!\00"
@.str.2 = [2 x i8] c";\00"
define i32 @FetchAdcValuesArray(i8* %0, i8** nocapture writeonly %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [64 x i8]
%6 = alloca [512 x i8]
%7 = tail call i32 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%13 = icmp eq i32 %7, 0
br i1 %13, label %14, label %54
14: ; preds = %2
%15 = tail call i32 @strlen(i8* %0)
%16 = add nsw i32 %15, -1
%17 = icmp eq i32 %8, %16
br i1 %17, label %18, label %54
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %0, i64 1
%20 = tail call i32 @strlen(i8* %0)
%21 = add nsw i32 %20, -2
%22 = call i32 @strncpy(i8* %9, i8* %19, i32 %21)
%23 = call i32 @strcpy(i8* %10, i8* %9)
br label %24
24: ; preds = %24, %18
%25 = phi i64 [ %33, %24 ], [ 0, %18 ]
%26 = call i32 @strcspn(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @strncpy(i8* %11, i8* %10, i32 %26)
%28 = call i32 @strlen(i8* %11)
%29 = add nsw i32 %28, 1
%30 = call i8* @malloc(i32 %29)
%31 = getelementptr inbounds i8*, i8** %1, i64 %25
store i8* %30, i8** %31
%32 = call i32 @strcpy(i8* %30, i8* %11)
%33 = add nuw i64 %25, 1
%34 = call i32 @memset(i8* %11, i32 0, i32 64)
%35 = zext i32 %26 to i64
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %35
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = call i32 @strlen(i8* %10)
%39 = xor i32 %26, -1
%40 = add i32 %38, %39
%41 = call i32 @strncpy(i8* %12, i8* %37, i32 %40)
%42 = call i32 @memset(i8* %10, i32 0, i32 512)
%43 = call i32 @strcpy(i8* %10, i8* %12)
%44 = call i32 @memset(i8* %12, i32 0, i32 512)
%45 = call i64 @strstr(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %24
47: ; preds = %24
%48 = call i32 @strlen(i8* %10)
%49 = add nsw i32 %48, 1
%50 = call i8* @malloc(i32 %49)
%51 = and i64 %33, 4294967295
%52 = getelementptr inbounds i8*, i8** %1, i64 %51
store i8* %50, i8** %52
%53 = call i32 @strcpy(i8* %50, i8* %10)
br label %54
54: ; preds = %2, %14, %47
%55 = phi i32 [ 0, %47 ], [ -1, %14 ], [ -1, %2 ]
ret i32 %55
}