#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*/ _DEBUG(int, char *, int, char *);
scalar_t__ isalnum(int);
scalar_t__ memory_allocation(int);
int /*<<< orphan*/ stripBadChar(char *, char *);
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
char *getTitle(char *titleString) {
  int i;
  char *result;
  int count = 0;
  int j = 0;
  int first = 0;
  if ((titleString == NULL) || (strlen(titleString) == 0))
    return NULL;
  if (strstr(titleString, "StreamTitle") == NULL) {
    _DEBUG(851,
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/mcoulont/cpige_month/refs/heads/master/"
           "cpige.c",
           1,
           "Received a stream with metadata enabled, but at metaint interval, "
           "we only received binary crap. Please fix your stream.");
    return NULL;
  }
  result = (char *)memory_allocation(strlen(titleString) + 1);
  for (i = 0; i < strlen(titleString); i++) {
    if (count == 1) {
      if (titleString[(i + 1)] != ';') {
        if (first == 0) {
          if ((isalnum((int)titleString[i])) && (titleString[i] != ' ')) {
            result[j++] = titleString[i];
            first++;
          }
        } else {
          result[j++] = titleString[i];
        }
      }
    }
    if (titleString[i] == '\'') {
      if (count == 0)
        count++;
      else if (titleString[(i + 1)] == ';')
        break;
    }
  }
  result[j] = '\0';
  stripBadChar(result, result);
  return result;
}


x86 assembly (clang, -O0):
<getTitle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119e <getTitle+0x3e>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    11ab <getTitle+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    1369 <getTitle+0x209>
mov    -0x10(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
jne    11ef <getTitle+0x8f>
mov    $0x353,%edi
lea    0xe3b(%rip),%rsi
mov    $0x1,%edx
lea    0xeb8(%rip),%rcx
call   1060 <_DEBUG@plt>
movq   $0x0,-0x8(%rbp)
jmp    1369 <getTitle+0x209>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1030 <memory_allocation@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    1348 <getTitle+0x1e8>
cmpl   $0x1,-0x24(%rbp)
jne    12df <getTitle+0x17f>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
je     12da <getTitle+0x17a>
cmpl   $0x0,-0x2c(%rbp)
jne    12b5 <getTitle+0x155>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%rax
je     12b0 <getTitle+0x150>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     12b0 <getTitle+0x150>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12d5 <getTitle+0x175>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    12da <getTitle+0x17a>
jmp    12df <getTitle+0x17f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
jne    1335 <getTitle+0x1d5>
cmpl   $0x0,-0x24(%rbp)
jne    130c <getTitle+0x1ac>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1330 <getTitle+0x1d0>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
jne    132b <getTitle+0x1cb>
jmp    1348 <getTitle+0x1e8>
jmp    1330 <getTitle+0x1d0>
jmp    1335 <getTitle+0x1d5>
jmp    133a <getTitle+0x1da>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120d <getTitle+0xad>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <stripBadChar@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTitle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1258 <getTitle+0xf8>
mov    %rdi,%r13
call   1040 <strlen@plt>
test   %eax,%eax
je     1258 <getTitle+0xf8>
lea    0xe75(%rip),%rsi
mov    %r13,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     125d <getTitle+0xfd>
mov    %r13,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1030 <memory_allocation@plt>
mov    %rax,%r14
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    127f <getTitle+0x11f>
xor    %ebp,%ebp
xor    %r12d,%r12d
movl   $0x0,0x4(%rsp)
xor    %ebx,%ebx
jmp    11ed <getTitle+0x8d>
mov    %ebx,%r15d
add    $0x1,%rbp
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
mov    %r15d,%ebx
cmp    %rax,%rbp
jge    1287 <getTitle+0x127>
cmp    $0x1,%ebx
jne    1220 <getTitle+0xc0>
cmpb   $0x3b,0x1(%r13,%rbp,1)
je     1220 <getTitle+0xc0>
movzbl 0x0(%r13,%rbp,1),%eax
test   %r12d,%r12d
je     123c <getTitle+0xdc>
mov    0x4(%rsp),%edx
movslq %edx,%rcx
add    $0x1,%edx
mov    %edx,0x4(%rsp)
mov    %al,(%r14,%rcx,1)
mov    $0x1,%r12d
nopl   (%rax)
cmpb   $0x27,0x0(%r13,%rbp,1)
jne    11d0 <getTitle+0x70>
mov    $0x1,%r15d
test   %ebx,%ebx
je     11d3 <getTitle+0x73>
cmpb   $0x3b,0x1(%r13,%rbp,1)
jne    11d3 <getTitle+0x73>
jmp    1287 <getTitle+0x127>
movsbl %al,%edi
call   1050 <isalnum@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     1220 <getTitle+0xc0>
movzbl 0x0(%r13,%rbp,1),%eax
cmp    $0x20,%al
jne    1205 <getTitle+0xa5>
jmp    1220 <getTitle+0xc0>
xor    %r14d,%r14d
jmp    129c <getTitle+0x13c>
lea    0xda8(%rip),%rsi
lea    0xe2a(%rip),%rcx
mov    $0x353,%edi
mov    $0x1,%edx
call   1060 <_DEBUG@plt>
xor    %r14d,%r14d
jmp    129c <getTitle+0x13c>
movl   $0x0,0x4(%rsp)
movslq 0x4(%rsp),%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
mov    %r14,%rsi
call   1070 <stripBadChar@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"StreamTitle\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mcoulont/cpige_month/refs/heads/master/cpige.c\00"
@.str.2 = [120 x i8] c"Received a stream with metadata enabled, but at metaint interval, we only received binary crap. Please fix your stream.\00"
define i8* @getTitle(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i8*, i8** %3
%10 = icmp eq i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11, %1
store i8* null, i8** %2
br label %131
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i32* @strstr(i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @_DEBUG(i32 851, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %2
br label %131
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = call i32 @strlen(i8* %23)
%25 = add nsw i32 %24, 1
%26 = call i64 @memory_allocation(i32 %25)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %5
store i32 0, i32* %4
br label %28
28: ; preds = %119, %22
%29 = load i32, i32* %4
%30 = load i8*, i8** %3
%31 = call i32 @strlen(i8* %30)
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %122
33: ; preds = %28
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %92
36: ; preds = %33
%37 = load i8*, i8** %3
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 59
br i1 %44, label %45, label %91
45: ; preds = %36
%46 = load i32, i32* %8
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %79
48: ; preds = %45
%49 = load i8*, i8** %3
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = call i64 @isalnum(i32 %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %78
57: ; preds = %48
%58 = load i8*, i8** %3
%59 = load i32, i32* %4
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 32
br i1 %64, label %65, label %78
65: ; preds = %57
%66 = load i8*, i8** %3
%67 = load i32, i32* %4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
%70 = load i8, i8* %69
%71 = load i8*, i8** %5
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
store i32 %73, i32* %7
%74 = sext i32 %72 to i64
%75 = getelementptr inbounds i8, i8* %71, i64 %74
store i8 %70, i8* %75
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
br label %78
78: ; preds = %65, %57, %48
br label %90
79: ; preds = %45
%80 = load i8*, i8** %3
%81 = load i32, i32* %4
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
%84 = load i8, i8* %83
%85 = load i8*, i8** %5
%86 = load i32, i32* %7
%87 = add nsw i32 %86, 1
store i32 %87, i32* %7
%88 = sext i32 %86 to i64
%89 = getelementptr inbounds i8, i8* %85, i64 %88
store i8 %84, i8* %89
br label %90
90: ; preds = %79, %78
br label %91
91: ; preds = %90, %36
br label %92
92: ; preds = %91, %33
%93 = load i8*, i8** %3
%94 = load i32, i32* %4
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %93, i64 %95
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 39
br i1 %99, label %100, label %118
100: ; preds = %92
%101 = load i32, i32* %6
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %100
%104 = load i32, i32* %6
%105 = add nsw i32 %104, 1
store i32 %105, i32* %6
br label %117
106: ; preds = %100
%107 = load i8*, i8** %3
%108 = load i32, i32* %4
%109 = add nsw i32 %108, 1
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %107, i64 %110
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 59
br i1 %114, label %115, label %116
115: ; preds = %106
br label %122
116: ; preds = %106
br label %117
117: ; preds = %116, %103
br label %118
118: ; preds = %117, %92
br label %119
119: ; preds = %118
%120 = load i32, i32* %4
%121 = add nsw i32 %120, 1
store i32 %121, i32* %4
br label %28
122: ; preds = %115, %28
%123 = load i8*, i8** %5
%124 = load i32, i32* %7
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8, i8* %123, i64 %125
store i8 0, i8* %126
%127 = load i8*, i8** %5
%128 = load i8*, i8** %5
%129 = call i32 @stripBadChar(i8* %127, i8* %128)
%130 = load i8*, i8** %5
store i8* %130, i8** %2
br label %131
131: ; preds = %122, %20, %15
%132 = load i8*, i8** %2
ret i8* %132
}

LLVM IR (-O2):
@.str = [12 x i8] c"StreamTitle\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mcoulont/cpige_month/refs/heads/master/cpige.c\00"
@.str.2 = [120 x i8] c"Received a stream with metadata enabled, but at metaint interval, we only received binary crap. Please fix your stream.\00"
define i8* @getTitle(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %69, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %69, label %6
6: ; preds = %3
%7 = tail call i32* @strstr(i8* %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @_DEBUG(i32 851, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.2, i64 0, i64 0))
br label %69
11: ; preds = %6
%12 = tail call i32 @strlen(i8* %0)
%13 = add nsw i32 %12, 1
%14 = tail call i64 @memory_allocation(i32 %13)
%15 = inttoptr i64 %14 to i8*
%16 = tail call i32 @strlen(i8* %0)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %64
18: ; preds = %11, %58
%19 = phi i64 [ %60, %58 ], [ 0, %11 ]
%20 = phi i32 [ %47, %58 ], [ 0, %11 ]
%21 = phi i32 [ %46, %58 ], [ 0, %11 ]
%22 = phi i32 [ %59, %58 ], [ 0, %11 ]
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %45
24: ; preds = %18
%25 = add nuw nsw i64 %19, 1
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 59
br i1 %28, label %45, label %29
29: ; preds = %24
%30 = icmp eq i32 %20, 0
%31 = getelementptr inbounds i8, i8* %0, i64 %19
%32 = load i8, i8* %31
br i1 %30, label %33, label %40
33: ; preds = %29
%34 = sext i8 %32 to i32
%35 = tail call i64 @isalnum(i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %45, label %37
37: ; preds = %33
%38 = load i8, i8* %31
%39 = icmp eq i8 %38, 32
br i1 %39, label %45, label %40
40: ; preds = %29, %37
%41 = phi i8 [ %38, %37 ], [ %32, %29 ]
%42 = add nsw i32 %21, 1
%43 = sext i32 %21 to i64
%44 = getelementptr inbounds i8, i8* %15, i64 %43
store i8 %41, i8* %44
br label %45
45: ; preds = %40, %24, %33, %37, %18
%46 = phi i32 [ %21, %37 ], [ %21, %33 ], [ %21, %24 ], [ %21, %18 ], [ %42, %40 ]
%47 = phi i32 [ 0, %37 ], [ 0, %33 ], [ %20, %24 ], [ %20, %18 ], [ 1, %40 ]
%48 = getelementptr inbounds i8, i8* %0, i64 %19
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 39
br i1 %50, label %51, label %58
51: ; preds = %45
%52 = icmp eq i32 %22, 0
br i1 %52, label %58, label %53
53: ; preds = %51
%54 = add nuw nsw i64 %19, 1
%55 = getelementptr inbounds i8, i8* %0, i64 %54
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 59
br i1 %57, label %64, label %58
58: ; preds = %51, %45, %53
%59 = phi i32 [ 1, %53 ], [ %22, %45 ], [ 1, %51 ]
%60 = add nuw nsw i64 %19, 1
%61 = tail call i32 @strlen(i8* %0)
%62 = sext i32 %61 to i64
%63 = icmp slt i64 %60, %62
br i1 %63, label %18, label %64
64: ; preds = %58, %53, %11
%65 = phi i32 [ 0, %11 ], [ %46, %53 ], [ %46, %58 ]
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %15, i64 %66
store i8 0, i8* %67
%68 = tail call i32 @stripBadChar(i8* %15, i8* %15)
br label %69
69: ; preds = %1, %3, %64, %9
%70 = phi i8* [ null, %9 ], [ %15, %64 ], [ null, %3 ], [ null, %1 ]
ret i8* %70
}