#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 /*<<< orphan*/ memcpy(char *, char *, int);
char *slurm_xmalloc(int, char *, int, char *);
char *xstrdup(char *);
char *xstrstrip(char *str) {
  int i = 0, start = 0, found = 0;
  char *meat = NULL;
  char quote_c = '\0';
  int quote = 0;
  if (!str)
    return NULL;
  if (str[i] == '\"' || str[i] == '\'') {
    quote_c = str[i];
    quote = 1;
    i++;
  }
  start = i;
  while (str[i]) {
    if (quote && str[i] == quote_c) {
      found = 1;
      break;
    }
    i++;
  }
  if (found) {
    meat =
        slurm_xmalloc((i - start) + 1,
                      "/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/src/common/xstring.c",
                      493, "");
    memcpy(meat, str + start, (i - start));
  } else
    meat = xstrdup(str);
  return meat;
}


x86 assembly (clang, -O0):
<xstrstrip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movb   $0x0,-0x29(%rbp)
movl   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117c <xstrstrip+0x4c>
movq   $0x0,-0x8(%rbp)
jmp    127b <xstrstrip+0x14b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
je     11a6 <xstrstrip+0x76>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
jne    11c4 <xstrstrip+0x94>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1218 <xstrstrip+0xe8>
cmpl   $0x0,-0x30(%rbp)
je     120a <xstrstrip+0xda>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x29(%rbp),%ecx
cmp    %ecx,%eax
jne    120a <xstrstrip+0xda>
movl   $0x1,-0x1c(%rbp)
jmp    1218 <xstrstrip+0xe8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <xstrstrip+0x9a>
cmpl   $0x0,-0x1c(%rbp)
je     1266 <xstrstrip+0x136>
mov    -0x14(%rbp),%edi
sub    -0x18(%rbp),%edi
add    $0x1,%edi
lea    0xdce(%rip),%rsi
mov    $0x1ed,%edx
lea    0xe5f(%rip),%rcx
call   1030 <slurm_xmalloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
sub    -0x18(%rbp),%edx
call   1050 <memcpy@plt>
jmp    1273 <xstrstrip+0x143>
mov    -0x10(%rbp),%rdi
call   1040 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xstrstrip>:
push   %r15
push   %r14
push   %rbx
xor    %r15d,%r15d
test   %rdi,%rdi
je     11ce <xstrstrip+0x9e>
movzbl (%rdi),%edx
cmp    $0x27,%edx
je     115a <xstrstrip+0x2a>
mov    %edx,%ecx
mov    $0x0,%eax
mov    $0x0,%esi
cmp    $0x22,%dl
jne    1167 <xstrstrip+0x37>
mov    0x1(%rdi),%cl
mov    $0x1,%esi
mov    $0x1,%al
mov    %edx,%r15d
test   %cl,%cl
je     1199 <xstrstrip+0x69>
mov    %esi,%edx
lea    (%rdi,%rdx,1),%r14
add    %rdi,%rdx
add    $0x1,%rdx
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl %cl,%ecx
cmp    %ecx,%r15d
sete   %cl
test   %cl,%al
jne    11a3 <xstrstrip+0x73>
movzbl (%rdx,%rbx,1),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1180 <xstrstrip+0x50>
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <xstrdup@plt>
lea    0x1(%rbx),%edi
lea    0xe53(%rip),%rsi
lea    0xee9(%rip),%rcx
mov    $0x1ed,%edx
call   1030 <slurm_xmalloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [158 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/src/common/xstring.c\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @xstrstrip(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i8* null, i8** %7
store i8 0, i8* %8
store i32 0, i32* %9
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i8* null, i8** %2
br label %86
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 34
br i1 %20, label %29, label %21
21: ; preds = %13
%22 = load i8*, i8** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 39
br i1 %28, label %29, label %37
29: ; preds = %21, %13
%30 = load i8*, i8** %3
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
store i8 %34, i8* %8
store i32 1, i32* %9
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %37
37: ; preds = %29, %21
%38 = load i32, i32* %4
store i32 %38, i32* %5
br label %39
39: ; preds = %60, %37
%40 = load i8*, i8** %3
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %63
46: ; preds = %39
%47 = load i32, i32* %9
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %60
49: ; preds = %46
%50 = load i8*, i8** %3
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = load i8, i8* %8
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %55, %57
br i1 %58, label %59, label %60
59: ; preds = %49
store i32 1, i32* %6
br label %63
60: ; preds = %49, %46
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %39
63: ; preds = %59, %39
%64 = load i32, i32* %6
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %81
66: ; preds = %63
%67 = load i32, i32* %4
%68 = load i32, i32* %5
%69 = sub nsw i32 %67, %68
%70 = add nsw i32 %69, 1
%71 = call i8* @slurm_xmalloc(i32 %70, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 493, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i8* %71, i8** %7
%72 = load i8*, i8** %7
%73 = load i8*, i8** %3
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i32, i32* %4
%78 = load i32, i32* %5
%79 = sub nsw i32 %77, %78
%80 = call i32 @memcpy(i8* %72, i8* %76, i32 %79)
br label %84
81: ; preds = %63
%82 = load i8*, i8** %3
%83 = call i8* @xstrdup(i8* %82)
store i8* %83, i8** %7
br label %84
84: ; preds = %81, %66
%85 = load i8*, i8** %7
store i8* %85, i8** %2
br label %86
86: ; preds = %84, %12
%87 = load i8*, i8** %2
ret i8* %87
}

LLVM IR (-O2):
@.str = [158 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/src/common/xstring.c\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @xstrstrip(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %36, label %3
3: ; preds = %1
%4 = load i8, i8* %0
switch i8 %4, label %9 [
i8 34, label %5
i8 39, label %5
]
5: ; preds = %3, %3
%6 = zext i8 %4 to i32
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
br label %9
9: ; preds = %3, %5
%10 = phi i8 [ %8, %5 ], [ %4, %3 ]
%11 = phi i32 [ %6, %5 ], [ 0, %3 ]
%12 = phi i1 [ true, %5 ], [ false, %3 ]
%13 = phi i32 [ 1, %5 ], [ 0, %3 ]
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = icmp eq i8 %10, 0
br i1 %16, label %34, label %17
17: ; preds = %9, %23
%18 = phi i64 [ %24, %23 ], [ %14, %9 ]
%19 = phi i8 [ %26, %23 ], [ %10, %9 ]
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %11, %20
%22 = select i1 %12, i1 %21, i1 false
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = add nuw i64 %18, 1
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %34, label %17
28: ; preds = %17
%29 = trunc i64 %18 to i32
%30 = sub nsw i32 %29, %13
%31 = add nsw i32 %30, 1
%32 = tail call i8* @slurm_xmalloc(i32 %31, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 493, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%33 = tail call i32 @memcpy(i8* %32, i8* %15, i32 %30)
br label %36
34: ; preds = %23, %9
%35 = tail call i8* @xstrdup(i8* %0)
br label %36
36: ; preds = %28, %34, %1
%37 = phi i8* [ null, %1 ], [ %32, %28 ], [ %35, %34 ]
ret i8* %37
}