#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 */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(void *, size_t, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
void *malloc(size_t);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
char *strtok_r(char *, char *, char **);
int main() {
  FILE *file = fopen("pagina.html", "r");
  fseek(file, 0, SEEK_END);
  size_t size = ftell(file);
  rewind(file);
  void *buffer = malloc(size);
  fread(buffer, size, 1, file);
  char *save1 = 0, *save2 = 0;
  char *token = strtok_r(buffer, "<>", &save1);
  while (token) {
    if (*token == 'a') {
      char *link = strtok_r(token, "\"", &save2);
      link = strtok_r(0, "\"", &save2);
      char *title = strtok_r(0, "<>", &save1);
      printf("%s - %s\n", title, link);
    }
    token = strtok_r(0, "<>", &save1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
call   1030 <fread@plt>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe00(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12af <main+0x12f>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jne    1292 <main+0x112>
mov    -0x38(%rbp),%rdi
lea    0xdd0(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb8(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd9d(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xd86(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd71(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
jmp    121b <main+0x9b>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe70(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <rewind@plt>
mov    %r14,%rdi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe0d(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %r15,%rdi
call   1060 <strtok_r@plt>
test   %rax,%rax
je     1292 <main+0x112>
lea    0xdf7(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xde8(%rip),%r12
lea    0x8(%rsp),%rbx
lea    0xde1(%rip),%r13
jmp    1252 <main+0xd2>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edi,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <strtok_r@plt>
test   %rax,%rax
je     1292 <main+0x112>
cmpb   $0x61,(%rax)
jne    1240 <main+0xc0>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <strtok_r@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <strtok_r@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <strtok_r@plt>
mov    %r13,%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
call   1040 <printf@plt>
jmp    1240 <main+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"pagina.html\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.2 = [3 x i8] c"<>\00"
@.str.3 = [2 x i8] c"\22\00"
@.str.4 = [9 x i8] c"%s - %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %1
%10 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = load i32, i32* @SEEK_END
%13 = call i32 @fseek(i32* %11, i32 0, i32 %12)
%14 = load i32*, i32** %2
%15 = call i64 @ftell(i32* %14)
store i64 %15, i64* %3
%16 = load i32*, i32** %2
%17 = call i32 @rewind(i32* %16)
%18 = load i64, i64* %3
%19 = call i8* @malloc(i64 %18)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = load i64, i64* %3
%22 = load i32*, i32** %2
%23 = call i32 @fread(i8* %20, i64 %21, i32 1, i32* %22)
store i8* null, i8** %5
store i8* null, i8** %6
%24 = load i8*, i8** %4
%25 = call i8* @strtok_r(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %5)
store i8* %25, i8** %7
br label %26
26: ; preds = %42, %0
%27 = load i8*, i8** %7
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 97
br i1 %33, label %34, label %42
34: ; preds = %29
%35 = load i8*, i8** %7
%36 = call i8* @strtok_r(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %6)
store i8* %36, i8** %8
%37 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %6)
store i8* %37, i8** %8
%38 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %5)
store i8* %38, i8** %9
%39 = load i8*, i8** %9
%40 = load i8*, i8** %8
%41 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %39, i8* %40)
br label %42
42: ; preds = %34, %29
%43 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %5)
store i8* %43, i8** %7
br label %26
44: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"pagina.html\00"
@.str.1 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.2 = [3 x i8] c"<>\00"
@.str.3 = [2 x i8] c"\22\00"
@.str.4 = [9 x i8] c"%s - %s\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @SEEK_END
%5 = tail call i32 @fseek(i32* %3, i32 0, i32 %4)
%6 = tail call i64 @ftell(i32* %3)
%7 = tail call i32 @rewind(i32* %3)
%8 = tail call i8* @malloc(i64 %6)
%9 = tail call i32 @fread(i8* %8, i64 %6, i32 1, i32* %3)
%10 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%11 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%12 = call i8* @strtok_r(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %1)
%13 = icmp eq i8* %12, null
br i1 %13, label %26, label %14
14: ; preds = %0, %23
%15 = phi i8* [ %24, %23 ], [ %12, %0 ]
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 97
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = call i8* @strtok_r(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %2)
%20 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %2)
%21 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %1)
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %21, i8* %20)
br label %23
23: ; preds = %18, %14
%24 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %1)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %14
26: ; preds = %23, %0
ret i32 0
}