#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 parseFichierMatiere(char *str, char **tabMatieres) {
  int positionEOption = 0;
  int i = 0;
  char *option = malloc(sizeof(char) * 100);
  while ((str = strstr(str, "<OPTION\nVALUE=")) != NULL) {
    str = str + (strlen("<OPTION\nVALUE=") + 4);
    char *finOption = malloc(sizeof(char) * strlen(str));
    if ((finOption = strstr(str, "</OPTION>")) != NULL) {
      positionEOption = finOption - str;
      strncpy(option, str, positionEOption);
      option[positionEOption] = '\0';
      strcpy(tabMatieres[i], option);
      i++;
    } else {
      free(finOption);
      return 1;
    }
  }
  free(option);
  return 0;
}


x86 assembly (clang, -O0):
<parseFichierMatiere>:
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     1270 <parseFichierMatiere+0x110>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe47(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
add    $0x4,%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    0xe19(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1256 <parseFichierMatiere+0xf6>
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    126b <parseFichierMatiere+0x10b>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1280 <parseFichierMatiere+0x120>
jmp    118c <parseFichierMatiere+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):
<parseFichierMatiere>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%rbx
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     1217 <parseFichierMatiere+0xb7>
mov    %rax,%rbx
lea    0xe60(%rip),%r15
lea    0xe68(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%rbx
add    $0x4,%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     121b <parseFichierMatiere+0xbb>
mov    %rax,%rbp
sub    %rbx,%rbp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
mov    0x0(%r13),%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strstr@plt>
mov    %rax,%rbx
add    $0x8,%r13
test   %rax,%rax
jne    11b0 <parseFichierMatiere+0x50>
xor    %ebx,%ebx
jmp    1223 <parseFichierMatiere+0xc3>
mov    $0x1,%ebx
xor    %r14d,%r14d
mov    %r14,%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 = [15 x i8] c"<OPTION\0AVALUE=\00"
@.str.1 = [10 x i8] c"</OPTION>\00"
define i32 @parseFichierMatiere(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 = %57, %2
%12 = load i8*, i8** %4
%13 = call i8* @strstr(i8* %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %58
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%18 = add nsw i32 %17, 4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
store i8* %20, i8** %4
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = sext i32 %22 to i64
%24 = mul i64 1, %23
%25 = trunc i64 %24 to i32
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %9
%27 = load i8*, i8** %4
%28 = call i8* @strstr(i8* %27, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %28, i8** %9
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %54
30: ; preds = %15
%31 = load i8*, i8** %9
%32 = load i8*, i8** %4
%33 = ptrtoint i8* %31 to i64
%34 = ptrtoint i8* %32 to i64
%35 = sub i64 %33, %34
%36 = trunc i64 %35 to i32
store i32 %36, i32* %6
%37 = load i8*, i8** %8
%38 = load i8*, i8** %4
%39 = load i32, i32* %6
%40 = call i32 @strncpy(i8* %37, i8* %38, i32 %39)
%41 = load i8*, i8** %8
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 0, i8* %44
%45 = load i8**, i8*** %5
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = load i8*, i8** %8
%51 = call i32 @strcpy(i8* %49, i8* %50)
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %57
54: ; preds = %15
%55 = load i8*, i8** %9
%56 = call i32 @free(i8* %55)
store i32 1, i32* %3
br label %61
57: ; preds = %30
br label %11
58: ; preds = %11
%59 = load i8*, i8** %8
%60 = call i32 @free(i8* %59)
store i32 0, i32* %3
br label %61
61: ; preds = %58, %54
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [15 x i8] c"<OPTION\0AVALUE=\00"
@.str.1 = [10 x i8] c"</OPTION>\00"
define i32 @parseFichierMatiere(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 ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %31, label %6
6: ; preds = %2, %16
%7 = phi i64 [ %28, %16 ], [ 0, %2 ]
%8 = phi i8* [ %29, %16 ], [ %4, %2 ]
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = add nsw i32 %9, 4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = tail call i32 @strlen(i8* %12)
%14 = tail call i8* @strstr(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %31, label %16
16: ; preds = %6
%17 = ptrtoint i8* %14 to i64
%18 = ptrtoint i8* %12 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
%21 = tail call i32 @strncpy(i8* %3, i8* %12, i32 %20)
%22 = shl i64 %19, 32
%23 = ashr exact i64 %22, 32
%24 = getelementptr inbounds i8, i8* %3, i64 %23
store i8 0, i8* %24
%25 = getelementptr inbounds i8*, i8** %1, i64 %7
%26 = load i8*, i8** %25
%27 = tail call i32 @strcpy(i8* %26, i8* %3)
%28 = add nuw i64 %7, 1
%29 = tail call i8* @strstr(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %6
31: ; preds = %16, %6, %2
%32 = phi i8* [ %3, %2 ], [ null, %6 ], [ %3, %16 ]
%33 = phi i32 [ 0, %2 ], [ 1, %6 ], [ 0, %16 ]
%34 = tail call i32 @free(i8* %32)
ret i32 %33
}