#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 */
char *create_substring(char *, char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
scalar_t__ strlen(char *);
char *strstr(char *, char const *);
char **iterative_data_scraper(int iters, char *haystack, char *start,
                              char *end) {
  char **char_array = (char **)malloc(sizeof(char *) * iters);
  const char *TRACK_INFO = "trackinfo : [{";
  char *start_of_data = strstr(haystack, TRACK_INFO);
  char *tmp = create_substring(start_of_data, "trackinfo", "var CurrencyData");
  char *tmp_start = tmp;
  unsigned i;
  for (i = 0; i < iters; i++) {
    char_array[i] = create_substring(tmp, start, end);
    tmp = strstr(tmp, char_array[i]);
    tmp += strlen(char_array[i]);
    if (strlen(start) > strlen(char_array[i]))
      tmp += 600;
  }
  free(tmp_start);
  return char_array;
}


x86 assembly (clang, -O0):
<iterative_data_scraper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    0xe7f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe6e(%rip),%rsi
lea    0xe71(%rip),%rdx
call   1050 <create_substring@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1269 <iterative_data_scraper+0x119>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <create_substring@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
jle    1256 <iterative_data_scraper+0x106>
mov    -0x40(%rbp),%rax
add    $0x258,%rax
mov    %rax,-0x40(%rbp)
jmp    125b <iterative_data_scraper+0x10b>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11c0 <iterative_data_scraper+0x70>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterative_data_scraper>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%r13d
lea    0x0(,%r13,8),%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rsp)
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
lea    0xe7d(%rip),%rsi
lea    0xe80(%rip),%rdx
mov    %rax,%rdi
call   1050 <create_substring@plt>
mov    %rax,(%rsp)
test   %r13d,%r13d
je     121f <iterative_data_scraper+0xcf>
mov    %r13d,%eax
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
mov    (%rsp),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <create_substring@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rax
mov    %rbp,(%rax,%r14,8)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strstr@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbp
mov    %r15,%r13
lea    (%rbx,%rax,1),%r15
mov    %r12,%rdi
call   1040 <strlen@plt>
cmp    %rbp,%rax
lea    0x258(%rbx,%rbp,1),%rbx
cmovle %r15,%rbx
mov    %r13,%r15
add    $0x1,%r14
cmp    %r14,0x10(%rsp)
jne    11c0 <iterative_data_scraper+0x70>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"trackinfo : [{\00"
@.str.1 = [10 x i8] c"trackinfo\00"
@.str.2 = [17 x i8] c"var CurrencyData\00"
define i8** @iterative_data_scraper(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = mul i64 8, %16
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8**
store i8** %20, i8*** %9
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %10
%21 = load i8*, i8** %6
%22 = load i8*, i8** %10
%23 = call i8* @strstr(i8* %21, i8* %22)
store i8* %23, i8** %11
%24 = load i8*, i8** %11
%25 = call i8* @create_substring(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i8* %25, i8** %12
%26 = load i8*, i8** %12
store i8* %26, i8** %13
store i32 0, i32* %14
br label %27
27: ; preds = %68, %4
%28 = load i32, i32* %14
%29 = load i32, i32* %5
%30 = icmp ult i32 %28, %29
br i1 %30, label %31, label %71
31: ; preds = %27
%32 = load i8*, i8** %12
%33 = load i8*, i8** %7
%34 = load i8*, i8** %8
%35 = call i8* @create_substring(i8* %32, i8* %33, i8* %34)
%36 = load i8**, i8*** %9
%37 = load i32, i32* %14
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
store i8* %35, i8** %39
%40 = load i8*, i8** %12
%41 = load i8**, i8*** %9
%42 = load i32, i32* %14
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i8* @strstr(i8* %40, i8* %45)
store i8* %46, i8** %12
%47 = load i8**, i8*** %9
%48 = load i32, i32* %14
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i64 @strlen(i8* %51)
%53 = load i8*, i8** %12
%54 = getelementptr inbounds i8, i8* %53, i64 %52
store i8* %54, i8** %12
%55 = load i8*, i8** %7
%56 = call i64 @strlen(i8* %55)
%57 = load i8**, i8*** %9
%58 = load i32, i32* %14
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i64 @strlen(i8* %61)
%63 = icmp sgt i64 %56, %62
br i1 %63, label %64, label %67
64: ; preds = %31
%65 = load i8*, i8** %12
%66 = getelementptr inbounds i8, i8* %65, i64 600
store i8* %66, i8** %12
br label %67
67: ; preds = %64, %31
br label %68
68: ; preds = %67
%69 = load i32, i32* %14
%70 = add i32 %69, 1
store i32 %70, i32* %14
br label %27
71: ; preds = %27
%72 = load i8*, i8** %13
%73 = call i32 @free(i8* %72)
%74 = load i8**, i8*** %9
ret i8** %74
}

LLVM IR (-O2):
@.str = [15 x i8] c"trackinfo : [{\00"
@.str.1 = [10 x i8] c"trackinfo\00"
@.str.2 = [17 x i8] c"var CurrencyData\00"
define i8** @iterative_data_scraper(i32 %0, i8* %1, i8* %2, i8* %3) {
%5 = shl i32 %0, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8**
%8 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = tail call i8* @create_substring(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %0, 0
br i1 %10, label %27, label %11
11: ; preds = %4
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %25, %13 ]
%15 = phi i8* [ %9, %11 ], [ %24, %13 ]
%16 = tail call i8* @create_substring(i8* %15, i8* %2, i8* %3)
%17 = getelementptr inbounds i8*, i8** %7, i64 %14
store i8* %16, i8** %17
%18 = tail call i8* @strstr(i8* dereferenceable(1) %15, i8* dereferenceable(1) %16)
%19 = tail call i64 @strlen(i8* dereferenceable(1) %16)
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%22 = icmp sgt i64 %21, %19
%23 = select i1 %22, i64 600, i64 0
%24 = getelementptr i8, i8* %20, i64 %23
%25 = add nuw nsw i64 %14, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %13
27: ; preds = %13, %4
%28 = tail call i32 @free(i8* %9)
ret i8** %7
}