#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*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int format_data_get_data(char *, char *, int);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ gestion_erreurs_set(int, char *, char *);
scalar_t__ malloc(int);
void format_data(char *_path, char *_pattern, int n_arg) {
  char *_buffer;
  int n, n_data;
  FILE *_file;
  if (!(_path))
    gestion_erreurs_set(
        52,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ngwese/mod/refs/heads/clock-div-mult/"
        "xdk-asf-3.17.0/avr32/services/dsp/dsplib/utils/programs/data_extract/"
        "main.c",
        "ASSERT("
        "_path"
        ")");
  _file = fopen(_path, "rb");
  if (!(_file))
    gestion_erreurs_set(
        56,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ngwese/mod/refs/heads/clock-div-mult/"
        "xdk-asf-3.17.0/avr32/services/dsp/dsplib/utils/programs/data_extract/"
        "main.c",
        "ASSERT("
        "_file"
        ")");
  fseek(_file, 0, SEEK_END);
  n = ftell(_file);
  _buffer = (char *)malloc(n + 1);
  if (!(_buffer))
    gestion_erreurs_set(
        62,
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ngwese/mod/refs/heads/clock-div-mult/"
        "xdk-asf-3.17.0/avr32/services/dsp/dsplib/utils/programs/data_extract/"
        "main.c",
        "ASSERT("
        "_buffer"
        ")");
  _buffer[n] = '\0';
  fseek(_file, 0, SEEK_SET);
  fread(_buffer, 1, n, _file);
  fclose(_file);
  n_data = format_data_get_data(_buffer, _pattern, n_arg);
  free(_buffer);
}


x86 assembly (clang, -O0):
<format_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11c6 <format_data+0x36>
mov    $0x34,%edi
lea    0xe46(%rip),%rsi
lea    0xf0a(%rip),%rdx
call   10b0 <gestion_erreurs_set@plt>
mov    -0x8(%rbp),%rdi
lea    0xf08(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11fd <format_data+0x6d>
mov    $0x38,%edi
lea    0xe0f(%rip),%rsi
lea    0xee4(%rip),%rdx
call   10b0 <gestion_erreurs_set@plt>
mov    -0x30(%rbp),%rdi
mov    0x2de0(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    124f <format_data+0xbf>
mov    $0x3e,%edi
lea    0xdbd(%rip),%rsi
lea    0xea0(%rip),%rdx
call   10b0 <gestion_erreurs_set@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
mov    0x2d72(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <format_data_get_data@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rdi,%rdi
jne    11be <format_data+0x2e>
lea    0xe53(%rip),%rsi
lea    0xf17(%rip),%rdx
mov    $0x34,%edi
call   10b0 <gestion_erreurs_set@plt>
lea    0xf14(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    11ed <format_data+0x5d>
lea    0xe24(%rip),%rsi
lea    0xef9(%rip),%rdx
mov    $0x38,%edi
call   10b0 <gestion_erreurs_set@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1070 <ftell@plt>
mov    %eax,%r12d
lea    0x1(%r12),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1235 <format_data+0xa5>
lea    0xddc(%rip),%rsi
lea    0xebf(%rip),%rdx
mov    $0x3e,%edi
call   10b0 <gestion_erreurs_set@plt>
movslq %r12d,%rax
movb   $0x0,(%rbx,%rax,1)
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1060 <format_data_get_data@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [203 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ngwese/mod/refs/heads/clock-div-mult/xdk-asf-3.17.0/avr32/services/dsp/dsplib/utils/programs/data_extract/main.c\00"
@.str.1 = [14 x i8] c"ASSERT(_path)\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [14 x i8] c"ASSERT(_file)\00"
@SEEK_END = global i32 0
@.str.4 = [16 x i8] c"ASSERT(_buffer)\00"
@SEEK_SET = global i32 0
define void @format_data(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %3
%14 = call i32 @gestion_erreurs_set(i32 52, i8* getelementptr inbounds ([203 x i8], [203 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %3
%16 = load i8*, i8** %4
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %17, i32** %10
%18 = load i32*, i32** %10
%19 = icmp ne i32* %18, null
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = call i32 @gestion_erreurs_set(i32 56, i8* getelementptr inbounds ([203 x i8], [203 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
%23 = load i32*, i32** %10
%24 = load i32, i32* @SEEK_END
%25 = call i32 @fseek(i32* %23, i32 0, i32 %24)
%26 = load i32*, i32** %10
%27 = call i32 @ftell(i32* %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %7
%32 = load i8*, i8** %7
%33 = icmp ne i8* %32, null
br i1 %33, label %36, label %34
34: ; preds = %22
%35 = call i32 @gestion_erreurs_set(i32 62, i8* getelementptr inbounds ([203 x i8], [203 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %22
%37 = load i8*, i8** %7
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 0, i8* %40
%41 = load i32*, i32** %10
%42 = load i32, i32* @SEEK_SET
%43 = call i32 @fseek(i32* %41, i32 0, i32 %42)
%44 = load i8*, i8** %7
%45 = load i32, i32* %8
%46 = load i32*, i32** %10
%47 = call i32 @fread(i8* %44, i32 1, i32 %45, i32* %46)
%48 = load i32*, i32** %10
%49 = call i32 @fclose(i32* %48)
%50 = load i8*, i8** %7
%51 = load i8*, i8** %5
%52 = load i32, i32* %6
%53 = call i32 @format_data_get_data(i8* %50, i8* %51, i32 %52)
store i32 %53, i32* %9
%54 = load i8*, i8** %7
%55 = call i32 @free(i8* %54)
ret void
}

LLVM IR (-O2):
@.str = [203 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ngwese/mod/refs/heads/clock-div-mult/xdk-asf-3.17.0/avr32/services/dsp/dsplib/utils/programs/data_extract/main.c\00"
@.str.1 = [14 x i8] c"ASSERT(_path)\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [14 x i8] c"ASSERT(_file)\00"
@SEEK_END = global i32 0
@.str.4 = [16 x i8] c"ASSERT(_buffer)\00"
@SEEK_SET = global i32 0
define void @format_data(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @gestion_erreurs_set(i32 52, i8* getelementptr inbounds ([203 x i8], [203 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @gestion_erreurs_set(i32 56, i8* getelementptr inbounds ([203 x i8], [203 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = load i32, i32* @SEEK_END
%14 = tail call i32 @fseek(i32* %8, i32 0, i32 %13)
%15 = tail call i32 @ftell(i32* %8)
%16 = add nsw i32 %15, 1
%17 = tail call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
%19 = icmp eq i64 %17, 0
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = tail call i32 @gestion_erreurs_set(i32 62, i8* getelementptr inbounds ([203 x i8], [203 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %12
%23 = sext i32 %15 to i64
%24 = getelementptr inbounds i8, i8* %18, i64 %23
store i8 0, i8* %24
%25 = load i32, i32* @SEEK_SET
%26 = tail call i32 @fseek(i32* %8, i32 0, i32 %25)
%27 = tail call i32 @fread(i8* %18, i32 1, i32 %15, i32* %8)
%28 = tail call i32 @fclose(i32* %8)
%29 = tail call i32 @format_data_get_data(i8* %18, i8* %1, i32 %2)
%30 = tail call i32 @free(i8* %18)
ret void
}