#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_value(struct hdr_histogram *, scalar_t__);
bool hdr_record_corrected_value(struct hdr_histogram *h, int64_t value,
                                int64_t expected_interval) {
  if (!hdr_record_value(h, value)) {
    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_value(h, missing_value)) {
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<hdr_record_corrected_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <hdr_record_value@plt>
cmp    $0x0,%eax
jne    1146 <hdr_record_corrected_value+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <hdr_record_corrected_value+0xb7>
cmpq   $0x0,-0x20(%rbp)
jle    115f <hdr_record_corrected_value+0x4f>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jg     116b <hdr_record_corrected_value+0x5b>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <hdr_record_corrected_value+0xb7>
mov    -0x18(%rbp),%rax
sub    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jl     11c0 <hdr_record_corrected_value+0xb0>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <hdr_record_value@plt>
cmp    $0x0,%eax
jne    11a7 <hdr_record_corrected_value+0x97>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <hdr_record_corrected_value+0xb7>
jmp    11ac <hdr_record_corrected_value+0x9c>
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    1177 <hdr_record_corrected_value+0x67>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hdr_record_corrected_value>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <hdr_record_value@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     115f <hdr_record_corrected_value+0x4f>
test   %r12,%r12
jle    1159 <hdr_record_corrected_value+0x49>
sub    %r12,%rbx
jle    1159 <hdr_record_corrected_value+0x49>
mov    %rbx,%rbp
nopw   0x0(%rax,%rax,1)
sub    %r12,%rbp
jl     1159 <hdr_record_corrected_value+0x49>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <hdr_record_value@plt>
mov    %rbp,%rbx
test   %eax,%eax
jne    1140 <hdr_record_corrected_value+0x30>
jmp    115f <hdr_record_corrected_value+0x4f>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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