#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 const *, int);
scalar_t__ safe_malloc(char *, int, int);
void extract_package_details(const char *src, char **pkg, char **version) {
  const char *end, *s1, *s2;
  end = src;
  while (*end)
    end++;
  s1 = end;
  while ((s1 >= src) && (*s1 != '/'))
    s1--;
  s2 = s1 - 1;
  while ((s2 >= src) && (*s2 != '/'))
    s2--;
  *pkg = (char *)safe_malloc(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/rc0/spill/refs/heads/master/spill.c",
      223, sizeof(char) * ((s1 - s2)));
  *version = (char *)safe_malloc(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/rc0/spill/refs/heads/master/spill.c",
      224, sizeof(char) * ((end - s1)));
  memcpy(*pkg, s2 + 1, s1 - s2 - 1);
  (*pkg)[s1 - s2 - 1] = 0;
  memcpy(*version, s1 + 1, end - s1);
  return;
}


x86 assembly (clang, -O0):
<extract_package_details>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     115a <extract_package_details+0x3a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <extract_package_details+0x1c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x31(%rbp)
jb     1185 <extract_package_details+0x65>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1195 <extract_package_details+0x75>
jmp    11a6 <extract_package_details+0x86>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    1162 <extract_package_details+0x42>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x32(%rbp)
jb     11d5 <extract_package_details+0xb5>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    11e5 <extract_package_details+0xc5>
jmp    11f6 <extract_package_details+0xd6>
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    11b2 <extract_package_details+0x92>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
shl    $0x0,%rax
mov    %eax,%edx
lea    0xdf2(%rip),%rdi
mov    $0xdf,%esi
call   1030 <safe_malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
shl    $0x0,%rax
mov    %eax,%edx
lea    0xdc6(%rip),%rdi
mov    $0xe0,%esi
call   1030 <safe_malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%rdx
sub    %rdx,%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_package_details>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
lea    -0x1(%rdi),%rbx
lea    -0x1(%rdi),%ebp
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1140 <extract_package_details+0x20>
cmp    %rdi,%rbx
mov    %rdx,(%rsp)
jb     1171 <extract_package_details+0x51>
add    $0xffffffffffffffff,%rbx
mov    %rbx,%rax
nopl   (%rax)
mov    %rax,%rbx
cmp    %rdi,%rax
jb     1171 <extract_package_details+0x51>
lea    -0x1(%rbx),%rax
cmpb   $0x2f,(%rbx)
jne    1160 <extract_package_details+0x40>
lea    -0x1(%rbx),%rax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %rax,%r13
mov    %rcx,%r12
cmp    %rdi,%rax
jb     119b <extract_package_details+0x7b>
lea    -0x1(%r13),%rax
lea    0x1(%r12),%rcx
cmpb   $0x2f,0x0(%r13)
jne    1180 <extract_package_details+0x60>
lea    0x1(%r12),%edx
lea    0xe59(%rip),%r14
mov    %r14,%rdi
mov    $0xdf,%esi
call   1030 <safe_malloc@plt>
mov    %rax,(%r15)
sub    %ebx,%ebp
mov    %r14,%rdi
mov    $0xe0,%esi
mov    %ebp,%edx
call   1030 <safe_malloc@plt>
mov    (%rsp),%r14
mov    %rax,(%r14)
mov    (%r15),%rdi
add    $0x1,%r13
mov    %r13,%rsi
mov    %r12d,%edx
call   1040 <memcpy@plt>
mov    (%r15),%rax
movb   $0x0,(%rax,%r12,1)
mov    (%r14),%rdi
add    $0x1,%rbx
mov    %rbx,%rsi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <memcpy@plt>

LLVM IR (-O0):
@.str = [126 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rc0/spill/refs/heads/master/spill.c\00"
define void @extract_package_details(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%10 = load i8*, i8** %4
store i8* %10, i8** %7
br label %11
11: ; preds = %15, %3
%12 = load i8*, i8** %7
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %7
br label %11
18: ; preds = %11
%19 = load i8*, i8** %7
store i8* %19, i8** %8
br label %20
20: ; preds = %31, %18
%21 = load i8*, i8** %8
%22 = load i8*, i8** %4
%23 = icmp uge i8* %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i8*, i8** %8
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 47
br label %29
29: ; preds = %24, %20
%30 = phi i1 [ false, %20 ], [ %28, %24 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i32 -1
store i8* %33, i8** %8
br label %20
34: ; preds = %29
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i64 -1
store i8* %36, i8** %9
br label %37
37: ; preds = %48, %34
%38 = load i8*, i8** %9
%39 = load i8*, i8** %4
%40 = icmp uge i8* %38, %39
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i8*, i8** %9
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 47
br label %46
46: ; preds = %41, %37
%47 = phi i1 [ false, %37 ], [ %45, %41 ]
br i1 %47, label %48, label %51
48: ; preds = %46
%49 = load i8*, i8** %9
%50 = getelementptr inbounds i8, i8* %49, i32 -1
store i8* %50, i8** %9
br label %37
51: ; preds = %46
%52 = load i8*, i8** %8
%53 = load i8*, i8** %9
%54 = ptrtoint i8* %52 to i64
%55 = ptrtoint i8* %53 to i64
%56 = sub i64 %54, %55
%57 = mul i64 1, %56
%58 = trunc i64 %57 to i32
%59 = call i64 @safe_malloc(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 223, i32 %58)
%60 = inttoptr i64 %59 to i8*
%61 = load i8**, i8*** %5
store i8* %60, i8** %61
%62 = load i8*, i8** %7
%63 = load i8*, i8** %8
%64 = ptrtoint i8* %62 to i64
%65 = ptrtoint i8* %63 to i64
%66 = sub i64 %64, %65
%67 = mul i64 1, %66
%68 = trunc i64 %67 to i32
%69 = call i64 @safe_malloc(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 224, i32 %68)
%70 = inttoptr i64 %69 to i8*
%71 = load i8**, i8*** %6
store i8* %70, i8** %71
%72 = load i8**, i8*** %5
%73 = load i8*, i8** %72
%74 = load i8*, i8** %9
%75 = getelementptr inbounds i8, i8* %74, i64 1
%76 = load i8*, i8** %8
%77 = load i8*, i8** %9
%78 = ptrtoint i8* %76 to i64
%79 = ptrtoint i8* %77 to i64
%80 = sub i64 %78, %79
%81 = sub nsw i64 %80, 1
%82 = trunc i64 %81 to i32
%83 = call i32 @memcpy(i8* %73, i8* %75, i32 %82)
%84 = load i8**, i8*** %5
%85 = load i8*, i8** %84
%86 = load i8*, i8** %8
%87 = load i8*, i8** %9
%88 = ptrtoint i8* %86 to i64
%89 = ptrtoint i8* %87 to i64
%90 = sub i64 %88, %89
%91 = sub nsw i64 %90, 1
%92 = getelementptr inbounds i8, i8* %85, i64 %91
store i8 0, i8* %92
%93 = load i8**, i8*** %6
%94 = load i8*, i8** %93
%95 = load i8*, i8** %8
%96 = getelementptr inbounds i8, i8* %95, i64 1
%97 = load i8*, i8** %7
%98 = load i8*, i8** %8
%99 = ptrtoint i8* %97 to i64
%100 = ptrtoint i8* %98 to i64
%101 = sub i64 %99, %100
%102 = trunc i64 %101 to i32
%103 = call i32 @memcpy(i8* %94, i8* %96, i32 %102)
ret void
}

LLVM IR (-O2):
@.str = [126 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rc0/spill/refs/heads/master/spill.c\00"
define void @extract_package_details(i8* %0, i8** nocapture %1, i8** nocapture %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i8* [ %0, %3 ], [ %8, %4 ]
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %7, label %9, label %4
9: ; preds = %4
%10 = icmp ult i8* %5, %0
br i1 %10, label %18, label %11
11: ; preds = %9, %15
%12 = phi i8* [ %13, %15 ], [ %5, %9 ]
%13 = getelementptr inbounds i8, i8* %12, i64 -1
%14 = icmp ult i8* %13, %0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load i8, i8* %13
%17 = icmp eq i8 %16, 47
br i1 %17, label %18, label %11
18: ; preds = %15, %11, %9
%19 = phi i8* [ %5, %9 ], [ %13, %11 ], [ %13, %15 ]
br label %20
20: ; preds = %24, %18
%21 = phi i8* [ %19, %18 ], [ %22, %24 ]
%22 = getelementptr inbounds i8, i8* %21, i64 -1
%23 = icmp ult i8* %22, %0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = load i8, i8* %22
%26 = icmp eq i8 %25, 47
br i1 %26, label %27, label %20
27: ; preds = %20, %24
%28 = ptrtoint i8* %19 to i64
%29 = ptrtoint i8* %22 to i64
%30 = sub i64 %28, %29
%31 = trunc i64 %30 to i32
%32 = tail call i64 @safe_malloc(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 223, i32 %31)
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %1
%34 = ptrtoint i8* %5 to i64
%35 = sub i64 %34, %28
%36 = trunc i64 %35 to i32
%37 = tail call i64 @safe_malloc(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 224, i32 %36)
%38 = inttoptr i64 %37 to i8*
store i8* %38, i8** %2
%39 = load i8*, i8** %1
%40 = add nsw i64 %30, -1
%41 = trunc i64 %40 to i32
%42 = tail call i32 @memcpy(i8* %39, i8* %21, i32 %41)
%43 = load i8*, i8** %1
%44 = getelementptr inbounds i8, i8* %43, i64 %40
store i8 0, i8* %44
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %19, i64 1
%47 = tail call i32 @memcpy(i8* %45, i8* %46, i32 %36)
ret void
}