#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 */
scalar_t__ determine_size(int, double);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ srand(int);
long determine_nr_of_files(int median_file_size, double max_file_size,
                           long bytes_to_consume) {
  long nr_of_files = 0, byte_total = 0;
  srand(1);
  while (byte_total < bytes_to_consume) {
    byte_total += determine_size(median_file_size, max_file_size);
    nr_of_files++;
  }
  srand(1);
  fflush(NULL);
  return nr_of_files;
}


x86 assembly (clang, -O0):
<determine_nr_of_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x1,%edi
call   1030 <srand@plt>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1192 <determine_nr_of_files+0x62>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
call   1050 <determine_size@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115e <determine_nr_of_files+0x2e>
mov    $0x1,%edi
call   1030 <srand@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_nr_of_files>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movsd  %xmm0,(%rsp)
mov    %edi,%r15d
mov    $0x1,%edi
call   1030 <srand@plt>
test   %r14,%r14
jle    117b <determine_nr_of_files+0x4b>
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15d,%edi
movsd  (%rsp),%xmm0
call   1050 <determine_size@plt>
add    %rax,%rbp
add    $0x1,%rbx
cmp    %r14,%rbp
jl     1160 <determine_nr_of_files+0x30>
jmp    117d <determine_nr_of_files+0x4d>
xor    %ebx,%ebx
mov    $0x1,%edi
call   1030 <srand@plt>
xor    %edi,%edi
call   1040 <fflush@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @determine_nr_of_files(i32 %0, double %1, i64 %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 %0, i32* %4
store double %1, double* %5
store i64 %2, i64* %6
store i64 0, i64* %7
store i64 0, i64* %8
%9 = call i32 @srand(i32 1)
br label %10
10: ; preds = %14, %3
%11 = load i64, i64* %8
%12 = load i64, i64* %6
%13 = icmp slt i64 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i32, i32* %4
%16 = load double, double* %5
%17 = call i64 @determine_size(i32 %15, double %16)
%18 = load i64, i64* %8
%19 = add nsw i64 %18, %17
store i64 %19, i64* %8
%20 = load i64, i64* %7
%21 = add nsw i64 %20, 1
store i64 %21, i64* %7
br label %10
22: ; preds = %10
%23 = call i32 @srand(i32 1)
%24 = call i32 @fflush(i32* null)
%25 = load i64, i64* %7
ret i64 %25
}

LLVM IR (-O2):
define i64 @determine_nr_of_files(i32 %0, double %1, i64 %2) {
%4 = tail call i32 @srand(i32 1)
%5 = icmp sgt i64 %2, 0
br i1 %5, label %6, label %13
6: ; preds = %3, %6
%7 = phi i64 [ %10, %6 ], [ 0, %3 ]
%8 = phi i64 [ %11, %6 ], [ 0, %3 ]
%9 = tail call i64 @determine_size(i32 %0, double %1)
%10 = add nsw i64 %9, %7
%11 = add nuw nsw i64 %8, 1
%12 = icmp slt i64 %10, %2
br i1 %12, label %6, label %13
13: ; preds = %6, %3
%14 = phi i64 [ 0, %3 ], [ %11, %6 ]
%15 = tail call i32 @srand(i32 1)
%16 = tail call i32 @fflush(i32* null)
ret i64 %14
}