#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int split_double_line(char *str, double *parray) {
  char num_str[1000];
  int i = 0;
  int j = 0;
  int num_count = 0;
  while (1) {
    if (str[i] == ' ' || str[i] == '\0') {
      if (j == 0) {
        printf("Error in reading formatted file.\n");
        exit(1);
      } else {
        num_str[j] = '\0';
        if (parray != NULL)
          parray[num_count] = atof(num_str);
        num_count++;
        j = 0;
      }
      if (str[i] == '\0')
        break;
    } else if ((str[i] >= 48 && str[i] <= 57) || (str[i] == '.') ||
               (str[i] == '-')) {
      num_str[j] = str[i];
      j++;
    } else {
      printf("Unexpected character found in the file.\n");
      putchar(str[i]);
      exit(1);
    }
    i++;
  }
  return num_count;
}


x86 assembly (clang, -O0):
<split_double_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x404(%rbp)
movl   $0x0,-0x408(%rbp)
movl   $0x0,-0x40c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11a1 <split_double_line+0x61>
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1235 <split_double_line+0xf5>
cmpl   $0x0,-0x408(%rbp)
jne    11c4 <split_double_line+0x84>
lea    0xe4b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movslq -0x408(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
cmpq   $0x0,-0x10(%rbp)
je     11fa <split_double_line+0xba>
lea    -0x400(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x10(%rbp),%rax
movslq -0x40c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40c(%rbp)
movl   $0x0,-0x408(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1230 <split_double_line+0xf0>
jmp    1308 <split_double_line+0x1c8>
jmp    12f4 <split_double_line+0x1b4>
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1265 <split_double_line+0x125>
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jle    1295 <split_double_line+0x155>
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     1295 <split_double_line+0x155>
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    12c5 <split_double_line+0x185>
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x408(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    12ef <split_double_line+0x1af>
lea    0xd56(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x404(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    12f4 <split_double_line+0x1b4>
mov    -0x404(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404(%rbp)
jmp    1171 <split_double_line+0x31>
mov    -0x40c(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_double_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
mov    %rsp,%r15
xor    %ebp,%ebp
jmp    116d <split_double_line+0x2d>
nopl   0x0(%rax)
movslq %eax,%rdx
mov    %cl,(%rsp,%rdx,1)
add    $0x1,%eax
add    $0x1,%rbx
movzbl (%rbx),%ecx
test   $0xdf,%cl
jne    11b0 <split_double_line+0x70>
test   %eax,%eax
je     11ee <split_double_line+0xae>
cltq
movb   $0x0,(%rsp,%rax,1)
test   %r14,%r14
je     1198 <split_double_line+0x58>
mov    %r15,%rdi
call   1050 <atof@plt>
movslq %ebp,%rax
movsd  %xmm0,(%r14,%rax,8)
movzbl (%rbx),%ecx
add    $0x1,%ebp
xor    %eax,%eax
test   %cl,%cl
jne    1169 <split_double_line+0x29>
jmp    11de <split_double_line+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x30(%rcx),%edx
cmp    $0xa,%dl
jb     1160 <split_double_line+0x20>
lea    -0x2d(%rcx),%edx
cmp    $0x1,%dl
jbe    1160 <split_double_line+0x20>
lea    0xe39(%rip),%rdi
call   1040 <puts@plt>
movsbl (%rbx),%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    %ebp,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe33(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Error in reading formatted file.\0A\00"
@.str.1 = [41 x i8] c"Unexpected character found in the file.\0A\00"
define i32 @split_double_line(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca [1000 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store double* %1, double** %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %2, %110
%10 = load i8*, i8** %3
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %25, label %17
17: ; preds = %9
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %57
25: ; preds = %17, %9
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %25
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %33
store i8 0, i8* %34
%35 = load double*, double** %4
%36 = icmp ne double* %35, null
br i1 %36, label %37, label %44
37: ; preds = %31
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%39 = call double @atof(i8* %38)
%40 = load double*, double** %4
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double %39, double* %43
br label %44
44: ; preds = %37, %31
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
store i32 0, i32* %7
br label %47
47: ; preds = %44
%48 = load i8*, i8** %3
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %47
br label %113
56: ; preds = %47
br label %110
57: ; preds = %17
%58 = load i8*, i8** %3
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp sge i32 %63, 48
br i1 %64, label %65, label %73
65: ; preds = %57
%66 = load i8*, i8** %3
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp sle i32 %71, 57
br i1 %72, label %89, label %73
73: ; preds = %65, %57
%74 = load i8*, i8** %3
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 46
br i1 %80, label %89, label %81
81: ; preds = %73
%82 = load i8*, i8** %3
%83 = load i32, i32* %6
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %82, i64 %84
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 45
br i1 %88, label %89, label %100
89: ; preds = %81, %73, %65
%90 = load i8*, i8** %3
%91 = load i32, i32* %6
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = load i8, i8* %93
%95 = load i32, i32* %7
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 %96
store i8 %94, i8* %97
%98 = load i32, i32* %7
%99 = add nsw i32 %98, 1
store i32 %99, i32* %7
br label %109
100: ; preds = %81
%101 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%102 = load i8*, i8** %3
%103 = load i32, i32* %6
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %102, i64 %104
%106 = load i8, i8* %105
%107 = call i32 @putchar(i8 signext %106)
%108 = call i32 @exit(i32 1)
unreachable
109: ; preds = %89
br label %110
110: ; preds = %109, %56
%111 = load i32, i32* %6
%112 = add nsw i32 %111, 1
store i32 %112, i32* %6
br label %9
113: ; preds = %55
%114 = load i32, i32* %8
ret i32 %114
}

LLVM IR (-O2):
@str = [40 x i8] c"Unexpected character found in the file.\00"
@str.2 = [33 x i8] c"Error in reading formatted file.\00"
define i32 @split_double_line(i8* nocapture %0, double* writeonly %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = icmp eq double* %1, null
br label %6
6: ; preds = %44, %2
%7 = phi i64 [ %47, %44 ], [ 0, %2 ]
%8 = phi i32 [ %45, %44 ], [ 0, %2 ]
%9 = phi i32 [ %46, %44 ], [ 0, %2 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %7
%11 = load i8, i8* %10
switch i8 %11, label %29 [
i8 32, label %12
i8 0, label %12
]
12: ; preds = %6, %6
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.2, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %12
%18 = sext i32 %8 to i64
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %18
store i8 0, i8* %19
br i1 %5, label %25, label %20
20: ; preds = %17
%21 = call double @atof(i8* %4)
%22 = sext i32 %9 to i64
%23 = getelementptr inbounds double, double* %1, i64 %22
store double %21, double* %23
%24 = load i8, i8* %10
br label %25
25: ; preds = %20, %17
%26 = phi i8 [ %24, %20 ], [ %11, %17 ]
%27 = add nsw i32 %9, 1
%28 = icmp eq i8 %26, 0
br i1 %28, label %48, label %44
29: ; preds = %6
%30 = add i8 %11, -48
%31 = icmp ult i8 %30, 10
%32 = add i8 %11, -45
%33 = icmp ult i8 %32, 2
%34 = or i1 %31, %33
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = sext i32 %8 to i64
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %36
store i8 %11, i8* %37
%38 = add nsw i32 %8, 1
br label %44
39: ; preds = %29
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%41 = load i8, i8* %10
%42 = tail call i32 @putchar(i8 signext %41)
%43 = tail call i32 @exit(i32 1)
unreachable
44: ; preds = %25, %35
%45 = phi i32 [ 0, %25 ], [ %38, %35 ]
%46 = phi i32 [ %27, %25 ], [ %9, %35 ]
%47 = add nuw i64 %7, 1
br label %6
48: ; preds = %25
ret i32 %27
}