#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 **);
scalar_t__ strtol(char *, char **, int);
int _load_integer(int *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 = -1;
      else if ((str_ptr2[0] >= '0') && (str_ptr2[0] <= '9')) {
        *destination = (int)strtol(scratch, (char **)NULL, 10);
      } else {
        error("_load_integer: 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_integer>:
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     1345 <_load_integer+0x1c5>
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_integer+0x8b>
movsbl -0x420(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
je     1224 <_load_integer+0xa4>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x444(%rbp)
jmp    12f6 <_load_integer+0x176>
lea    -0x420(%rbp),%rdi
lea    0xdce(%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    0xd9f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1283 <_load_integer+0x103>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    12f1 <_load_integer+0x171>
mov    -0x430(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     12cb <_load_integer+0x14b>
mov    -0x430(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     12cb <_load_integer+0x14b>
lea    -0x420(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    12ec <_load_integer+0x16c>
mov    -0x18(%rbp),%rsi
lea    0xd38(%rip),%rdi
call   1090 <error@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    134c <_load_integer+0x1cc>
jmp    12f1 <_load_integer+0x171>
jmp    12f6 <_load_integer+0x176>
movl   $0x0,-0x43c(%rbp)
mov    -0x43c(%rbp),%eax
mov    -0x440(%rbp),%ecx
add    -0x444(%rbp),%ecx
cmp    %ecx,%eax
jge    1340 <_load_integer+0x1c0>
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    1300 <_load_integer+0x180>
jmp    1345 <_load_integer+0x1c5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_load_integer>:
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     1251 <_load_integer+0xc1>
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     1256 <_load_integer+0xc6>
call   1070 <isspace@plt>
mov    $0x0,%ebx
test   %rax,%rax
jne    1258 <_load_integer+0xc8>
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     1292 <_load_integer+0x102>
mov    (%r14),%al
add    $0xd0,%al
cmp    $0x9,%al
ja     129a <_load_integer+0x10a>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,%r14
jmp    1258 <_load_integer+0xc8>
xor    %r15d,%r15d
jmp    127d <_load_integer+0xed>
xor    %ebx,%ebx
mov    (%rsp),%rax
mov    %r14d,(%rax)
add    %r12d,%ebx
test   %ebx,%ebx
jle    127d <_load_integer+0xed>
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    $0xffffffff,%r14d
jmp    1258 <_load_integer+0xc8>
lea    0xd6d(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <error@plt>
mov    0x2d30(%rip),%rax
mov    (%rax),%r15d
jmp    127d <_load_integer+0xed>

LLVM IR (-O0):
@.str = [4 x i8] c" \0A\09\00"
@.str.1 = [10 x i8] c"UNLIMITED\00"
@.str.2 = [40 x i8] c"_load_integer: bad value for keyword %s\00"
@EINVAL = global i32 0
define i32 @_load_integer(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%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 i32* %0, i32** %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 %92
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 i32*, i32** %5
store i32 1, i32* %41
store i32 0, i32* %14
br label %76
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 i32*, i32** %5
store i32 -1, i32* %52
br label %75
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 sge i32 %57, 48
br i1 %58, label %59, label %70
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 sle i32 %63, 57
br i1 %64, label %65, label %70
65: ; preds = %59
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%67 = call i64 @strtol(i8* %66, i8** null, i32 10)
%68 = trunc i64 %67 to i32
%69 = load i32*, i32** %5
store i32 %68, i32* %69
br label %74
70: ; preds = %59, %53
%71 = load i8*, i8** %6
%72 = call i32 @error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %71)
%73 = load i32, i32* @EINVAL
store i32 %73, i32* %4
br label %93
74: ; preds = %65
br label %75
75: ; preds = %74, %51
br label %76
76: ; preds = %75, %40
store i32 0, i32* %12
br label %77
77: ; preds = %88, %76
%78 = load i32, i32* %12
%79 = load i32, i32* %13
%80 = load i32, i32* %14
%81 = add nsw i32 %79, %80
%82 = icmp slt i32 %78, %81
br i1 %82, label %83, label %91
83: ; preds = %77
%84 = load i8*, i8** %9
%85 = load i32, i32* %12
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
store i8 32, i8* %87
br label %88
88: ; preds = %83
%89 = load i32, i32* %12
%90 = add nsw i32 %89, 1
store i32 %90, i32* %12
br label %77
91: ; preds = %77
br label %92
92: ; preds = %91, %3
store i32 0, i32* %4
br label %93
93: ; preds = %92, %70
%94 = load i32, i32* %4
ret i32 %94
}

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