void distribute(int blocksPerThread, int minSize, int maxSize, char **blkp,
                int allocatorNo, int distributorId) {
  if ((__builtin_expect(!!((0xffff) <= 0xffff), 0)))
    _log_write(__FUNCTION__,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/ashish-17/wfmalloc/refs/"
               "heads/master/src/main.c",
               611, 0xffff, 0, "");
  ;
  ;
  int blkSize, i = 0;
  for (i = 0; i < blocksPerThread; i++) {
    blkSize = randomNumber(minSize, maxSize);
    if (allocatorNo == 1) {
      blkp[i] = (char *)wfmalloc(blkSize, distributorId);
    } else {
      blkp[i] = (char *)malloc(blkSize);
    }
  }
  if ((__builtin_expect(!!((0xffff) <= 0xffff), 0)))
    _log_write(__FUNCTION__,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/ashish-17/wfmalloc/refs/"
               "heads/master/src/main.c",
               623, 0xffff, 1, "");
  ;
  ;
}


x86 assembly (clang, -O0):
<distribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
lea    0xe9c(%rip),%rdi
lea    0xea0(%rip),%rsi
mov    $0x263,%edx
mov    $0xffff,%ecx
xor    %r8d,%r8d
lea    0xf15(%rip),%r9
mov    $0x0,%al
call   1030 <_log_write@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1206 <distribute+0xc6>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1040 <randomNumber@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11db <distribute+0x9b>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    $0x0,%al
call   1060 <wfmalloc@plt>
movslq %eax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11f3 <distribute+0xb3>
movslq -0x24(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11f8 <distribute+0xb8>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1194 <distribute+0x54>
lea    0xdf3(%rip),%rdi
lea    0xdf7(%rip),%rsi
mov    $0x26f,%edx
mov    $0xffff,%ecx
mov    $0x1,%r8d
lea    0xe69(%rip),%r9
mov    $0x0,%al
call   1030 <_log_write@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distribute>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,0x4(%rsp)
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xe9c(%rip),%rdi
lea    0xea0(%rip),%rsi
lea    0xf22(%rip),%r9
mov    $0x263,%edx
mov    $0xffff,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1030 <_log_write@plt>
test   %ebp,%ebp
jle    11d8 <distribute+0x98>
mov    %ebp,%ebp
xor    %r14d,%r14d
jmp    11b5 <distribute+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %eax,%rdi
call   1050 <malloc@plt>
mov    %rax,(%r12,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbp
je     11d8 <distribute+0x98>
mov    %ebx,%edi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <randomNumber@plt>
cmp    $0x1,%r15d
jne    11a0 <distribute+0x60>
mov    %eax,%edi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1060 <wfmalloc@plt>
cltq
jmp    11a8 <distribute+0x68>
lea    0xe21(%rip),%rdi
lea    0xe25(%rip),%rsi
lea    0xea7(%rip),%r9
mov    $0x26f,%edx
mov    $0xffff,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_log_write@plt>

LLVM IR (-O0):
@__FUNCTION__.distribute = [11 x i8] c"distribute\00"
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ashish-17/wfmalloc/refs/heads/master/src/main.c\00"
@.str.1 = [1 x i8] zeroinitializer
define void @distribute(i32 %0, i32 %1, i32 %2, i8** %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8** %3, i8*** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%15 = call i32 (i8*, i8*, i32, i32, i32, i8*, ...) bitcast (i32 (...)* @_log_write to i32 (i8*, i8*, i32, i32, i32, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.distribute, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 611, i32 65535, i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %14
store i32 0, i32* %14
br label %16
16: ; preds = %45, %6
%17 = load i32, i32* %14
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %48
20: ; preds = %16
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = call i32 (i32, i32, ...) bitcast (i32 (...)* @randomNumber to i32 (i32, i32, ...)*)(i32 %21, i32 %22)
store i32 %23, i32* %13
%24 = load i32, i32* %11
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %36
26: ; preds = %20
%27 = load i32, i32* %13
%28 = load i32, i32* %12
%29 = call i32 (i32, i32, ...) bitcast (i32 (...)* @wfmalloc to i32 (i32, i32, ...)*)(i32 %27, i32 %28)
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i8*
%32 = load i8**, i8*** %10
%33 = load i32, i32* %14
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
store i8* %31, i8** %35
br label %44
36: ; preds = %20
%37 = load i32, i32* %13
%38 = sext i32 %37 to i64
%39 = call i8* @malloc(i64 %38)
%40 = load i8**, i8*** %10
%41 = load i32, i32* %14
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
store i8* %39, i8** %43
br label %44
44: ; preds = %36, %26
br label %45
45: ; preds = %44
%46 = load i32, i32* %14
%47 = add nsw i32 %46, 1
store i32 %47, i32* %14
br label %16
48: ; preds = %16
%49 = call i32 (i8*, i8*, i32, i32, i32, i8*, ...) bitcast (i32 (...)* @_log_write to i32 (i8*, i8*, i32, i32, i32, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.distribute, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 623, i32 65535, i32 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__FUNCTION__.distribute = [11 x i8] c"distribute\00"
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ashish-17/wfmalloc/refs/heads/master/src/main.c\00"
@.str.1 = [1 x i8] zeroinitializer
define void @distribute(i32 %0, i32 %1, i32 %2, i8** nocapture writeonly %3, i32 %4, i32 %5) {
%7 = tail call i32 (i8*, i8*, i32, i32, i32, i8*, ...) bitcast (i32 (...)* @_log_write to i32 (i8*, i8*, i32, i32, i32, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.distribute, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 611, i32 65535, i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = icmp eq i32 %4, 1
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %9, %22
%13 = phi i64 [ 0, %9 ], [ %25, %22 ]
%14 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @randomNumber to i32 (i32, i32, ...)*)(i32 %1, i32 %2)
br i1 %10, label %15, label %19
15: ; preds = %12
%16 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @wfmalloc to i32 (i32, i32, ...)*)(i32 %14, i32 %5)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
br label %22
19: ; preds = %12
%20 = sext i32 %14 to i64
%21 = tail call i8* @malloc(i64 %20)
br label %22
22: ; preds = %15, %19
%23 = phi i8* [ %18, %15 ], [ %21, %19 ]
%24 = getelementptr inbounds i8*, i8** %3, i64 %13
store i8* %23, i8** %24
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %27, label %12
27: ; preds = %22, %6
%28 = tail call i32 (i8*, i8*, i32, i32, i32, i8*, ...) bitcast (i32 (...)* @_log_write to i32 (i8*, i8*, i32, i32, i32, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.distribute, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 623, i32 65535, i32 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
ret void
}