#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 */
void *ml_calloc(int, int, char *, int);
int /*<<< orphan*/ ml_free(void *, char *, int);
void *ml_malloc(int, char *, int);
void *ml_realloc(void *, int, char *, int);
int ml_report();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int main() {
  int count = 0;
  for (int i = 0; i < 100; ++i) {
    void *p = NULL;
    int size = rand() % 1000;
    if (size & 1)
      p = ml_malloc(
          size,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ptahpeteh/ml/refs/heads/master/test.c",
          15);
    else
      p = ml_calloc(
          2, size,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ptahpeteh/ml/refs/heads/master/test.c",
          16);
    if (size % 4 == 0) {
      size += (size & 128 ? -1 : 1) * (rand() % 64);
      p = ml_realloc(
          p, size,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/ptahpeteh/ml/refs/heads/master/test.c",
          20);
    }
    if (size % 3 == 0)
      ml_free(p,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ptahpeteh/ml/refs/heads/master/test.c",
              23);
    else {
      printf("%p <-- %d\n", p, size);
      ++count;
    }
  }
  if (count != ml_report()) {
    printf("NOT ALL LISTED\n");
  } else
    printf("TOTAL: %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    12c0 <main+0x150>
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11dd <main+0x6d>
mov    -0x1c(%rbp),%edi
lea    0xe36(%rip),%rsi
mov    $0xf,%edx
call   1050 <ml_malloc@plt>
mov    %rax,-0x18(%rbp)
jmp    11fa <main+0x8a>
mov    -0x1c(%rbp),%esi
mov    $0x2,%edi
lea    0xe14(%rip),%rdx
mov    $0x10,%ecx
call   1070 <ml_calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1261 <main+0xf1>
mov    -0x1c(%rbp),%edx
and    $0x80,%edx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%eax
imul   %edx,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    0xdad(%rip),%rdx
mov    $0x14,%ecx
call   1060 <ml_realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    128f <main+0x11f>
mov    -0x18(%rbp),%rdi
lea    0xd80(%rip),%rsi
mov    $0x17,%edx
call   1080 <ml_free@plt>
jmp    12ad <main+0x13d>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12b2 <main+0x142>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118d <main+0x1d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1040 <ml_report@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
je     12ed <main+0x17d>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fe <main+0x18e>
mov    -0x8(%rbp),%esi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x64,%r15d
lea    0xe68(%rip),%r14
xor    %r12d,%r12d
jmp    11c1 <main+0x41>
nopl   (%rax)
lea    0xed9(%rip),%rdi
mov    %r13,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
add    $0xffffffff,%r15d
je     1291 <main+0x111>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rbx
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%ebx
test   $0x1,%bl
jne    1210 <main+0x90>
mov    $0x2,%edi
mov    %ebx,%esi
mov    %r14,%rdx
mov    $0x10,%ecx
call   1080 <ml_calloc@plt>
jmp    121f <main+0x9f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xf,%edx
call   1060 <ml_malloc@plt>
mov    %rax,%r13
test   $0x3,%bl
jne    125e <main+0xde>
xor    %eax,%eax
call   10a0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
mov    %eax,%ebp
neg    %ebp
test   $0x80,%bl
cmove  %eax,%ebp
add    %ebx,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    $0x14,%ecx
call   1070 <ml_realloc@plt>
mov    %rax,%r13
mov    %ebp,%ebx
imul   $0xffffaaab,%ebx,%eax
add    $0x2aaa,%eax
movzwl %ax,%eax
cmp    $0x5554,%eax
ja     11a0 <main+0x20>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x17,%edx
call   1090 <ml_free@plt>
add    $0xffffffff,%r15d
jne    11c1 <main+0x41>
xor    %eax,%eax
call   1050 <ml_report@plt>
cmp    %eax,%r12d
jne    12b0 <main+0x130>
lea    0xde7(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12bc <main+0x13c>
lea    0xddf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [128 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ptahpeteh/ml/refs/heads/master/test.c\00"
@.str.1 = [11 x i8] c"%p <-- %d\0A\00"
@.str.2 = [16 x i8] c"NOT ALL LISTED\0A\00"
@.str.3 = [11 x i8] c"TOTAL: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %53, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %56
9: ; preds = %6
store i8* null, i8** %4
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 1000
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32, i32* %5
%17 = call i8* @ml_malloc(i32 %16, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 15)
store i8* %17, i8** %4
br label %21
18: ; preds = %9
%19 = load i32, i32* %5
%20 = call i8* @ml_calloc(i32 2, i32 %19, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 16)
store i8* %20, i8** %4
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %5
%23 = srem i32 %22, 4
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load i32, i32* %5
%27 = and i32 %26, 128
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 -1, i32 1
%31 = call i32 (...) @rand()
%32 = srem i32 %31, 64
%33 = mul nsw i32 %30, %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, %33
store i32 %35, i32* %5
%36 = load i8*, i8** %4
%37 = load i32, i32* %5
%38 = call i8* @ml_realloc(i8* %36, i32 %37, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 20)
store i8* %38, i8** %4
br label %39
39: ; preds = %25, %21
%40 = load i32, i32* %5
%41 = srem i32 %40, 3
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = call i32 @ml_free(i8* %44, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 23)
br label %52
46: ; preds = %39
%47 = load i8*, i8** %4
%48 = load i32, i32* %5
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %47, i32 %48)
%50 = load i32, i32* %2
%51 = add nsw i32 %50, 1
store i32 %51, i32* %2
br label %52
52: ; preds = %46, %43
br label %53
53: ; preds = %52
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %6
56: ; preds = %6
%57 = load i32, i32* %2
%58 = call i32 (...) @ml_report()
%59 = icmp ne i32 %57, %58
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %65
62: ; preds = %56
%63 = load i32, i32* %2
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %62, %60
ret i32 0
}

LLVM IR (-O2):
@.str = [128 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ptahpeteh/ml/refs/heads/master/test.c\00"
@.str.1 = [11 x i8] c"%p <-- %d\0A\00"
@.str.3 = [11 x i8] c"TOTAL: %d\0A\00"
@str = [15 x i8] c"NOT ALL LISTED\00"
define i32 @main() {
br label %4
1: ; preds = %39
%2 = tail call i32 (...) @ml_report()
%3 = icmp eq i32 %40, %2
br i1 %3, label %45, label %43
4: ; preds = %0, %39
%5 = phi i32 [ 0, %0 ], [ %41, %39 ]
%6 = phi i32 [ 0, %0 ], [ %40, %39 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 1000
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = tail call i8* @ml_malloc(i32 %8, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 15)
br label %15
13: ; preds = %4
%14 = tail call i8* @ml_calloc(i32 2, i32 %8, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 16)
br label %15
15: ; preds = %13, %11
%16 = phi i8* [ %12, %11 ], [ %14, %13 ]
%17 = and i32 %8, 3
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = and i32 %8, 128
%21 = icmp eq i32 %20, 0
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 64
%24 = sub nsw i32 0, %23
%25 = select i1 %21, i32 %23, i32 %24
%26 = add nsw i32 %25, %8
%27 = tail call i8* @ml_realloc(i8* %16, i32 %26, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 20)
br label %28
28: ; preds = %19, %15
%29 = phi i8* [ %27, %19 ], [ %16, %15 ]
%30 = phi i32 [ %26, %19 ], [ %8, %15 ]
%31 = trunc i32 %30 to i16
%32 = srem i16 %31, 3
%33 = icmp eq i16 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = tail call i32 @ml_free(i8* %29, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @.str, i64 0, i64 0), i32 23)
br label %39
36: ; preds = %28
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %30)
%38 = add nsw i32 %6, 1
br label %39
39: ; preds = %36, %34
%40 = phi i32 [ %6, %34 ], [ %38, %36 ]
%41 = add nuw nsw i32 %5, 1
%42 = icmp eq i32 %41, 100
br i1 %42, label %1, label %4
43: ; preds = %1
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %47
45: ; preds = %1
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %47
47: ; preds = %45, %43
ret i32 0
}