#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__ isspace(int);
scalar_t__ slurm_strcasestr(char *, char *);
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strtok_r(char *, char *, char **);
long strtol(char *, char **, int);
int _load_long(long *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') || (isspace((int)scratch[0]))) {
      *destination = 1;
      str_len2 = 0;
    } else {
      str_ptr2 = (char *)strtok_r(scratch, " \n\t", &str_ptr3);
      str_len2 = strlen(str_ptr2);
      if (strcasecmp(str_ptr2, "UNLIMITED") == 0)
        *destination = -1L;
      else if ((str_ptr2[0] == '-') ||
               ((str_ptr2[0] >= '0') && (str_ptr2[0] <= '9'))) {
        *destination = strtol(scratch, (char **)NULL, 10);
      } else {
        error("_load_long: bad value for keyword %s", keyword);
        return EINVAL;
      }
    }
    for (i = 0; i < (str_len1 + str_len2); i++) {
      str_ptr1[i] = ' ';
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<_load_long>:
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   10a0 <slurm_strcasestr@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     135c <_load_long+0x1dc>
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   1040 <strcpy@plt>
movsbl -0x420(%rbp),%eax
cmp    $0x0,%eax
je     120b <_load_long+0x8b>
movsbl -0x420(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     1225 <_load_long+0xa5>
mov    -0x10(%rbp),%rax
movq   $0x1,(%rax)
movl   $0x0,-0x444(%rbp)
jmp    130d <_load_long+0x18d>
lea    -0x420(%rbp),%rdi
lea    0xdcd(%rip),%rsi
lea    -0x438(%rbp),%rdx
call   1070 <strtok_r@plt>
mov    %rax,-0x430(%rbp)
mov    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x444(%rbp)
mov    -0x430(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1285 <_load_long+0x105>
mov    -0x10(%rbp),%rax
movq   $0xffffffffffffffff,(%rax)
jmp    1308 <_load_long+0x188>
mov    -0x430(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     12be <_load_long+0x13e>
mov    -0x430(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     12e2 <_load_long+0x162>
mov    -0x430(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     12e2 <_load_long+0x162>
lea    -0x420(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1303 <_load_long+0x183>
mov    -0x18(%rbp),%rsi
lea    0xd21(%rip),%rdi
call   1090 <error@plt>
mov    0x2ce7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1363 <_load_long+0x1e3>
jmp    1308 <_load_long+0x188>
jmp    130d <_load_long+0x18d>
movl   $0x0,-0x43c(%rbp)
mov    -0x43c(%rbp),%eax
mov    -0x440(%rbp),%ecx
add    -0x444(%rbp),%ecx
cmp    %ecx,%eax
jge    1357 <_load_long+0x1d7>
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    1317 <_load_long+0x197>
jmp    135c <_load_long+0x1dc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_load_long>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rdx,%rdi
call   10b0 <slurm_strcasestr@plt>
test   %rax,%rax
je     125a <_load_long+0xca>
mov    %rax,%r13
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
movslq %eax,%rsi
add    %r13,%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
movsbl 0x10(%rsp),%edi
xor    %r15d,%r15d
mov    $0x1,%r14d
test   %edi,%edi
mov    %rbx,(%rsp)
je     125f <_load_long+0xcf>
call   1070 <isspace@plt>
mov    $0x0,%ebx
test   %rax,%rax
jne    1261 <_load_long+0xd1>
lea    0xdfe(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
call   1080 <strtok_r@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xddf(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     129b <_load_long+0x10b>
mov    (%r14),%al
cmp    $0x2d,%al
je     12a4 <_load_long+0x114>
add    $0xd0,%al
cmp    $0x9,%al
jbe    12a4 <_load_long+0x114>
lea    0xdc8(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <error@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%r15d
jmp    1286 <_load_long+0xf6>
xor    %r15d,%r15d
jmp    1286 <_load_long+0xf6>
xor    %ebx,%ebx
mov    (%rsp),%rax
mov    %r14,(%rax)
add    %r12d,%ebx
test   %ebx,%ebx
jle    1286 <_load_long+0xf6>
add    $0xffffffff,%ebx
add    $0x1,%rbx
mov    %r13,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1060 <memset@plt>
mov    %r15d,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffffffffffff,%r14
jmp    1261 <_load_long+0xd1>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,%r14
jmp    1261 <_load_long+0xd1>

LLVM IR (-O0):
@.str = [4 x i8] c" \0A\09\00"
@.str.1 = [10 x i8] c"UNLIMITED\00"
@.str.2 = [37 x i8] c"_load_long: bad value for keyword %s\00"
@EINVAL = global i32 0
define i32 @_load_long(i64* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i64*
%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 i64* %0, i64** %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 %97
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 eq i32 %32, 0
br i1 %33, label %40, label %34
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 = call i64 @isspace(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %34, %21
%41 = load i64*, i64** %5
store i64 1, i64* %41
store i32 0, i32* %14
br label %81
42: ; preds = %34
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%44 = call i64 @strtok_r(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %11)
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %10
%46 = load i8*, i8** %10
%47 = call i32 @strlen(i8* %46)
store i32 %47, i32* %14
%48 = load i8*, i8** %10
%49 = call i64 @strcasecmp(i8* %48, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %42
%52 = load i64*, i64** %5
store i64 -1, i64* %52
br label %80
53: ; preds = %42
%54 = load i8*, i8** %10
%55 = getelementptr inbounds i8, i8* %54, i64 0
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 45
br i1 %58, label %71, label %59
59: ; preds = %53
%60 = load i8*, i8** %10
%61 = getelementptr inbounds i8, i8* %60, i64 0
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp sge i32 %63, 48
br i1 %64, label %65, label %75
65: ; preds = %59
%66 = load i8*, i8** %10
%67 = getelementptr inbounds i8, i8* %66, i64 0
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp sle i32 %69, 57
br i1 %70, label %71, label %75
71: ; preds = %65, %53
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%73 = call i64 @strtol(i8* %72, i8** null, i32 10)
%74 = load i64*, i64** %5
store i64 %73, i64* %74
br label %79
75: ; preds = %65, %59
%76 = load i8*, i8** %6
%77 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %76)
%78 = load i32, i32* @EINVAL
store i32 %78, i32* %4
br label %98
79: ; preds = %71
br label %80
80: ; preds = %79, %51
br label %81
81: ; preds = %80, %40
store i32 0, i32* %12
br label %82
82: ; preds = %93, %81
%83 = load i32, i32* %12
%84 = load i32, i32* %13
%85 = load i32, i32* %14
%86 = add nsw i32 %84, %85
%87 = icmp slt i32 %83, %86
br i1 %87, label %88, label %96
88: ; preds = %82
%89 = load i8*, i8** %9
%90 = load i32, i32* %12
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %89, i64 %91
store i8 32, i8* %92
br label %93
93: ; preds = %88
%94 = load i32, i32* %12
%95 = add nsw i32 %94, 1
store i32 %95, i32* %12
br label %82
96: ; preds = %82
br label %97
97: ; preds = %96, %3
store i32 0, i32* %4
br label %98
98: ; preds = %97, %75
%99 = load i32, i32* %4
ret i32 %99
}

LLVM IR (-O2):
@.str = [4 x i8] c" \0A\09\00"
@.str.1 = [10 x i8] c"UNLIMITED\00"
@.str.2 = [37 x i8] c"_load_long: bad value for keyword %s\00"
@EINVAL = global i32 0
define i32 @_load_long(i64* 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 %48, 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 = load i8, i8* %6
%17 = icmp eq i8 %16, 0
br i1 %17, label %39, label %18
18: ; preds = %11
%19 = sext i8 %16 to i32
%20 = call i64 @isspace(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = call i64 @strtok_r(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5)
%24 = inttoptr i64 %23 to i8*
%25 = call i32 @strlen(i8* %24)
%26 = call i64 @strcasecmp(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %39, label %28
28: ; preds = %22
%29 = load i8, i8* %24
%30 = icmp eq i8 %29, 45
%31 = add i8 %29, -48
%32 = icmp ult i8 %31, 10
%33 = or i1 %30, %32
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i64 @strtol(i8* nocapture %6, i8** null, i32 10)
br label %39
36: ; preds = %28
%37 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%38 = load i32, i32* @EINVAL
br label %48
39: ; preds = %22, %11, %18, %34
%40 = phi i64 [ %35, %34 ], [ 1, %18 ], [ 1, %11 ], [ -1, %22 ]
%41 = phi i32 [ %25, %34 ], [ 0, %18 ], [ 0, %11 ], [ %25, %22 ]
store i64 %40, i64* %0
%42 = add i32 %41, %12
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = add nsw i32 %42, -1
%46 = zext i32 %45 to i64
%47 = add nuw nsw i64 %46, 1
br label %48
48: ; preds = %44, %39, %3, %36
%49 = phi i32 [ %38, %36 ], [ 0, %3 ], [ 0, %39 ], [ 0, %44 ]
ret i32 %49
}