#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 */
long atol(char *);
char *calloc(int, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcspn(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, scalar_t__);
char *strstr(char *, char *);
char *strtok(char *, char *);
long parse_results(char *recvbuf) {
  extern int oflag, vflag;
  char *errorLine;
  char *ptr;
  char *buf;
  char copy[25];
  int i = 0, j = 0;
  errorLine = calloc(1024, sizeof(char));
  strncat(errorLine, recvbuf, (strcspn(recvbuf, "\n") - 1));
  if (vflag)
    printf("(verbose) Status line from server: \"%s\"\n", errorLine);
  if (strstr(errorLine, "200") == NULL) {
    printf("Error! Received \"%s\" from server!\n", errorLine);
    return (0);
  }
  ptr = strstr(recvbuf, "Results <b>");
  if (ptr != NULL) {
    buf = strtok(ptr, "Results <b>");
    buf = strtok(NULL, " </b>");
    buf = strtok(NULL, " </b>");
    buf = strtok(NULL, ">");
    buf = strtok(NULL, ">");
    buf = strtok(NULL, "<");
    if (buf != 0) {
      j = 0;
      for (i = 0; i < strlen(buf); i++) {
        if (buf[i] != ',') {
          copy[j] = buf[i];
          j++;
        }
      }
      copy[j++] = '\0';
      return (atol(copy));
    } else
      return (0);
  } else {
    ptr = strstr(recvbuf, "of about <b>");
    if (ptr != NULL) {
      buf = strtok(ptr, "of about <b>");
      return (atol(buf));
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<parse_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
mov    $0x400,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1060 <strcspn@plt>
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1050 <strncat@plt>
mov    0x2e00(%rip),%rax
cmpl   $0x0,(%rax)
je     1201 <parse_results+0x81>
mov    -0x18(%rbp),%rsi
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
jne    1238 <parse_results+0xb8>
mov    -0x18(%rbp),%rsi
lea    0xe07(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    13cb <parse_results+0x24b>
mov    -0x10(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1379 <parse_results+0x1f9>
mov    -0x20(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xde6(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd2(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc2(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdae(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd9c(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     136c <parse_results+0x1ec>
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    1348 <parse_results+0x1c8>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
je     1335 <parse_results+0x1b5>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x58(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    133a <parse_results+0x1ba>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12e8 <parse_results+0x168>
mov    -0x58(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x58(%rbp)
cltq
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
call   1080 <atol@plt>
mov    %rax,-0x8(%rbp)
jmp    13cb <parse_results+0x24b>
movq   $0x0,-0x8(%rbp)
jmp    13cb <parse_results+0x24b>
mov    -0x10(%rbp),%rdi
lea    0xce0(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     13be <parse_results+0x23e>
mov    -0x20(%rbp),%rdi
lea    0xcc1(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <atol@plt>
mov    %rax,-0x8(%rbp)
jmp    13cb <parse_results+0x24b>
jmp    13c3 <parse_results+0x243>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_results>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
mov    $0x400,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcspn@plt>
lea    -0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strncat@plt>
mov    0x2e25(%rip),%rax
cmpl   $0x0,(%rax)
je     11d7 <parse_results+0x57>
lea    0xe31(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strstr@plt>
test   %rax,%rax
je     12a9 <parse_results+0x129>
lea    0xe5a(%rip),%rsi
mov    %r14,%rdi
call   10a0 <strstr@plt>
test   %rax,%rax
je     12dc <parse_results+0x15c>
lea    0xe42(%rip),%rsi
mov    %rax,%rdi
call   1090 <strtok@plt>
lea    0xe3f(%rip),%rbx
xor    %r14d,%r14d
xor    %edi,%edi
mov    %rbx,%rsi
call   1090 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1090 <strtok@plt>
lea    0xe25(%rip),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1090 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1090 <strtok@plt>
lea    0xe0c(%rip),%rsi
xor    %edi,%edi
call   1090 <strtok@plt>
test   %rax,%rax
je     12cf <parse_results+0x14f>
mov    %rax,%r15
mov    %rax,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    12bd <parse_results+0x13d>
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    1293 <parse_results+0x113>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    12bd <parse_results+0x13d>
movzbl (%r15,%rbx,1),%eax
cmp    $0x2c,%al
je     1280 <parse_results+0x100>
movslq %r14d,%r14
mov    %al,(%rsp,%r14,1)
add    $0x1,%r14d
jmp    1280 <parse_results+0x100>
lea    0xd7d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %r14d,%r14d
jmp    12cf <parse_results+0x14f>
movslq %r14d,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1080 <atol@plt>
mov    %rax,%r14
mov    %r14,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd81(%rip),%rsi
mov    %r14,%rdi
call   10a0 <strstr@plt>
test   %rax,%rax
je     12b8 <parse_results+0x138>
lea    0xd6d(%rip),%rsi
mov    %rax,%rdi
call   1090 <strtok@plt>
mov    %rax,%rdi
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <atol@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@vflag = external global i32
@.str.1 = [41 x i8] c"(verbose) Status line from server: \22%s\22\0A\00"
@.str.2 = [4 x i8] c"200\00"
@.str.3 = [35 x i8] c"Error! Received \22%s\22 from server!\0A\00"
@.str.4 = [12 x i8] c"Results <b>\00"
@.str.5 = [6 x i8] c" </b>\00"
@.str.6 = [2 x i8] c">\00"
@.str.7 = [2 x i8] c"<\00"
@.str.8 = [13 x i8] c"of about <b>\00"
define i64 @parse_results(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [25 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %8
store i32 0, i32* %9
%10 = call i8* @calloc(i32 1024, i32 1)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i64 @strcspn(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = sub nsw i64 %14, 1
%16 = call i32 @strncat(i8* %11, i8* %12, i64 %15)
%17 = load i32, i32* @vflag
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %1
%20 = load i8*, i8** %4
%21 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %1
%23 = load i8*, i8** %4
%24 = call i8* @strstr(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i8*, i8** %4
%28 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %27)
store i64 0, i64* %2
br label %93
29: ; preds = %22
%30 = load i8*, i8** %3
%31 = call i8* @strstr(i8* %30, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i8* %31, i8** %5
%32 = load i8*, i8** %5
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %81
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = call i8* @strtok(i8* %35, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i8* %36, i8** %6
%37 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i8* %37, i8** %6
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i8* %38, i8** %6
%39 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %39, i8** %6
%40 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %40, i8** %6
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %41, i8** %6
%42 = load i8*, i8** %6
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %80
44: ; preds = %34
store i32 0, i32* %9
store i32 0, i32* %8
br label %45
45: ; preds = %70, %44
%46 = load i32, i32* %8
%47 = load i8*, i8** %6
%48 = call i32 @strlen(i8* %47)
%49 = icmp slt i32 %46, %48
br i1 %49, label %50, label %73
50: ; preds = %45
%51 = load i8*, i8** %6
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 44
br i1 %57, label %58, label %69
58: ; preds = %50
%59 = load i8*, i8** %6
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 %65
store i8 %63, i8* %66
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %69
69: ; preds = %58, %50
br label %70
70: ; preds = %69
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
store i32 %72, i32* %8
br label %45
73: ; preds = %45
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 %76
store i8 0, i8* %77
%78 = getelementptr inbounds [25 x i8], [25 x i8]* %7, i64 0, i64 0
%79 = call i64 @atol(i8* %78)
store i64 %79, i64* %2
br label %93
80: ; preds = %34
store i64 0, i64* %2
br label %93
81: ; preds = %29
%82 = load i8*, i8** %3
%83 = call i8* @strstr(i8* %82, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
store i8* %83, i8** %5
%84 = load i8*, i8** %5
%85 = icmp ne i8* %84, null
br i1 %85, label %86, label %91
86: ; preds = %81
%87 = load i8*, i8** %5
%88 = call i8* @strtok(i8* %87, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
store i8* %88, i8** %6
%89 = load i8*, i8** %6
%90 = call i64 @atol(i8* %89)
store i64 %90, i64* %2
br label %93
91: ; preds = %81
br label %92
92: ; preds = %91
store i64 0, i64* %2
br label %93
93: ; preds = %92, %86, %80, %73, %26
%94 = load i64, i64* %2
ret i64 %94
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@vflag = external global i32
@.str.1 = [41 x i8] c"(verbose) Status line from server: \22%s\22\0A\00"
@.str.2 = [4 x i8] c"200\00"
@.str.3 = [35 x i8] c"Error! Received \22%s\22 from server!\0A\00"
@.str.4 = [12 x i8] c"Results <b>\00"
@.str.5 = [6 x i8] c" </b>\00"
@.str.6 = [2 x i8] c">\00"
@.str.7 = [2 x i8] c"<\00"
@.str.8 = [13 x i8] c"of about <b>\00"
define i64 @parse_results(i8* %0) {
%2 = alloca [25 x i8]
%3 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%4 = tail call dereferenceable_or_null(1024) i8* @calloc(i32 1024, i32 1)
%5 = tail call i64 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = add nsw i64 %5, -1
%7 = tail call i32 @strncat(i8* %4, i8* %0, i64 %6)
%8 = load i32, i32* @vflag
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %12
12: ; preds = %10, %1
%13 = tail call i8* @strstr(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %58
17: ; preds = %12
%18 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %52, label %20
20: ; preds = %17
%21 = tail call i8* @strtok(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%23 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%24 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%25 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%26 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%27 = icmp eq i8* %26, null
br i1 %27, label %58, label %28
28: ; preds = %20
%29 = tail call i32 @strlen(i8* %26)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %47
31: ; preds = %28, %41
%32 = phi i64 [ %43, %41 ], [ 0, %28 ]
%33 = phi i32 [ %42, %41 ], [ 0, %28 ]
%34 = getelementptr inbounds i8, i8* %26, i64 %32
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 44
br i1 %36, label %41, label %37
37: ; preds = %31
%38 = sext i32 %33 to i64
%39 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 %38
store i8 %35, i8* %39
%40 = add nsw i32 %33, 1
br label %41
41: ; preds = %31, %37
%42 = phi i32 [ %40, %37 ], [ %33, %31 ]
%43 = add nuw nsw i64 %32, 1
%44 = tail call i32 @strlen(i8* %26)
%45 = sext i32 %44 to i64
%46 = icmp slt i64 %43, %45
br i1 %46, label %31, label %47
47: ; preds = %41, %28
%48 = phi i32 [ 0, %28 ], [ %42, %41 ]
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 %49
store i8 0, i8* %50
%51 = call i64 @atol(i8* %3)
br label %58
52: ; preds = %17
%53 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%54 = icmp eq i8* %53, null
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = tail call i8* @strtok(i8* %53, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%57 = tail call i64 @atol(i8* %56)
br label %58
58: ; preds = %52, %20, %55, %47, %15
%59 = phi i64 [ 0, %15 ], [ %51, %47 ], [ %57, %55 ], [ 0, %20 ], [ 0, %52 ]
ret i64 %59
}