#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*/ decode_html_entities_utf8(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *get_substring(char *, char *, char *, int);
int /*<<< orphan*/ set_series_folder(char *);
void parse_and_set_mangasee_series_folder(char *page, bool chapterPage) {
  char *seriesLocation = get_substring(page, "\"SeriesName\"", "\n", 26);
  char *seriesName;
  if (chapterPage) {
    seriesName = get_substring(seriesLocation, "value=\"", "\"", 26);
  } else {
    seriesName = get_substring(seriesLocation, ">", "<", 26);
  }
  decode_html_entities_utf8(seriesName, NULL);
  set_series_folder(seriesName);
  if (seriesName != NULL) {
    free(seriesName);
  }
  free(seriesLocation);
}


x86 assembly (clang, -O0):
<parse_and_set_mangasee_series_folder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
lea    0xeac(%rip),%rdx
mov    $0x1a,%ecx
call   1060 <get_substring@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     119e <parse_and_set_mangasee_series_folder+0x5e>
mov    -0x18(%rbp),%rdi
lea    0xe8b(%rip),%rsi
lea    0xe8a(%rip),%rdx
mov    $0x1a,%ecx
call   1060 <get_substring@plt>
mov    %rax,-0x20(%rbp)
jmp    11be <parse_and_set_mangasee_series_folder+0x7e>
mov    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
lea    0xe69(%rip),%rdx
mov    $0x1a,%ecx
call   1060 <get_substring@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <decode_html_entities_utf8@plt>
mov    -0x20(%rbp),%rdi
call   1050 <set_series_folder@plt>
cmpq   $0x0,-0x20(%rbp)
je     11e8 <parse_and_set_mangasee_series_folder+0xa8>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_and_set_mangasee_series_folder>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
lea    0xeb3(%rip),%rsi
lea    0xeb9(%rip),%rdx
mov    $0x1a,%ecx
call   1060 <get_substring@plt>
mov    %rax,%r14
test   %ebx,%ebx
je     1175 <parse_and_set_mangasee_series_folder+0x35>
lea    0xea3(%rip),%rsi
lea    0xea2(%rip),%rdx
jmp    1183 <parse_and_set_mangasee_series_folder+0x43>
lea    0xe9b(%rip),%rsi
lea    0xe96(%rip),%rdx
mov    %r14,%rdi
mov    $0x1a,%ecx
call   1060 <get_substring@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <decode_html_entities_utf8@plt>
mov    %rbx,%rdi
call   1050 <set_series_folder@plt>
test   %rbx,%rbx
je     11b2 <parse_and_set_mangasee_series_folder+0x72>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"\22SeriesName\22\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"value=\22\00"
@.str.3 = [2 x i8] c"\22\00"
@.str.4 = [2 x i8] c">\00"
@.str.5 = [2 x i8] c"<\00"
define void @parse_and_set_mangasee_series_folder(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i8* @get_substring(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 26)
store i8* %8, i8** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i8* @get_substring(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 26)
store i8* %13, i8** %6
br label %17
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = call i8* @get_substring(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 26)
store i8* %16, i8** %6
br label %17
17: ; preds = %14, %11
%18 = load i8*, i8** %6
%19 = call i32 @decode_html_entities_utf8(i8* %18, i32* null)
%20 = load i8*, i8** %6
%21 = call i32 @set_series_folder(i8* %20)
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %24, %17
%28 = load i8*, i8** %5
%29 = call i32 @free(i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"\22SeriesName\22\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [8 x i8] c"value=\22\00"
@.str.3 = [2 x i8] c"\22\00"
@.str.4 = [2 x i8] c">\00"
@.str.5 = [2 x i8] c"<\00"
define void @parse_and_set_mangasee_series_folder(i8* %0, i32 %1) {
%3 = tail call i8* @get_substring(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 26)
%4 = icmp eq i32 %1, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i8* @get_substring(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 26)
br label %9
7: ; preds = %2
%8 = tail call i8* @get_substring(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 26)
br label %9
9: ; preds = %7, %5
%10 = phi i8* [ %6, %5 ], [ %8, %7 ]
%11 = tail call i32 @decode_html_entities_utf8(i8* %10, i32* null)
%12 = tail call i32 @set_series_folder(i8* %10)
%13 = icmp eq i8* %10, null
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = tail call i32 @free(i8* %10)
br label %16
16: ; preds = %14, %9
%17 = tail call i32 @free(i8* %3)
ret void
}