#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*/ printf(char *, ...);
ArrayUsage(char *szItem, int items, int maxitems, int itemsize) {
  float percentage = maxitems ? items * 100.0 / maxitems : 0.0;
  printf("%-12s  %7i/%-7i  %7i/%-7i  (%4.1f%%)", szItem, items, maxitems,
         items * itemsize, maxitems * itemsize, percentage);
  if (percentage > 80.0)
    printf("VERY FULL!\n");
  else if (percentage > 95.0)
    printf("SIZE DANGER!\n");
  else if (percentage > 99.9)
    printf("SIZE OVERFLOW!!!\n");
  else
    printf("\n");
  return items * itemsize;
}


x86 assembly (clang, -O0):
<ArrayUsage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1153 <ArrayUsage+0x43>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xec4(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1160 <ArrayUsage+0x50>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1160 <ArrayUsage+0x50>
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
imul   -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9d
imul   -0x14(%rbp),%r9d
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe86(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe56(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11cf <ArrayUsage+0xbf>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1243 <ArrayUsage+0x133>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe30(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11fd <ArrayUsage+0xed>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123e <ArrayUsage+0x12e>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    122b <ArrayUsage+0x11b>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1239 <ArrayUsage+0x129>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123e <ArrayUsage+0x12e>
jmp    1243 <ArrayUsage+0x133>
mov    -0xc(%rbp),%eax
imul   -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ArrayUsage>:
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r9d
mov    %edx,%ecx
mov    %esi,%edx
mov    %rdi,%rsi
test   %ecx,%ecx
je     1161 <ArrayUsage+0x31>
cvtsi2sd %edx,%xmm0
mulsd  0xeb1(%rip),%xmm0
cvtsi2sd %ecx,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
jmp    1164 <ArrayUsage+0x34>
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r9d,%ebx
imul   %edx,%ebx
imul   %ecx,%r9d
lea    0xea5(%rip),%rdi
mov    %ebx,%r8d
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xe6f(%rip),%xmm0
jbe    11a9 <ArrayUsage+0x79>
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
jmp    11e3 <ArrayUsage+0xb3>
ucomisd 0xe5f(%rip),%xmm0
jbe    11c1 <ArrayUsage+0x91>
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
jmp    11e3 <ArrayUsage+0xb3>
ucomisd 0xe4f(%rip),%xmm0
jbe    11d9 <ArrayUsage+0xa9>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
jmp    11e3 <ArrayUsage+0xb3>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"%-12s %7i/%-7i %7i/%-7i (%4.1f%%)\00"
@.str.1 = [12 x i8] c"VERY FULL!\0A\00"
@.str.2 = [14 x i8] c"SIZE DANGER!\0A\00"
@.str.3 = [18 x i8] c"SIZE OVERFLOW!!!\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @ArrayUsage(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %4
%13 = load i32, i32* %6
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 1.000000e+02
%16 = load i32, i32* %7
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
br label %20
19: ; preds = %4
br label %20
20: ; preds = %19, %12
%21 = phi double [ %18, %12 ], [ 0.000000e+00, %19 ]
%22 = fptrunc double %21 to float
store float %22, float* %9
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = load i32, i32* %8
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = mul nsw i32 %29, %30
%32 = load float, float* %9
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %24, i32 %25, i32 %28, i32 %31, double %33)
%35 = load float, float* %9
%36 = fpext float %35 to double
%37 = fcmp ogt double %36, 8.000000e+01
br i1 %37, label %38, label %40
38: ; preds = %20
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %56
40: ; preds = %20
%41 = load float, float* %9
%42 = fpext float %41 to double
%43 = fcmp ogt double %42, 9.500000e+01
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %55
46: ; preds = %40
%47 = load float, float* %9
%48 = fpext float %47 to double
%49 = fcmp ogt double %48, 9.990000e+01
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %54
52: ; preds = %46
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %55
55: ; preds = %54, %44
br label %56
56: ; preds = %55, %38
%57 = load i32, i32* %6
%58 = load i32, i32* %8
%59 = mul nsw i32 %57, %58
ret i32 %59
}

LLVM IR (-O2):
@.str = [37 x i8] c"%-12s %7i/%-7i %7i/%-7i (%4.1f%%)\00"
@str = [17 x i8] c"SIZE OVERFLOW!!!\00"
@str.5 = [13 x i8] c"SIZE DANGER!\00"
@str.6 = [11 x i8] c"VERY FULL!\00"
define i32 @ArrayUsage(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %13, label %6
6: ; preds = %4
%7 = sitofp i32 %1 to double
%8 = fmul double %7, 1.000000e+02
%9 = sitofp i32 %2 to double
%10 = fdiv double %8, %9
%11 = fptrunc double %10 to float
%12 = fpext float %11 to double
br label %13
13: ; preds = %4, %6
%14 = phi double [ %12, %6 ], [ 0.000000e+00, %4 ]
%15 = mul nsw i32 %3, %1
%16 = mul nsw i32 %3, %2
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i32 %2, i32 %15, i32 %16, double %14)
%18 = fcmp ogt double %14, 8.000000e+01
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
br label %31
21: ; preds = %13
%22 = fcmp ogt double %14, 9.500000e+01
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
br label %31
25: ; preds = %21
%26 = fcmp ogt double %14, 9.990000e+01
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %31
29: ; preds = %25
%30 = tail call i32 @putchar(i32 10)
br label %31
31: ; preds = %23, %29, %27, %19
ret i32 %15
}