#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 */
double atof(char *);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
char *strstr(char *, char *);
int RetrieveAdcVoltageValueFrom1unitOfAdcResponse(char s1unitOfAdcResponse[],
                                                  double *dVoltValue,
                                                  char *sError) {
  int iResult = 0;
  char sVoltageValue[64] = {0}, *sTemp = NULL;
  double dVoltage = 0.00f;
  sTemp = strstr(s1unitOfAdcResponse, "VOLT ");
  if (!sTemp) {
    sprintf(sError, "%s", "ADC value not found.");
    return -10;
  }
  strncpy(sVoltageValue, sTemp + 5, strlen(sTemp) - 5);
  dVoltage = atof(sVoltageValue);
  memcpy(dVoltValue, &dVoltage, sizeof(double));
  return iResult;
}


x86 assembly (clang, -O0):
<RetrieveAdcVoltageValueFrom1unitOfAdcResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1060 <memset@plt>
movq   $0x0,-0x78(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1090 <strstr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    11f0 <RetrieveAdcVoltageValueFrom1unitOfAdcResponse+0x80>
mov    -0x20(%rbp),%rdi
lea    0xe2e(%rip),%rsi
lea    0xe2a(%rip),%rdx
call   1080 <sprintf@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    1253 <RetrieveAdcVoltageValueFrom1unitOfAdcResponse+0xe3>
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x78(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x88(%rbp)
mov    -0x78(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    %rax,%rdx
sub    $0x5,%rdx
call   1030 <strncpy@plt>
lea    -0x70(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x80(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RetrieveAdcVoltageValueFrom1unitOfAdcResponse>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe83(%rip),%rsi
call   1070 <strstr@plt>
test   %rax,%rax
je     11ce <RetrieveAdcVoltageValueFrom1unitOfAdcResponse+0x7e>
mov    %rax,%rbx
add    $0x5,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    -0x5(%rax),%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
mov    %r15,%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
mov    $0x8,%edx
call   1060 <memcpy@plt>
xor    %eax,%eax
jmp    11eb <RetrieveAdcVoltageValueFrom1unitOfAdcResponse+0x9b>
movups 0xe31(%rip),%xmm0
movups %xmm0,(%rbx)
movabs $0x2e646e756f6620,%rax
mov    %rax,0xd(%rbx)
mov    $0xfffffff6,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"VOLT \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"ADC value not found.\00"
define i32 @RetrieveAdcVoltageValueFrom1unitOfAdcResponse(i8* %0, double* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [64 x i8]
%10 = alloca i8*
%11 = alloca double
store i8* %0, i8** %5
store double* %1, double** %6
store i8* %2, i8** %7
store i32 0, i32* %8
%12 = bitcast [64 x i8]* %9 to i8*
store i8* null, i8** %10
store double 0.000000e+00, double* %11
%13 = load i8*, i8** %5
%14 = call i8* @strstr(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %10
%15 = load i8*, i8** %10
%16 = icmp ne i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %3
%18 = load i8*, i8** %7
%19 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 -10, i32* %4
br label %33
20: ; preds = %3
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%22 = load i8*, i8** %10
%23 = getelementptr inbounds i8, i8* %22, i64 5
%24 = load i8*, i8** %10
%25 = call i64 @strlen(i8* %24)
%26 = sub nsw i64 %25, 5
%27 = call i32 @strncpy(i8* %21, i8* %23, i64 %26)
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%29 = call double @atof(i8* %28)
store double %29, double* %11
%30 = load double*, double** %6
%31 = call i32 @memcpy(double* %30, double* %11, i32 8)
%32 = load i32, i32* %8
store i32 %32, i32* %4
br label %33
33: ; preds = %20, %17
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@.str = [6 x i8] c"VOLT \00"
@.str.2 = [21 x i8] c"ADC value not found.\00"
define i32 @RetrieveAdcVoltageValueFrom1unitOfAdcResponse(i8* %0, double* %1, i8* nocapture writeonly %2) {
%4 = alloca [64 x i8]
%5 = alloca double
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%7 = bitcast double* %5 to i8*
%8 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %3
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(21) %2, i8* align 1 dereferenceable(21) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 21, i1 false)
br label %18
11: ; preds = %3
%12 = getelementptr inbounds i8, i8* %8, i64 5
%13 = tail call i64 @strlen(i8* %8)
%14 = add nsw i64 %13, -5
%15 = call i32 @strncpy(i8* %6, i8* %12, i64 %14)
%16 = call double @atof(i8* %6)
store double %16, double* %5
%17 = call i32 @memcpy(double* %1, double* %5, i32 8)
br label %18
18: ; preds = %11, %10
%19 = phi i32 [ 0, %11 ], [ -10, %10 ]
ret i32 %19
}