#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fill_line_ped(int *, char *, int, int, char *,
                                 int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *fopen_read(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ test_line(char *, int /*<<< orphan*/ *, int, int);
void read_ped(char *input_file, int N, int M, int *data) {
  FILE *File = NULL;
  int i;
  int max_char_per_line = 5 * (M + 6) + 20;
  char *szbuff;
  char *ref;
  szbuff = (char *)malloc(max_char_per_line * sizeof(char));
  ref = (char *)malloc(M * sizeof(char));
  for (i = 0; i < M; i++)
    ref[i] = '0';
  File = fopen_read(input_file);
  i = 0;
  while (fgets(szbuff, max_char_per_line, File) && i < N) {
    fill_line_ped(data, szbuff, M, i, input_file, File, ref);
    i++;
  }
  test_line(input_file, File, i, N);
  fclose(File);
  free(szbuff);
  free(ref);
}


x86 assembly (clang, -O0):
<read_ped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x6,%eax
imul   $0x5,%eax,%eax
add    $0x14,%eax
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f0 <read_ped+0x80>
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ca <read_ped+0x5a>
mov    -0x8(%rbp),%rdi
call   1080 <fopen_read@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x39(%rbp)
je     1232 <read_ped+0xc2>
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1242 <read_ped+0xd2>
jmp    1273 <read_ped+0x103>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x38(%rbp),%rax
mov    %rax,(%rsp)
call   1070 <fill_line_ped@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1204 <read_ped+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1090 <test_line@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ped>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x20(%rsp)
mov    %edx,%ebp
mov    %esi,0x14(%rsp)
mov    %rdi,0x18(%rsp)
lea    0x32(%rbp,%rbp,4),%r14d
mov    %r14d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
test   %ebp,%ebp
jle    11cb <read_ped+0x4b>
mov    %ebp,%edx
mov    %r13,%rdi
mov    $0x30,%esi
call   1050 <memset@plt>
mov    0x18(%rsp),%rdi
call   1090 <fopen_read@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     123c <read_ped+0xbc>
cmpl   $0x0,0x14(%rsp)
jle    123c <read_ped+0xbc>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r13,(%rsp)
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r15d,%ecx
mov    0x18(%rsp),%r8
mov    %r12,%r9
call   1080 <fill_line_ped@plt>
add    $0x1,%r15d
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     123c <read_ped+0xbc>
cmp    0x14(%rsp),%r15d
jl     1200 <read_ped+0x80>
mov    0x18(%rsp),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    0x14(%rsp),%ecx
call   10a0 <test_line@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @read_ped(i8* %0, i32 %1, i32 %2, i32* %3) {
%5 = mul i32 %2, 5
%6 = add i32 %5, 50
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i64 @malloc(i32 %2)
%10 = inttoptr i64 %9 to i8*
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = zext i32 %2 to i64
br label %14
14: ; preds = %12, %4
%15 = tail call i32* @fopen_read(i8* %0)
%16 = tail call i64 @fgets(i8* %8, i32 %6, i32* %15)
%17 = icmp ne i64 %16, 0
%18 = icmp sgt i32 %1, 0
%19 = and i1 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %14, %20
%21 = phi i32 [ %23, %20 ], [ 0, %14 ]
%22 = tail call i32 @fill_line_ped(i32* %3, i8* %8, i32 %2, i32 %21, i8* %0, i32* %15, i8* %10)
%23 = add nuw nsw i32 %21, 1
%24 = tail call i64 @fgets(i8* %8, i32 %6, i32* %15)
%25 = icmp ne i64 %24, 0
%26 = icmp slt i32 %23, %1
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %20, label %28
28: ; preds = %20, %14
%29 = phi i32 [ 0, %14 ], [ %23, %20 ]
%30 = tail call i32 @test_line(i8* %0, i32* %15, i32 %29, i32 %1)
%31 = tail call i32 @fclose(i32* %15)
%32 = tail call i32 @free(i8* %8)
%33 = tail call i32 @free(i8* %10)
ret void
}