#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*/ _stp_warn(char *, ...);
int _stp_stat_calc_buckets(int stop, int start, int interval) {
  int buckets;
  if (interval == 0) {
    _stp_warn("histogram: interval cannot be zero.\n");
    return 0;
  }
  buckets = (stop - start) / interval + 3;
  if (buckets > 128 || buckets < 3) {
    _stp_warn("histogram: Number of buckets must be between 1 and %d\n"
              "Number_of_buckets = (stop - start) / interval.\n"
              "Please adjust your start, stop, and interval values.\n",
              128 - 2);
    return 0;
  }
  return buckets;
}


x86 assembly (clang, -O0):
<_stp_stat_calc_buckets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1145 <_stp_stat_calc_buckets+0x35>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <_stp_warn@plt>
movl   $0x0,-0x4(%rbp)
jmp    1191 <_stp_stat_calc_buckets+0x81>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jg     116c <_stp_stat_calc_buckets+0x5c>
cmpl   $0x3,-0x14(%rbp)
jge    118b <_stp_stat_calc_buckets+0x7b>
lea    0xeb2(%rip),%rdi
mov    $0x7e,%esi
mov    $0x0,%al
call   1030 <_stp_warn@plt>
movl   $0x0,-0x4(%rbp)
jmp    1191 <_stp_stat_calc_buckets+0x81>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_stp_stat_calc_buckets>:
push   %rbx
test   %edx,%edx
je     113a <_stp_stat_calc_buckets+0x2a>
mov    %edx,%ecx
sub    %esi,%edi
mov    %edi,%eax
cltd
idiv   %ecx
cmp    $0x7e,%eax
jb     114c <_stp_stat_calc_buckets+0x3c>
lea    0xefb(%rip),%rdi
xor    %ebx,%ebx
mov    $0x7e,%esi
xor    %eax,%eax
call   1030 <_stp_warn@plt>
jmp    1151 <_stp_stat_calc_buckets+0x41>
lea    0xebf(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <_stp_warn@plt>
jmp    1151 <_stp_stat_calc_buckets+0x41>
mov    %eax,%ebx
add    $0x3,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"histogram: interval cannot be zero.\0A\00"
@.str.1 = [155 x i8] c"histogram: Number of buckets must be between 1 and %d\0ANumber_of_buckets = (stop - start) / interval.\0APlease adjust your start, stop, and interval values.\0A\00"
define i32 @_stp_stat_calc_buckets(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 (i8*, ...) @_stp_warn(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %29
13: ; preds = %3
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = sub nsw i32 %14, %15
%17 = load i32, i32* %7
%18 = sdiv i32 %16, %17
%19 = add nsw i32 %18, 3
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp sgt i32 %20, 128
br i1 %21, label %25, label %22
22: ; preds = %13
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 3
br i1 %24, label %25, label %27
25: ; preds = %22, %13
%26 = call i32 (i8*, ...) @_stp_warn(i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 126)
store i32 0, i32* %4
br label %29
27: ; preds = %22
%28 = load i32, i32* %8
store i32 %28, i32* %4
br label %29
29: ; preds = %27, %25, %11
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
@.str = [37 x i8] c"histogram: interval cannot be zero.\0A\00"
@.str.1 = [155 x i8] c"histogram: Number of buckets must be between 1 and %d\0ANumber_of_buckets = (stop - start) / interval.\0APlease adjust your start, stop, and interval values.\0A\00"
define i32 @_stp_stat_calc_buckets(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @_stp_warn(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %15
7: ; preds = %3
%8 = sub nsw i32 %0, %1
%9 = sdiv i32 %8, %2
%10 = icmp ugt i32 %9, 125
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 (i8*, ...) @_stp_warn(i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 126)
br label %15
13: ; preds = %7
%14 = add nuw nsw i32 %9, 3
br label %15
15: ; preds = %13, %11, %5
%16 = phi i32 [ 0, %5 ], [ 0, %11 ], [ %14, %13 ]
ret i32 %16
}