#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 */
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ tmfprintf(int /*<<< orphan*/ *, char *, char const *, long,
                             long, long);
void check_fragments(const char *action, ssize_t total, ssize_t n_was,
                     ssize_t n_is, ssize_t delta, FILE *log) {
  if (NULL == action)
    return;
  if ((n_is < (n_was - delta)) || (n_is > (n_was + delta))) {
    (void)tmfprintf(log, "%s [%ld] bytes out of [%ld], last=[%ld]\n", action,
                    (long)n_is, (long)total, (long)n_was);
  }
}


x86 assembly (clang, -O0):
<check_fragments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
jne    1141 <check_fragments+0x31>
jmp    118b <check_fragments+0x7b>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    -0x28(%rbp),%rcx
cmp    %rcx,%rax
jl     116b <check_fragments+0x5b>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    -0x28(%rbp),%rcx
cmp    %rcx,%rax
jle    118b <check_fragments+0x7b>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe7a(%rip),%rsi
call   1030 <tmfprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_fragments>:
test   %rdi,%rdi
je     1131 <check_fragments+0x21>
mov    %rdx,%rax
mov    %rsi,%r10
mov    %rdi,%rdx
mov    %rax,%rsi
sub    %r8,%rsi
cmp    %rcx,%rsi
jg     1132 <check_fragments+0x22>
add    %rax,%r8
cmp    %rcx,%r8
jl     1132 <check_fragments+0x22>
ret
lea    0xec7(%rip),%rsi
mov    %r9,%rdi
mov    %r10,%r8
mov    %rax,%r9
jmp    1030 <tmfprintf@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"%s [%ld] bytes out of [%ld], last=[%ld]\0A\00"
define void @check_fragments(i8* %0, i64 %1, i64 %2, i64 %3, i64 %4, i32* %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32*
store i8* %0, i8** %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i32* %5, i32** %12
%13 = load i8*, i8** %7
%14 = icmp eq i8* null, %13
br i1 %14, label %15, label %16
15: ; preds = %6
br label %35
16: ; preds = %6
%17 = load i64, i64* %10
%18 = load i64, i64* %9
%19 = load i64, i64* %11
%20 = sub nsw i64 %18, %19
%21 = icmp slt i64 %17, %20
br i1 %21, label %28, label %22
22: ; preds = %16
%23 = load i64, i64* %10
%24 = load i64, i64* %9
%25 = load i64, i64* %11
%26 = add nsw i64 %24, %25
%27 = icmp sgt i64 %23, %26
br i1 %27, label %28, label %35
28: ; preds = %22, %16
%29 = load i32*, i32** %12
%30 = load i8*, i8** %7
%31 = load i64, i64* %10
%32 = load i64, i64* %8
%33 = load i64, i64* %9
%34 = call i32 @tmfprintf(i32* %29, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %30, i64 %31, i64 %32, i64 %33)
br label %35
35: ; preds = %15, %28, %22
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"%s [%ld] bytes out of [%ld], last=[%ld]\0A\00"
define void @check_fragments(i8* %0, i64 %1, i64 %2, i64 %3, i64 %4, i32* %5) {
%7 = icmp eq i8* %0, null
br i1 %7, label %16, label %8
8: ; preds = %6
%9 = sub nsw i64 %2, %4
%10 = icmp sgt i64 %9, %3
%11 = add nsw i64 %4, %2
%12 = icmp slt i64 %11, %3
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 @tmfprintf(i32* %5, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %3, i64 %1, i64 %2)
br label %16
16: ; preds = %8, %6, %14
ret void
}