#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int parseFichierRendus(char *str, char **tabRendus) {
  int positionERendu = 0;
  int i = 0;
  char *rendu = malloc(sizeof(char) * 100);
  while ((str = strstr(str,
                       "<a\n	  "
                       "\nhref=\"javascript:popup('popup.php?id_echeance=")) !=
         NULL) {
    if (i < 10)
      str =
          str +
          (strlen("<a\n	  \nhref=\"javascript:popup('popup.php?id_echeance=") +
           5);
    else
      str =
          str +
          (strlen("<a\n	  \nhref=\"javascript:popup('popup.php?id_echeance=") +
           6);
    char *finRendu = malloc(sizeof(char) * strlen(str));
    if ((finRendu = strstr(str, "</a>")) != NULL) {
      positionERendu = finRendu - str;
      strncpy(rendu, str, positionERendu);
      rendu[positionERendu] = '\0';
      strcpy(tabRendus[i], rendu);
      i++;
    } else {
      free(finRendu);
      return 1;
    }
  }
  free(rendu);
  return 0;
}


x86 assembly (clang, -O0):
<parseFichierRendus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12a6 <parseFichierRendus+0x146>
cmpl   $0xa,-0x20(%rbp)
jge    11e0 <parseFichierRendus+0x80>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe3d(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
add    $0x5,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1207 <parseFichierRendus+0xa7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xe11(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
add    $0x6,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     128c <parseFichierRendus+0x12c>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12a1 <parseFichierRendus+0x141>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b6 <parseFichierRendus+0x156>
jmp    118c <parseFichierRendus+0x2c>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseFichierRendus>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     1223 <parseFichierRendus+0xc3>
mov    %rax,%rbp
lea    0xe60(%rip),%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1060 <strlen@plt>
cmp    $0xa,%r12
sbb    $0x0,%eax
add    $0x6,%eax
movslq %eax,%rbx
add    %rbp,%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
lea    0xe5c(%rip),%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     1227 <parseFichierRendus+0xc7>
mov    %rax,%rbp
sub    %rbx,%rbp
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,0x0(%r13,%rax,1)
mov    (%r14,%r12,8),%rdi
mov    %r13,%rsi
call   1050 <strcpy@plt>
add    $0x1,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strstr@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11b0 <parseFichierRendus+0x50>
xor    %ebx,%ebx
jmp    122f <parseFichierRendus+0xcf>
mov    $0x1,%ebx
xor    %r13d,%r13d
mov    %r13,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [54 x i8] c"<a\0A\09 \0Ahref=\22javascript:popup('popup.php?id_echeance=\00"
@.str.1 = [5 x i8] c"</a>\00"
define i32 @parseFichierRendus(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = call i8* @malloc(i32 100)
store i8* %10, i8** %8
br label %11
11: ; preds = %67, %2
%12 = load i8*, i8** %4
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %68
15: ; preds = %11
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = call i32 @strlen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%21 = add nsw i32 %20, 5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8* %23, i8** %4
br label %30
24: ; preds = %15
%25 = load i8*, i8** %4
%26 = call i32 @strlen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%27 = add nsw i32 %26, 6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
store i8* %29, i8** %4
br label %30
30: ; preds = %24, %18
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
%33 = sext i32 %32 to i64
%34 = mul i64 1, %33
%35 = trunc i64 %34 to i32
%36 = call i8* @malloc(i32 %35)
store i8* %36, i8** %9
%37 = load i8*, i8** %4
%38 = call i8* @strstr(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %38, i8** %9
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %64
40: ; preds = %30
%41 = load i8*, i8** %9
%42 = load i8*, i8** %4
%43 = ptrtoint i8* %41 to i64
%44 = ptrtoint i8* %42 to i64
%45 = sub i64 %43, %44
%46 = trunc i64 %45 to i32
store i32 %46, i32* %6
%47 = load i8*, i8** %8
%48 = load i8*, i8** %4
%49 = load i32, i32* %6
%50 = call i32 @strncpy(i8* %47, i8* %48, i32 %49)
%51 = load i8*, i8** %8
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
store i8 0, i8* %54
%55 = load i8**, i8*** %5
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = load i8*, i8** %8
%61 = call i32 @strcpy(i8* %59, i8* %60)
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %67
64: ; preds = %30
%65 = load i8*, i8** %9
%66 = call i32 @free(i8* %65)
store i32 1, i32* %3
br label %71
67: ; preds = %40
br label %11
68: ; preds = %11
%69 = load i8*, i8** %8
%70 = call i32 @free(i8* %69)
store i32 0, i32* %3
br label %71
71: ; preds = %68, %64
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
@.str = [54 x i8] c"<a\0A\09 \0Ahref=\22javascript:popup('popup.php?id_echeance=\00"
@.str.1 = [5 x i8] c"</a>\00"
define i32 @parseFichierRendus(i8* %0, i8** nocapture %1) {
%3 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %33, label %6
6: ; preds = %2, %18
%7 = phi i64 [ %30, %18 ], [ 0, %2 ]
%8 = phi i8* [ %31, %18 ], [ %4, %2 ]
%9 = icmp ult i64 %7, 10
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%11 = select i1 %9, i32 5, i32 6
%12 = add nsw i32 %10, %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %8, i64 %13
%15 = tail call i32 @strlen(i8* %14)
%16 = tail call i8* @strstr(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %33, label %18
18: ; preds = %6
%19 = ptrtoint i8* %16 to i64
%20 = ptrtoint i8* %14 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
%23 = tail call i32 @strncpy(i8* %3, i8* %14, i32 %22)
%24 = shl i64 %21, 32
%25 = ashr exact i64 %24, 32
%26 = getelementptr inbounds i8, i8* %3, i64 %25
store i8 0, i8* %26
%27 = getelementptr inbounds i8*, i8** %1, i64 %7
%28 = load i8*, i8** %27
%29 = tail call i32 @strcpy(i8* %28, i8* %3)
%30 = add nuw i64 %7, 1
%31 = tail call i8* @strstr(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %6
33: ; preds = %18, %6, %2
%34 = phi i8* [ %3, %2 ], [ null, %6 ], [ %3, %18 ]
%35 = phi i32 [ 0, %2 ], [ 1, %6 ], [ 0, %18 ]
%36 = tail call i32 @free(i8* %34)
ret i32 %35
}