#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fisError(char *);
int /*<<< orphan*/ *getNextLine(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, char *, char *);
scalar_t__ strlen(char *);
void getString(char *buf, FILE *fp, double *array) {
  int i;
  char string1[500];
  char string2[500];
  int tmp;
  if (getNextLine(buf, fp) == NULL)
    fisError("getString: Incomplete FIS file!");
  tmp = sscanf(buf, " %[^'] '%[^']' ", string1, string2);
  if (tmp != 2) {
    printf("Error format in FIS file when parsing\n");
    printf("\"%s\"\n", buf);
    fisError("Error in getString().");
  }
  for (i = 0; i < (int)strlen(string2); i++)
    array[i] = string2[i];
}


x86 assembly (clang, -O0):
<getString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <getNextLine@plt>
cmp    $0x0,%rax
jne    118a <getString+0x3a>
lea    0xe7b(%rip),%rdi
call   1030 <fisError@plt>
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    -0x410(%rbp),%rcx
lea    0xe7d(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0x2,-0x414(%rbp)
je     11e7 <getString+0x97>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe7b(%rip),%rdi
call   1030 <fisError@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x418(%rbp),%eax
cmp    %ecx,%eax
jge    123f <getString+0xef>
movslq -0x1c(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ee <getString+0x9e>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getString>:
push   %r14
push   %rbx
sub    $0x3f8,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
call   1070 <getNextLine@plt>
test   %rax,%rax
jne    1186 <getString+0x26>
lea    0xe7f(%rip),%rdi
call   1030 <fisError@plt>
lea    0xe93(%rip),%rsi
lea    0x200(%rsp),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
call   1080 <sscanf@plt>
cmp    $0x2,%eax
je     11ce <getString+0x6e>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe78(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe6d(%rip),%rdi
call   1030 <fisError@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1269 <getString+0x109>
mov    %eax,%ecx
cmp    $0x4,%rcx
jae    11ea <getString+0x8a>
xor    %edx,%edx
jmp    1250 <getString+0xf0>
and    $0x3,%eax
mov    %rcx,%rdx
sub    %rax,%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
movd   (%rsp,%rsi,1),%xmm0
punpcklbw %xmm0,%xmm0
movzwl 0x2(%rsp,%rsi,1),%edi
movd   %edi,%xmm1
punpcklbw %xmm1,%xmm1
pshuflw $0x60,%xmm0,%xmm0
psrad  $0x18,%xmm0
cvtdq2pd %xmm0,%xmm0
pshuflw $0x60,%xmm1,%xmm1
psrad  $0x18,%xmm1
cvtdq2pd %xmm1,%xmm1
movupd %xmm0,(%rbx,%rsi,8)
movups %xmm1,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
cmp    %rsi,%rdx
jne    1200 <getString+0xa0>
test   %rax,%rax
je     1269 <getString+0x109>
nopw   0x0(%rax,%rax,1)
movsbl (%rsp,%rdx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1250 <getString+0xf0>
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"getString: Incomplete FIS file!\00"
@.str.1 = [16 x i8] c" %[^'] '%[^']' \00"
@.str.2 = [39 x i8] c"Error format in FIS file when parsing\0A\00"
@.str.3 = [6 x i8] c"\22%s\22\0A\00"
@.str.4 = [22 x i8] c"Error in getString().\00"
define void @getString(i8* %0, i32* %1, double* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca double*
%7 = alloca i32
%8 = alloca [500 x i8]
%9 = alloca [500 x i8]
%10 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store double* %2, double** %6
%11 = load i8*, i8** %4
%12 = load i32*, i32** %5
%13 = call i32* @getNextLine(i8* %11, i32* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @fisError(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %3
%18 = load i8*, i8** %4
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%21 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%26 = load i8*, i8** %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = call i32 @fisError(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %24, %17
store i32 0, i32* %7
br label %30
30: ; preds = %46, %29
%31 = load i32, i32* %7
%32 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 0
%33 = call i64 @strlen(i8* %32)
%34 = trunc i64 %33 to i32
%35 = icmp slt i32 %31, %34
br i1 %35, label %36, label %49
36: ; preds = %30
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [500 x i8], [500 x i8]* %9, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sitofp i8 %40 to double
%42 = load double*, double** %6
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
store double %41, double* %45
br label %46
46: ; preds = %36
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %30
49: ; preds = %30
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"getString: Incomplete FIS file!\00"
@.str.1 = [16 x i8] c" %[^'] '%[^']' \00"
@.str.3 = [6 x i8] c"\22%s\22\0A\00"
@.str.4 = [22 x i8] c"Error in getString().\00"
@str = [38 x i8] c"Error format in FIS file when parsing\00"
define void @getString(i8* %0, i32* %1, double* nocapture writeonly %2) {
%4 = alloca [500 x i8]
%5 = alloca [500 x i8]
%6 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%8 = tail call i32* @getNextLine(i8* %0, i32* %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @fisError(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %7)
%14 = icmp eq i32 %13, 2
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%18 = call i32 @fisError(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %15, %12
%20 = call i64 @strlen(i8* %7)
%21 = trunc i64 %20 to i32
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %57
23: ; preds = %19
%24 = and i64 %20, 4294967295
%25 = icmp ult i64 %24, 4
br i1 %25, label %47, label %26
26: ; preds = %23
%27 = and i64 %20, 3
%28 = sub nsw i64 %24, %27
br label %29
29: ; preds = %29, %26
%30 = phi i64 [ 0, %26 ], [ %43, %29 ]
%31 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 %30
%32 = bitcast i8* %31 to <2 x i8>*
%33 = load <2 x i8>, <2 x i8>* %32
%34 = getelementptr inbounds i8, i8* %31, i64 2
%35 = bitcast i8* %34 to <2 x i8>*
%36 = load <2 x i8>, <2 x i8>* %35
%37 = sitofp <2 x i8> %33 to <2 x double>
%38 = sitofp <2 x i8> %36 to <2 x double>
%39 = getelementptr inbounds double, double* %2, i64 %30
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> %37, <2 x double>* %40
%41 = getelementptr inbounds double, double* %39, i64 2
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> %38, <2 x double>* %42
%43 = add nuw i64 %30, 4
%44 = icmp eq i64 %43, %28
br i1 %44, label %45, label %29
45: ; preds = %29
%46 = icmp eq i64 %27, 0
br i1 %46, label %57, label %47
47: ; preds = %23, %45
%48 = phi i64 [ 0, %23 ], [ %28, %45 ]
br label %49
49: ; preds = %47, %49
%50 = phi i64 [ %55, %49 ], [ %48, %47 ]
%51 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sitofp i8 %52 to double
%54 = getelementptr inbounds double, double* %2, i64 %50
store double %53, double* %54
%55 = add nuw nsw i64 %50, 1
%56 = icmp eq i64 %55, %24
br i1 %56, label %57, label %49
57: ; preds = %49, %45, %19
ret void
}