#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 *get_line(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
scalar_t__ realloc(char **, int);
int /*<<< orphan*/ *strstr(char *, char *);
char **get_block_lines(FILE *fp, char *delimeter, int *num_line) {
  char *buffer = NULL;
  int count = 0;
  char **data = 0;
  data = (char **)malloc(sizeof(char *));
  while (1) {
    buffer = get_line(fp);
    if (buffer == NULL)
      continue;
    if (strstr(buffer, delimeter) != NULL)
      break;
    if (count == 0) {
      data[count] = buffer;
    } else {
      data = (char **)realloc(data, (sizeof(char *) * (count + 1)));
      data[count] = buffer;
    }
    count++;
  }
  if (buffer != NULL) {
    data = (char **)realloc(data, (sizeof(char *) * (count + 1)));
    data[count] = buffer;
    count++;
  }
  *num_line = (count - 1);
  return data;
}


x86 assembly (clang, -O0):
<get_block_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_line@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1196 <get_block_lines+0x56>
jmp    1179 <get_block_lines+0x39>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11b2 <get_block_lines+0x72>
jmp    120a <get_block_lines+0xca>
cmpl   $0x0,-0x24(%rbp)
jne    11d1 <get_block_lines+0x91>
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11fc <get_block_lines+0xbc>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1179 <get_block_lines+0x39>
cmpq   $0x0,-0x20(%rbp)
je     1249 <get_block_lines+0x109>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_block_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
xor    %ebp,%ebp
jmp    1190 <get_block_lines+0x50>
lea    0x8(,%rbp,8),%esi
mov    %r12,%rdi
call   1050 <realloc@plt>
lea    (%rax,%rbp,8),%r12
mov    %rbx,(%r12)
add    $0x1,%rbp
mov    %rax,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
call   1030 <get_line@plt>
test   %rax,%rax
je     1190 <get_block_lines+0x50>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11ba <get_block_lines+0x7a>
test   %rbp,%rbp
jne    1165 <get_block_lines+0x25>
mov    %r12,%rax
jmp    1178 <get_block_lines+0x38>
lea    0x8(,%rbp,8),%esi
mov    %r12,%rdi
call   1050 <realloc@plt>
mov    %ebp,%ecx
mov    %rbx,(%rax,%rcx,8)
mov    %ebp,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @get_block_lines(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i8* null, i8** %7
store i32 0, i32* %8
store i8** null, i8*** %9
%10 = call i64 @malloc(i32 8)
%11 = inttoptr i64 %10 to i8**
store i8** %11, i8*** %9
br label %12
12: ; preds = %3, %17, %47
%13 = load i32*, i32** %4
%14 = call i8* @get_line(i32* %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %12
br label %12
18: ; preds = %12
%19 = load i8*, i8** %7
%20 = load i8*, i8** %5
%21 = call i32* @strstr(i8* %19, i8* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
br label %50
24: ; preds = %18
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i8*, i8** %7
%29 = load i8**, i8*** %9
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
store i8* %28, i8** %32
br label %47
33: ; preds = %24
%34 = load i8**, i8*** %9
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = mul i64 8, %37
%39 = trunc i64 %38 to i32
%40 = call i64 @realloc(i8** %34, i32 %39)
%41 = inttoptr i64 %40 to i8**
store i8** %41, i8*** %9
%42 = load i8*, i8** %7
%43 = load i8**, i8*** %9
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
store i8* %42, i8** %46
br label %47
47: ; preds = %33, %27
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %12
50: ; preds = %23
%51 = load i8*, i8** %7
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %69
53: ; preds = %50
%54 = load i8**, i8*** %9
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = mul i64 8, %57
%59 = trunc i64 %58 to i32
%60 = call i64 @realloc(i8** %54, i32 %59)
%61 = inttoptr i64 %60 to i8**
store i8** %61, i8*** %9
%62 = load i8*, i8** %7
%63 = load i8**, i8*** %9
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
store i8* %62, i8** %66
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %69
69: ; preds = %53, %50
%70 = load i32, i32* %8
%71 = sub nsw i32 %70, 1
%72 = load i32*, i32** %6
store i32 %71, i32* %72
%73 = load i8**, i8*** %9
ret i8** %73
}

LLVM IR (-O2):
define i8** @get_block_lines(i32* %0, i8* nocapture %1, i32* nocapture writeonly %2) {
%4 = tail call i64 @malloc(i32 8)
%5 = inttoptr i64 %4 to i8**
br label %6
6: ; preds = %24, %3
%7 = phi i64 [ %27, %24 ], [ 0, %3 ]
%8 = phi i8** [ %26, %24 ], [ %5, %3 ]
br label %9
9: ; preds = %6, %9
%10 = tail call i8* @get_line(i32* %0)
%11 = icmp eq i8* %10, null
br i1 %11, label %9, label %12
12: ; preds = %9
%13 = tail call i32* @strstr(i8* %10, i8* dereferenceable(1) %1)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = icmp eq i64 %7, 0
br i1 %16, label %24, label %17
17: ; preds = %15
%18 = trunc i64 %7 to i32
%19 = shl i32 %18, 3
%20 = add i32 %19, 8
%21 = tail call i64 @realloc(i8** %8, i32 %20)
%22 = inttoptr i64 %21 to i8**
%23 = getelementptr inbounds i8*, i8** %22, i64 %7
br label %24
24: ; preds = %15, %17
%25 = phi i8** [ %23, %17 ], [ %8, %15 ]
%26 = phi i8** [ %22, %17 ], [ %8, %15 ]
store i8* %10, i8** %25
%27 = add nuw i64 %7, 1
br label %6
28: ; preds = %12
%29 = trunc i64 %7 to i32
%30 = shl i32 %29, 3
%31 = add i32 %30, 8
%32 = tail call i64 @realloc(i8** %8, i32 %31)
%33 = inttoptr i64 %32 to i8**
%34 = and i64 %7, 4294967295
%35 = getelementptr inbounds i8*, i8** %33, i64 %34
store i8* %10, i8** %35
store i32 %29, i32* %2
ret i8** %33
}