#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ printf(char *, size_t, double);
double runtest(size_t, size_t, int, void *(*)());
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void run_all_tests(size_t payload, int num_cpu, int num_threads,
                   size_t cache_kb, void *test()) {
  size_t step = 32 * 1024;
  for (size_t buffer_length = step;
       buffer_length < 2 * num_cpu * cache_kb * 1024 / num_threads;
       buffer_length += step) {
    double elapsedtime = runtest(payload, buffer_length, num_threads, test);
    printf("buffer length = %zu elapsedtime = %f\n", buffer_length,
           elapsedtime);
    fflush(stdout);
    fprintf(stderr,
            "DEBUG %s:%d: "
            "------------------------------------------------------------------"
            "---------\n"
            "",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/tamas-p/ht/refs/heads/master/htg.c",
            146);
  }
}


x86 assembly (clang, -O0):
<run_all_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movq   $0x8000,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
cltq
imul   -0x18(%rbp),%rax
shl    $0xa,%rax
movslq -0x10(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jae    120a <run_all_tests+0xca>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1060 <runtest@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%rsi
movsd  -0x38(%rbp),%xmm0
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
lea    0xe91(%rip),%rdx
mov    $0x92,%ecx
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    116a <run_all_tests+0x2a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_all_tests>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %edx,%r12d
mov    %rdi,%r15
add    %esi,%esi
movslq %esi,%rax
imul   %rcx,%rax
shl    $0xa,%rax
movslq %edx,%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1183 <run_all_tests+0x43>
xor    %edx,%edx
div    %rcx
mov    %rax,%rbx
cmp    $0x8001,%rbx
jae    1193 <run_all_tests+0x53>
jmp    11f7 <run_all_tests+0xb7>
xor    %edx,%edx
div    %r12d
mov    %eax,%ebx
cmp    $0x8001,%rbx
jb     11f7 <run_all_tests+0xb7>
mov    $0x8000,%ebp
lea    0xee1(%rip),%r13
nop
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
mov    %r14,%rcx
call   1060 <runtest@plt>
lea    0xe48(%rip),%rdi
mov    %rbp,%rsi
call   1030 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
mov    %r13,%rdx
mov    $0x92,%ecx
call   1040 <fprintf@plt>
add    $0x8000,%rbp
cmp    %rbx,%rbp
jb     11a0 <run_all_tests+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"buffer length = %zu elapsedtime = %f\0A\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [90 x i8] c"DEBUG %s:%d: ---------------------------------------------------------------------------\0A\00"
@.str.2 = [125 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/tamas-p/ht/refs/heads/master/htg.c\00"
define void @run_all_tests(i64 %0, i32 %1, i32 %2, i64 %3, i8* (...)* %4) {
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8* (...)*
%11 = alloca i64
%12 = alloca i64
%13 = alloca double
store i64 %0, i64* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i64 %3, i64* %9
store i8* (...)* %4, i8* (...)** %10
store i64 32768, i64* %11
%14 = load i64, i64* %11
store i64 %14, i64* %12
br label %15
15: ; preds = %40, %5
%16 = load i64, i64* %12
%17 = load i32, i32* %7
%18 = mul nsw i32 2, %17
%19 = sext i32 %18 to i64
%20 = load i64, i64* %9
%21 = mul i64 %19, %20
%22 = mul i64 %21, 1024
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = udiv i64 %22, %24
%26 = icmp ult i64 %16, %25
br i1 %26, label %27, label %44
27: ; preds = %15
%28 = load i64, i64* %6
%29 = load i64, i64* %12
%30 = load i32, i32* %8
%31 = load i8* (...)*, i8* (...)** %10
%32 = call double @runtest(i64 %28, i64 %29, i32 %30, i8* (...)* %31)
store double %32, double* %13
%33 = load i64, i64* %12
%34 = load double, double* %13
%35 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %33, double %34)
%36 = load i32, i32* @stdout
%37 = call i32 @fflush(i32 %36)
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.2, i64 0, i64 0), i32 146)
br label %40
40: ; preds = %27
%41 = load i64, i64* %11
%42 = load i64, i64* %12
%43 = add i64 %42, %41
store i64 %43, i64* %12
br label %15
44: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"buffer length = %zu elapsedtime = %f\0A\00"
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [90 x i8] c"DEBUG %s:%d: ---------------------------------------------------------------------------\0A\00"
@.str.2 = [125 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/tamas-p/ht/refs/heads/master/htg.c\00"
define void @run_all_tests(i64 %0, i32 %1, i32 %2, i64 %3, i8* (...)* %4) {
%6 = shl nsw i32 %1, 1
%7 = sext i32 %6 to i64
%8 = shl i64 %3, 10
%9 = mul i64 %8, %7
%10 = sext i32 %2 to i64
%11 = udiv i64 %9, %10
%12 = icmp ugt i64 %11, 32768
br i1 %12, label %14, label %13
13: ; preds = %14, %5
ret void
14: ; preds = %5, %14
%15 = phi i64 [ %22, %14 ], [ 32768, %5 ]
%16 = tail call double @runtest(i64 %0, i64 %15, i32 %2, i8* (...)* %4)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %15, double %16)
%18 = load i32, i32* @stdout
%19 = tail call i32 @fflush(i32 %18)
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.2, i64 0, i64 0), i32 146)
%22 = add i64 %15, 32768
%23 = icmp ult i64 %22, %11
br i1 %23, label %14, label %13
}