#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 */
struct hdr_histogram {
  int dummy;
};
typedef scalar_t__ int64_t;

/* Variables and functions */
int /*<<< orphan*/ hdr_record_values(struct hdr_histogram *, scalar_t__,
                                     scalar_t__);
bool hdr_record_corrected_values(struct hdr_histogram *h, int64_t value,
                                 int64_t count, int64_t expected_interval) {
  if (!hdr_record_values(h, value, count)) {
    return false;
  }
  if (expected_interval <= 0 || value <= expected_interval) {
    return true;
  }
  int64_t missing_value = value - expected_interval;
  for (; missing_value >= expected_interval;
       missing_value -= expected_interval) {
    if (!hdr_record_values(h, missing_value, count)) {
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<hdr_record_corrected_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <hdr_record_values@plt>
cmp    $0x0,%eax
jne    114e <hdr_record_corrected_values+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <hdr_record_corrected_values+0xc3>
cmpq   $0x0,-0x28(%rbp)
jle    1167 <hdr_record_corrected_values+0x57>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     1173 <hdr_record_corrected_values+0x63>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <hdr_record_corrected_values+0xc3>
mov    -0x18(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jl     11cc <hdr_record_corrected_values+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <hdr_record_values@plt>
cmp    $0x0,%eax
jne    11b3 <hdr_record_corrected_values+0xa3>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <hdr_record_corrected_values+0xc3>
jmp    11b8 <hdr_record_corrected_values+0xa8>
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    117f <hdr_record_corrected_values+0x6f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hdr_record_corrected_values>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%r13
call   1030 <hdr_record_values@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     1162 <hdr_record_corrected_values+0x52>
test   %r12,%r12
jle    115c <hdr_record_corrected_values+0x4c>
sub    %r12,%rbp
jle    115c <hdr_record_corrected_values+0x4c>
mov    %rbp,%rbx
sub    %r12,%rbx
jl     115c <hdr_record_corrected_values+0x4c>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1030 <hdr_record_values@plt>
mov    %rbx,%rbp
test   %eax,%eax
jne    1140 <hdr_record_corrected_values+0x30>
jmp    1162 <hdr_record_corrected_values+0x52>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hdr_histogram = type { i32 }
define i32 @hdr_record_corrected_values(%struct.hdr_histogram* %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i32
%6 = alloca %struct.hdr_histogram*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store %struct.hdr_histogram* %0, %struct.hdr_histogram** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i64 %3, i64* %9
%11 = load %struct.hdr_histogram*, %struct.hdr_histogram** %6
%12 = load i64, i64* %7
%13 = load i64, i64* %8
%14 = call i32 @hdr_record_values(%struct.hdr_histogram* %11, i64 %12, i64 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %4
store i32 0, i32* %5
br label %46
17: ; preds = %4
%18 = load i64, i64* %9
%19 = icmp sle i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17
%21 = load i64, i64* %7
%22 = load i64, i64* %9
%23 = icmp sle i64 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20, %17
store i32 1, i32* %5
br label %46
25: ; preds = %20
%26 = load i64, i64* %7
%27 = load i64, i64* %9
%28 = sub nsw i64 %26, %27
store i64 %28, i64* %10
br label %29
29: ; preds = %41, %25
%30 = load i64, i64* %10
%31 = load i64, i64* %9
%32 = icmp sge i64 %30, %31
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = load %struct.hdr_histogram*, %struct.hdr_histogram** %6
%35 = load i64, i64* %10
%36 = load i64, i64* %8
%37 = call i32 @hdr_record_values(%struct.hdr_histogram* %34, i64 %35, i64 %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %33
store i32 0, i32* %5
br label %46
40: ; preds = %33
br label %41
41: ; preds = %40
%42 = load i64, i64* %9
%43 = load i64, i64* %10
%44 = sub nsw i64 %43, %42
store i64 %44, i64* %10
br label %29
45: ; preds = %29
store i32 1, i32* %5
br label %46
46: ; preds = %45, %39, %24, %16
%47 = load i32, i32* %5
ret i32 %47
}

LLVM IR (-O2):
%struct.hdr_histogram = type { i32 }
define i32 @hdr_record_corrected_values(%struct.hdr_histogram* %0, i64 %1, i64 %2, i64 %3) {
%5 = tail call i32 @hdr_record_values(%struct.hdr_histogram* %0, i64 %1, i64 %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %4
%8 = icmp sgt i64 %3, 0
%9 = icmp sgt i64 %1, %3
%10 = and i1 %8, %9
br i1 %10, label %11, label %18
11: ; preds = %7, %15
%12 = phi i64 [ %13, %15 ], [ %1, %7 ]
%13 = sub nsw i64 %12, %3
%14 = icmp slt i64 %13, %3
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = tail call i32 @hdr_record_values(%struct.hdr_histogram* %0, i64 %13, i64 %2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %11
18: ; preds = %15, %11, %7, %4
%19 = phi i32 [ 0, %4 ], [ 1, %7 ], [ 1, %11 ], [ 0, %15 ]
ret i32 %19
}