#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
scalar_t__ atoi(char *);
int /*<<< orphan*/ free(char *);
char *match(char *, char *);
int /*<<< orphan*/ printf(char *, char *, int);
size_t strlen(char *);
pid_t parse_p(char *string, size_t *count) {
  char *result;
  pid_t p;
  *count = 0;
  if (string == 0)
    return 0;
  if (count == 0)
    return 0;
  result = match(string, "^[0-9]{1,}");
  if (result == 0) {
    printf("%s:%d:Could not match pid\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/myYearbook/playr/refs/heads/master/src/"
           "parseline.c",
           586);
    return 0;
  }
  p = (pid_t)atoi(result);
  if (p == 0)
    printf("%s:%d:Could not parse pid\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/myYearbook/playr/refs/heads/master/src/"
           "parseline.c",
           592);
  *count = strlen(result);
  free(result);
  return p;
}


x86 assembly (clang, -O0):
<parse_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
jne    1183 <parse_p+0x33>
movq   $0x0,-0x8(%rbp)
jmp    1233 <parse_p+0xe3>
cmpq   $0x0,-0x18(%rbp)
jne    119b <parse_p+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    1233 <parse_p+0xe3>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1060 <match@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11df <parse_p+0x8f>
lea    0xe4a(%rip),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x24a,%edx
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1233 <parse_p+0xe3>
mov    -0x20(%rbp),%rdi
call   1070 <atoi@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120f <parse_p+0xbf>
lea    0xeb5(%rip),%rdi
lea    0xe21(%rip),%rsi
mov    $0x250,%edx
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_p>:
push   %r15
push   %r14
push   %rbx
movq   $0x0,(%rsi)
test   %rdi,%rdi
je     11cd <parse_p+0x7d>
mov    %rsi,%r14
lea    0xe95(%rip),%rsi
call   1060 <match@plt>
test   %rax,%rax
je     11b5 <parse_p+0x65>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11a0 <parse_p+0x50>
lea    0xf24(%rip),%rdi
lea    0xe90(%rip),%rsi
mov    $0x250,%edx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,(%r14)
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11d0 <parse_p+0x80>
lea    0xe4f(%rip),%rdi
lea    0xe63(%rip),%rsi
mov    $0x24a,%edx
call   1050 <printf@plt>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"^[0-9]{1,}\00"
@.str.1 = [27 x i8] c"%s:%d:Could not match pid\0A\00"
@.str.2 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/myYearbook/playr/refs/heads/master/src/parseline.c\00"
@.str.3 = [27 x i8] c"%s:%d:Could not parse pid\0A\00"
define i64 @parse_p(i8* %0, i64* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = load i64*, i64** %5
store i64 0, i64* %8
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i64 0, i64* %3
br label %37
12: ; preds = %2
%13 = load i64*, i64** %5
%14 = icmp eq i64* %13, null
br i1 %14, label %15, label %16
15: ; preds = %12
store i64 0, i64* %3
br label %37
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call i8* @match(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 586)
store i64 0, i64* %3
br label %37
23: ; preds = %16
%24 = load i8*, i8** %6
%25 = call i64 @atoi(i8* %24)
store i64 %25, i64* %7
%26 = load i64, i64* %7
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 592)
br label %30
30: ; preds = %28, %23
%31 = load i8*, i8** %6
%32 = call i64 @strlen(i8* %31)
%33 = load i64*, i64** %5
store i64 %32, i64* %33
%34 = load i8*, i8** %6
%35 = call i32 @free(i8* %34)
%36 = load i64, i64* %7
store i64 %36, i64* %3
br label %37
37: ; preds = %30, %21, %15, %11
%38 = load i64, i64* %3
ret i64 %38
}

LLVM IR (-O2):
@.str = [11 x i8] c"^[0-9]{1,}\00"
@.str.1 = [27 x i8] c"%s:%d:Could not match pid\0A\00"
@.str.2 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/myYearbook/playr/refs/heads/master/src/parseline.c\00"
@.str.3 = [27 x i8] c"%s:%d:Could not parse pid\0A\00"
define i64 @parse_p(i8* %0, i64* nocapture writeonly %1) {
store i64 0, i64* %1
%3 = icmp eq i8* %0, null
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = tail call i8* @match(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 586)
br label %17
9: ; preds = %4
%10 = tail call i64 @atoi(i8* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.2, i64 0, i64 0), i32 592)
br label %14
14: ; preds = %12, %9
%15 = tail call i64 @strlen(i8* %5)
store i64 %15, i64* %1
%16 = tail call i32 @free(i8* %5)
br label %17
17: ; preds = %2, %14, %7
%18 = phi i64 [ 0, %7 ], [ %10, %14 ], [ 0, %2 ]
ret i64 %18
}