#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 */
int EINVAL;
int /*<<< orphan*/ error(char *, char *);
scalar_t__ slurm_strcasestr(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strtod(char *, char **);
scalar_t__ strtok_r(char *, char *, char **);
int _load_float(float *destination, char *keyword, char *in_line) {
  char scratch[1024];
  char *str_ptr1, *str_ptr2, *str_ptr3;
  int i, str_len1, str_len2;
  str_ptr1 = (char *)slurm_strcasestr(in_line, keyword);
  if (str_ptr1 != NULL) {
    str_len1 = strlen(keyword);
    strcpy(scratch, str_ptr1 + str_len1);
    if ((scratch[0] < '0') && (scratch[0] > '9')) {
      error("_load_float: bad value for keyword %s", keyword);
      return EINVAL;
    }
    str_ptr2 = (char *)strtok_r(scratch, " \n\t", &str_ptr3);
    str_len2 = strlen(str_ptr2);
    *destination = (float)strtod(scratch, (char **)NULL);
    for (i = 0; i < (str_len1 + str_len2); i++) {
      str_ptr1[i] = ' ';
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<_load_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <slurm_strcasestr@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     12a5 <_load_float+0x145>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x440(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rsi
movslq -0x440(%rbp),%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
movsbl -0x420(%rbp),%eax
cmp    $0x30,%eax
jge    1206 <_load_float+0xa6>
movsbl -0x420(%rbp),%eax
cmp    $0x39,%eax
jle    1206 <_load_float+0xa6>
mov    -0x18(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1070 <error@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ac <_load_float+0x14c>
lea    -0x420(%rbp),%rdi
lea    0xe12(%rip),%rsi
lea    -0x438(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x444(%rbp)
lea    -0x420(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
cvtsi2ss %rax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x43c(%rbp)
mov    -0x43c(%rbp),%eax
mov    -0x440(%rbp),%ecx
add    -0x444(%rbp),%ecx
cmp    %ecx,%eax
jge    12a0 <_load_float+0x140>
mov    -0x428(%rbp),%rax
movslq -0x43c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x43c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x43c(%rbp)
jmp    1260 <_load_float+0x100>
jmp    12a5 <_load_float+0x145>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_load_float>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x410,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rdx,%rdi
call   1080 <slurm_strcasestr@plt>
test   %rax,%rax
je     11f0 <_load_float+0x90>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rbx
lea    (%r14,%rbx,1),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1030 <strcpy@plt>
lea    0xe58(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
call   1070 <strtok_r@plt>
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r15)
add    %ebp,%ebx
test   %ebx,%ebx
jle    11f0 <_load_float+0x90>
add    $0xffffffff,%ebx
add    $0x1,%rbx
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1060 <memset@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"_load_float: bad value for keyword %s\00"
@EINVAL = global i32 0
@.str.1 = [4 x i8] c" \0A\09\00"
define i32 @_load_float(float* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store float* %0, float** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%15 = load i8*, i8** %7
%16 = load i8*, i8** %6
%17 = call i64 @slurm_strcasestr(i8* %15, i8* %16)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %9
%19 = load i8*, i8** %9
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %68
21: ; preds = %3
%22 = load i8*, i8** %6
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %13
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%25 = load i8*, i8** %9
%26 = load i32, i32* %13
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = call i32 @strcpy(i8* %24, i8* %28)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp slt i32 %32, 48
br i1 %33, label %34, label %43
34: ; preds = %21
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp sgt i32 %37, 57
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = load i8*, i8** %6
%41 = call i32 @error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %40)
%42 = load i32, i32* @EINVAL
store i32 %42, i32* %4
br label %69
43: ; preds = %34, %21
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%45 = call i64 @strtok_r(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %11)
%46 = inttoptr i64 %45 to i8*
store i8* %46, i8** %10
%47 = load i8*, i8** %10
%48 = call i32 @strlen(i8* %47)
store i32 %48, i32* %14
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%50 = call i64 @strtod(i8* %49, i8** null)
%51 = sitofp i64 %50 to float
%52 = load float*, float** %5
store float %51, float* %52
store i32 0, i32* %12
br label %53
53: ; preds = %64, %43
%54 = load i32, i32* %12
%55 = load i32, i32* %13
%56 = load i32, i32* %14
%57 = add nsw i32 %55, %56
%58 = icmp slt i32 %54, %57
br i1 %58, label %59, label %67
59: ; preds = %53
%60 = load i8*, i8** %9
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
store i8 32, i8* %63
br label %64
64: ; preds = %59
%65 = load i32, i32* %12
%66 = add nsw i32 %65, 1
store i32 %66, i32* %12
br label %53
67: ; preds = %53
br label %68
68: ; preds = %67, %3
store i32 0, i32* %4
br label %69
69: ; preds = %68, %39
%70 = load i32, i32* %4
ret i32 %70
}

LLVM IR (-O2):
@EINVAL = global i32 0
@.str.1 = [4 x i8] c" \0A\09\00"
define i32 @_load_float(float* nocapture writeonly %0, i8* %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = bitcast i8** %5 to i8*
%8 = tail call i64 @slurm_strcasestr(i8* %2, i8* %1)
%9 = inttoptr i64 %8 to i8*
%10 = icmp eq i64 %8, 0
br i1 %10, label %27, label %11
11: ; preds = %3
%12 = tail call i32 @strlen(i8* %1)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
%15 = call i32 @strcpy(i8* %6, i8* %14)
%16 = call i64 @strtok_r(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %5)
%17 = inttoptr i64 %16 to i8*
%18 = call i32 @strlen(i8* %17)
%19 = call i64 @strtod(i8* nocapture %6, i8** null)
%20 = sitofp i64 %19 to float
store float %20, float* %0
%21 = add i32 %18, %12
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %11
%24 = add nsw i32 %21, -1
%25 = zext i32 %24 to i64
%26 = add nuw nsw i64 %25, 1
br label %27
27: ; preds = %23, %11, %3
ret i32 0
}