#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*/ info(char *, char *);
scalar_t__ slurm_strcasestr(char *, char *);
int /*<<< orphan*/ slurm_xfree(void **, char *, int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok_r(char *, char *, char **);
char *xstrdup(char *);
int load_string(char **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) {
    int quoted = 0;
    str_len1 = strlen(keyword);
    if (str_ptr1[str_len1] == '"')
      quoted = 1;
    strcpy(scratch, str_ptr1 + str_len1 + quoted);
    if (quoted)
      str_ptr2 = strtok_r(scratch, "\042\n", &str_ptr3);
    else
      str_ptr2 = strtok_r(scratch, " \n\t", &str_ptr3);
    if ((str_ptr2 == NULL) || ((str_len2 = strlen(str_ptr2)) == 0)) {
      info("load_string : keyword %s lacks value", keyword);
      return EINVAL;
    }
    slurm_xfree((void **)&(destination[0]),
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/"
                "debian-slurm/refs/heads/master/slurm/src/common/parse_spec.c",
                314, "");
    destination[0] = xstrdup(str_ptr2);
    for (i = 0; i < (str_len1 + str_len2 + quoted); i++)
      str_ptr1[i] = ' ';
    if (quoted && (str_ptr1[i] == '"'))
      str_ptr1[i] = ' ';
  }
  return 0;
}


x86 assembly (clang, -O0):
<load_string>:
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   1070 <slurm_strcasestr@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     136d <load_string+0x1fd>
movl   $0x0,-0x448(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x440(%rbp)
mov    -0x428(%rbp),%rax
movslq -0x440(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    11e7 <load_string+0x77>
movl   $0x1,-0x448(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x428(%rbp),%rsi
movslq -0x440(%rbp),%rax
add    %rax,%rsi
movslq -0x448(%rbp),%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
cmpl   $0x0,-0x448(%rbp)
je     1241 <load_string+0xd1>
lea    -0x420(%rbp),%rdi
lea    0xdd7(%rip),%rsi
lea    -0x438(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x430(%rbp)
jmp    1262 <load_string+0xf2>
lea    -0x420(%rbp),%rdi
lea    0xdb4(%rip),%rsi
lea    -0x438(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
je     128b <load_string+0x11b>
mov    -0x430(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x444(%rbp)
cmp    $0x0,%eax
jne    12ac <load_string+0x13c>
mov    -0x18(%rbp),%rsi
lea    0xd71(%rip),%rdi
call   1090 <info@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1374 <load_string+0x204>
mov    -0x10(%rbp),%rdi
lea    0xd75(%rip),%rsi
mov    $0x13a,%edx
lea    0xd43(%rip),%rcx
call   1080 <slurm_xfree@plt>
mov    -0x430(%rbp),%rdi
call   1050 <xstrdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x43c(%rbp)
mov    -0x43c(%rbp),%eax
mov    -0x440(%rbp),%ecx
add    -0x444(%rbp),%ecx
add    -0x448(%rbp),%ecx
cmp    %ecx,%eax
jge    132e <load_string+0x1be>
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    12e8 <load_string+0x178>
cmpl   $0x0,-0x448(%rbp)
je     1368 <load_string+0x1f8>
mov    -0x428(%rbp),%rax
movslq -0x43c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    1368 <load_string+0x1f8>
mov    -0x428(%rbp),%rax
movslq -0x43c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
jmp    136d <load_string+0x1fd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rdx,%rdi
call   1080 <slurm_strcasestr@plt>
test   %rax,%rax
je     1278 <load_string+0xf8>
mov    %rax,%r12
mov    %rbp,0x10(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
cltq
mov    %r12,%rcx
add    %rax,%rcx
mov    (%r12,%rax,1),%al
xor    %r14d,%r14d
mov    %al,0xf(%rsp)
cmp    $0x22,%al
sete   %r14b
lea    0xe25(%rip),%rax
lea    0xe21(%rip),%rbp
cmove  %rax,%rbp
lea    (%r14,%rcx,1),%rsi
lea    0x20(%rsp),%r13
mov    %r13,%rdi
call   1030 <strcpy@plt>
lea    0x18(%rsp),%rdx
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <strtok_r@plt>
test   %rax,%rax
je     127c <load_string+0xfc>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     127c <load_string+0xfc>
mov    %eax,%r13d
lea    0xe07(%rip),%rsi
lea    0xdda(%rip),%rcx
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x13a,%edx
call   1090 <slurm_xfree@plt>
mov    %rbp,%rdi
call   1060 <xstrdup@plt>
mov    %rax,(%rbx)
lea    (%r15,%r14,1),%eax
add    %r13d,%eax
xor    %ebx,%ebx
test   %eax,%eax
jle    1296 <load_string+0x116>
add    %r15d,%r13d
lea    (%r14,%r13,1),%ebp
add    $0xffffffff,%ebp
add    $0x1,%rbp
mov    %r12,%rdi
mov    $0x20,%esi
mov    %rbp,%rdx
call   1050 <memset@plt>
mov    %ebp,%eax
jmp    1298 <load_string+0x118>
xor    %ebx,%ebx
jmp    12ad <load_string+0x12d>
lea    0xd84(%rip),%rdi
mov    %rbx,%rsi
call   10a0 <info@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%ebx
jmp    12ad <load_string+0x12d>
xor    %eax,%eax
mov    0xf(%rsp),%cl
cmp    $0x22,%cl
jne    12ad <load_string+0x12d>
cmpb   $0x22,(%r12,%rax,1)
jne    12ad <load_string+0x12d>
movb   $0x20,(%r12,%rax,1)
mov    %ebx,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\22\0A\00"
@.str.1 = [4 x i8] c" \0A\09\00"
@.str.2 = [37 x i8] c"load_string : keyword %s lacks value\00"
@EINVAL = global i32 0
@.str.3 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/slurm/src/common/parse_spec.c\00"
@.str.4 = [1 x i8] zeroinitializer
define i32 @load_string(i8** %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%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
%15 = alloca i32
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%16 = load i8*, i8** %7
%17 = load i8*, i8** %6
%18 = call i64 @slurm_strcasestr(i8* %16, i8* %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %103
22: ; preds = %3
store i32 0, i32* %15
%23 = load i8*, i8** %6
%24 = call i32 @strlen(i8* %23)
store i32 %24, i32* %13
%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 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 34
br i1 %31, label %32, label %33
32: ; preds = %22
store i32 1, i32* %15
br label %33
33: ; preds = %32, %22
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = load i8*, i8** %9
%36 = load i32, i32* %13
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i32, i32* %15
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = call i32 @strcpy(i8* %34, i8* %41)
%43 = load i32, i32* %15
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %33
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%47 = call i8* @strtok_r(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %11)
store i8* %47, i8** %10
br label %51
48: ; preds = %33
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%50 = call i8* @strtok_r(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %11)
store i8* %50, i8** %10
br label %51
51: ; preds = %48, %45
%52 = load i8*, i8** %10
%53 = icmp eq i8* %52, null
br i1 %53, label %58, label %54
54: ; preds = %51
%55 = load i8*, i8** %10
%56 = call i32 @strlen(i8* %55)
store i32 %56, i32* %14
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %54, %51
%59 = load i8*, i8** %6
%60 = call i32 @info(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %59)
%61 = load i32, i32* @EINVAL
store i32 %61, i32* %4
br label %104
62: ; preds = %54
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = call i32 @slurm_xfree(i8** %64, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.3, i64 0, i64 0), i32 314, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%66 = load i8*, i8** %10
%67 = call i8* @xstrdup(i8* %66)
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 0
store i8* %67, i8** %69
store i32 0, i32* %12
br label %70
70: ; preds = %83, %62
%71 = load i32, i32* %12
%72 = load i32, i32* %13
%73 = load i32, i32* %14
%74 = add nsw i32 %72, %73
%75 = load i32, i32* %15
%76 = add nsw i32 %74, %75
%77 = icmp slt i32 %71, %76
br i1 %77, label %78, label %86
78: ; preds = %70
%79 = load i8*, i8** %9
%80 = load i32, i32* %12
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
store i8 32, i8* %82
br label %83
83: ; preds = %78
%84 = load i32, i32* %12
%85 = add nsw i32 %84, 1
store i32 %85, i32* %12
br label %70
86: ; preds = %70
%87 = load i32, i32* %15
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %102
89: ; preds = %86
%90 = load i8*, i8** %9
%91 = load i32, i32* %12
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 34
br i1 %96, label %97, label %102
97: ; preds = %89
%98 = load i8*, i8** %9
%99 = load i32, i32* %12
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %98, i64 %100
store i8 32, i8* %101
br label %102
102: ; preds = %97, %89, %86
br label %103
103: ; preds = %102, %3
store i32 0, i32* %4
br label %104
104: ; preds = %103, %58
%105 = load i32, i32* %4
ret i32 %105
}

LLVM IR (-O2):
@.str = [3 x i8] c"\22\0A\00"
@.str.1 = [4 x i8] c" \0A\09\00"
@.str.2 = [37 x i8] c"load_string : keyword %s lacks value\00"
@EINVAL = global i32 0
@.str.3 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/slurm/src/common/parse_spec.c\00"
@.str.4 = [1 x i8] zeroinitializer
define i32 @load_string(i8** %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 %50, 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 = load i8, i8* %14
%16 = icmp eq i8 %15, 34
%17 = zext i1 %16 to i32
%18 = zext i1 %16 to i64
%19 = getelementptr inbounds i8, i8* %14, i64 %18
%20 = call i32 @strcpy(i8* %6, i8* %19)
%21 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%22 = call i8* @strtok_r(i8* %6, i8* %21, i8** %5)
%23 = icmp eq i8* %22, null
br i1 %23, label %47, label %24
24: ; preds = %11
%25 = call i32 @strlen(i8* %22)
%26 = icmp eq i32 %25, 0
br i1 %26, label %47, label %27
27: ; preds = %24
%28 = call i32 @slurm_xfree(i8** %0, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.3, i64 0, i64 0), i32 314, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%29 = call i8* @xstrdup(i8* %22)
store i8* %29, i8** %0
%30 = add i32 %12, %17
%31 = add i32 %30, %25
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %27
%34 = add i32 %25, %12
%35 = add i32 %34, %17
%36 = add i32 %35, -1
%37 = zext i32 %36 to i64
%38 = add nuw nsw i64 %37, 1
%39 = and i64 %38, 4294967295
br label %40
40: ; preds = %33, %27
%41 = phi i64 [ 0, %27 ], [ %39, %33 ]
br i1 %16, label %42, label %50
42: ; preds = %40
%43 = getelementptr inbounds i8, i8* %9, i64 %41
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 34
br i1 %45, label %46, label %50
46: ; preds = %42
store i8 32, i8* %43
br label %50
47: ; preds = %11, %24
%48 = call i32 @info(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%49 = load i32, i32* @EINVAL
br label %50
50: ; preds = %40, %42, %46, %3, %47
%51 = phi i32 [ %49, %47 ], [ 0, %3 ], [ 0, %46 ], [ 0, %42 ], [ 0, %40 ]
ret i32 %51
}