#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 int /*<<< orphan*/ uint8_t;
typedef scalar_t__ uint64_t;
typedef unsigned long long uint32_t;

/* Variables and functions */
int /*<<< orphan*/ advance_window(scalar_t__, scalar_t__, int /*<<< orphan*/ *,
                                  unsigned long long);
int /*<<< orphan*/ set_bit(int, scalar_t__, int /*<<< orphan*/ *,
                           unsigned long long);
uint64_t track_seq_no(uint32_t seq_hi, uint32_t seq_lo, uint64_t T,
                      uint8_t *window, uint32_t W) {
  uint64_t seq =
      ((uint64_t)(((uint32_t)(seq_hi)) * 4294967296ull + ((uint32_t)(seq_lo))));
  if (seq > T) {
    advance_window(seq, T, window, W);
    T = seq;
  }
  set_bit(1, seq, window, W);
  return T;
}


x86 assembly (clang, -O0):
<track_seq_no>:
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    -0x8(%rbp),%rax
shl    $0x20,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    1177 <track_seq_no+0x57>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <advance_window@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%edi
call   1030 <set_bit@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<track_seq_no>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rdi,%rbx
shl    $0x20,%rbx
add    %rsi,%rbx
cmp    %rdx,%rbx
jle    1154 <track_seq_no+0x34>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <advance_window@plt>
mov    %rbx,%r12
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <set_bit@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @track_seq_no(i64 %0, i64 %1, i64 %2, i32* %3, i64 %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i64
store i64 %0, i64* %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i32* %3, i32** %9
store i64 %4, i64* %10
%12 = load i64, i64* %6
%13 = mul i64 %12, 4294967296
%14 = load i64, i64* %7
%15 = add i64 %13, %14
store i64 %15, i64* %11
%16 = load i64, i64* %11
%17 = load i64, i64* %8
%18 = icmp sgt i64 %16, %17
br i1 %18, label %19, label %26
19: ; preds = %5
%20 = load i64, i64* %11
%21 = load i64, i64* %8
%22 = load i32*, i32** %9
%23 = load i64, i64* %10
%24 = call i32 @advance_window(i64 %20, i64 %21, i32* %22, i64 %23)
%25 = load i64, i64* %11
store i64 %25, i64* %8
br label %26
26: ; preds = %19, %5
%27 = load i64, i64* %11
%28 = load i32*, i32** %9
%29 = load i64, i64* %10
%30 = call i32 @set_bit(i32 1, i64 %27, i32* %28, i64 %29)
%31 = load i64, i64* %8
ret i64 %31
}

LLVM IR (-O2):
define i64 @track_seq_no(i64 %0, i64 %1, i64 %2, i32* %3, i64 %4) {
%6 = shl i64 %0, 32
%7 = add i64 %6, %1
%8 = icmp sgt i64 %7, %2
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @advance_window(i64 %7, i64 %2, i32* %3, i64 %4)
br label %11
11: ; preds = %9, %5
%12 = phi i64 [ %7, %9 ], [ %2, %5 ]
%13 = tail call i32 @set_bit(i32 1, i64 %7, i32* %3, i64 %4)
ret i64 %12
}