#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*/ piece(char *, char, char *, int);
double extract_piece_value(char *source, int *ignore, int piece_to_apply) {
  char buffer[1024];
  if (!piece(buffer, '|', source, piece_to_apply)) {
    *ignore = 1;
    return 0.0;
  } else if (!*buffer) {
    *ignore = 1;
    return 0.0;
  } else {
    *ignore = 0;
    return atof(buffer);
  }
}


x86 assembly (clang, -O0):
<extract_piece_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    $0x7c,%esi
call   1040 <piece@plt>
cmp    $0x0,%eax
jne    116e <extract_piece_value+0x4e>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ad <extract_piece_value+0x8d>
cmpb   $0x0,-0x420(%rbp)
jne    1192 <extract_piece_value+0x72>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ad <extract_piece_value+0x8d>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
lea    -0x420(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_piece_value>:
push   %rbx
sub    $0x400,%rsp
mov    %edx,%ecx
mov    %rsi,%rbx
mov    %rdi,%rdx
mov    %rsp,%rdi
mov    $0x7c,%esi
call   1040 <piece@plt>
test   %eax,%eax
je     1157 <extract_piece_value+0x37>
cmpb   $0x0,(%rsp)
je     1157 <extract_piece_value+0x37>
movl   $0x0,(%rbx)
mov    %rsp,%rdi
call   1030 <atof@plt>
jmp    1160 <extract_piece_value+0x40>
movl   $0x1,(%rbx)
xorps  %xmm0,%xmm0
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @extract_piece_value(i8* %0, i32* %1, i32 %2) {
%4 = alloca double
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [1024 x i8]
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %5
%11 = load i32, i32* %7
%12 = call i32 @piece(i8* %9, i8 signext 124, i8* %10, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %3
%15 = load i32*, i32** %6
store i32 1, i32* %15
store double 0.000000e+00, double* %4
br label %26
16: ; preds = %3
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = load i32*, i32** %6
store i32 1, i32* %21
store double 0.000000e+00, double* %4
br label %26
22: ; preds = %16
%23 = load i32*, i32** %6
store i32 0, i32* %23
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%25 = call double @atof(i8* %24)
store double %25, double* %4
br label %26
26: ; preds = %22, %20, %14
%27 = load double, double* %4
ret double %27
}

LLVM IR (-O2):
define double @extract_piece_value(i8* %0, i32* nocapture writeonly %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i32 @piece(i8* %5, i8 signext 124, i8* %0, i32 %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %3
store i32 1, i32* %1
br label %15
9: ; preds = %3
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 1, i32* %1
br label %15
13: ; preds = %9
store i32 0, i32* %1
%14 = call double @atof(i8* %5)
br label %15
15: ; preds = %13, %12, %8
%16 = phi double [ %14, %13 ], [ 0.000000e+00, %12 ], [ 0.000000e+00, %8 ]
ret double %16
}