#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
char **continuous_substring(char *, char *, char *);
int /*<<< orphan*/ pointer_array_free(void **);
size_t run_html_decode_on_strings(char **);
int /*<<< orphan*/ write_string_array_to_file(char *, char **, char *, char *,
                                              int /*<<< orphan*/ *);
void mangasee_info_search_and_write(char *infoToParse, char *substringStart,
                                    char *substringEnd, char *single,
                                    char *plural, FILE *saveTo) {
  char **allInfo =
      continuous_substring(infoToParse, substringStart, substringEnd);
  size_t amountOfInfo = run_html_decode_on_strings(allInfo);
  char *initial = plural;
  if (amountOfInfo == 1) {
    initial = single;
  }
  if (amountOfInfo > 0) {
    write_string_array_to_file(initial, allInfo, ", ", "\n", saveTo);
  }
  pointer_array_free((void **)allInfo);
}


x86 assembly (clang, -O0):
<mangasee_info_search_and_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <continuous_substring@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <run_html_decode_on_strings@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x1,-0x40(%rbp)
jne    119d <mangasee_info_search_and_write+0x5d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
jbe    11c7 <mangasee_info_search_and_write+0x87>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%r8
lea    0xe45(%rip),%rdx
lea    0xe41(%rip),%rcx
call   1040 <write_string_array_to_file@plt>
mov    -0x38(%rbp),%rdi
call   1050 <pointer_array_free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mangasee_info_search_and_write>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
call   1060 <continuous_substring@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <run_html_decode_on_strings@plt>
test   %rax,%rax
je     118a <mangasee_info_search_and_write+0x4a>
cmp    $0x1,%rax
cmove  %r12,%r15
lea    0xe8b(%rip),%rdx
lea    0xe87(%rip),%rcx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%r8
call   1040 <write_string_array_to_file@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <pointer_array_free@plt>

LLVM IR (-O0):
@.str = [3 x i8] c", \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @mangasee_info_search_and_write(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i8**
%14 = alloca i64
%15 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32* %5, i32** %12
%16 = load i8*, i8** %7
%17 = load i8*, i8** %8
%18 = load i8*, i8** %9
%19 = call i8** @continuous_substring(i8* %16, i8* %17, i8* %18)
store i8** %19, i8*** %13
%20 = load i8**, i8*** %13
%21 = call i64 @run_html_decode_on_strings(i8** %20)
store i64 %21, i64* %14
%22 = load i8*, i8** %11
store i8* %22, i8** %15
%23 = load i64, i64* %14
%24 = icmp eq i64 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %6
%26 = load i8*, i8** %10
store i8* %26, i8** %15
br label %27
27: ; preds = %25, %6
%28 = load i64, i64* %14
%29 = icmp ugt i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8*, i8** %15
%32 = load i8**, i8*** %13
%33 = load i32*, i32** %12
%34 = call i32 @write_string_array_to_file(i8* %31, i8** %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %33)
br label %35
35: ; preds = %30, %27
%36 = load i8**, i8*** %13
%37 = call i32 @pointer_array_free(i8** %36)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c", \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @mangasee_info_search_and_write(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32* %5) {
%7 = tail call i8** @continuous_substring(i8* %0, i8* %1, i8* %2)
%8 = tail call i64 @run_html_decode_on_strings(i8** %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = icmp eq i64 %8, 1
%12 = select i1 %11, i8* %3, i8* %4
%13 = tail call i32 @write_string_array_to_file(i8* %12, i8** %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %14
14: ; preds = %10, %6
%15 = tail call i32 @pointer_array_free(i8** %7)
ret void
}