#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 abs(int);
int /*<<< orphan*/ deriv1(int /*<<< orphan*/, int);
int deriv2(int, int);
int hpfilt(int, int);
int lpfilt(int, int);
int mvwint(int, int);
int QRSFilter(int datum, int init) {
  if (init) {
    hpfilt(0, 1);
    lpfilt(0, 1);
    mvwint(0, 1);
    deriv1(0, 1);
    deriv2(0, 1);
  }
  datum = lpfilt(datum, 0);
  datum = hpfilt(datum, 0);
  datum = deriv2(datum, 0);
  datum = abs(datum);
  datum = mvwint(datum, 0);
  return datum;
}


x86 assembly (clang, -O0):
<QRSFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b4 <QRSFilter+0x54>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <hpfilt@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <lpfilt@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <mvwint@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1080 <deriv1@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <deriv2@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1070 <lpfilt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1030 <hpfilt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1050 <deriv2@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1060 <mvwint@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QRSFilter>:
push   %rbx
mov    %edi,%ebx
test   %esi,%esi
je     1193 <QRSFilter+0x43>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <hpfilt@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <lpfilt@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <mvwint@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <deriv1@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <deriv2@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <lpfilt@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1030 <hpfilt@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1040 <deriv2@plt>
mov    %eax,%edi
neg    %edi
cmovs  %eax,%edi
xor    %esi,%esi
pop    %rbx
jmp    1050 <mvwint@plt>

LLVM IR (-O0):
define i32 @QRSFilter(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = call i32 @hpfilt(i32 0, i32 1)
%9 = call i32 @lpfilt(i32 0, i32 1)
%10 = call i32 @mvwint(i32 0, i32 1)
%11 = call i32 @deriv1(i32 0, i32 1)
%12 = call i32 @deriv2(i32 0, i32 1)
br label %13
13: ; preds = %7, %2
%14 = load i32, i32* %3
%15 = call i32 @lpfilt(i32 %14, i32 0)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = call i32 @hpfilt(i32 %16, i32 0)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = call i32 @deriv2(i32 %18, i32 0)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = call i32 @abs(i32 %20)
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 @mvwint(i32 %22, i32 0)
store i32 %23, i32* %3
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @QRSFilter(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = tail call i32 @hpfilt(i32 0, i32 1)
%6 = tail call i32 @lpfilt(i32 0, i32 1)
%7 = tail call i32 @mvwint(i32 0, i32 1)
%8 = tail call i32 @deriv1(i32 0, i32 1)
%9 = tail call i32 @deriv2(i32 0, i32 1)
br label %10
10: ; preds = %4, %2
%11 = tail call i32 @lpfilt(i32 %0, i32 0)
%12 = tail call i32 @hpfilt(i32 %11, i32 0)
%13 = tail call i32 @deriv2(i32 %12, i32 0)
%14 = tail call i32 @llvm.abs.i32(i32 %13, i1 true)
%15 = tail call i32 @mvwint(i32 %14, i32 0)
ret i32 %15
}