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


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,-0xc(%rbp)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1030 <hpfilt@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1050 <deriv2@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1060 <mvwint@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%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
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = call i32 @hpfilt(i32 0, i32 1)
%10 = call i32 @lpfilt(i32 0, i32 1)
%11 = call i32 @mvwint(i32 0, i32 1)
%12 = call i32 @deriv1(i32 0, i32 1)
%13 = call i32 @deriv2(i32 0, i32 1)
br label %14
14: ; preds = %8, %2
%15 = load i32, i32* %3
%16 = call i32 @lpfilt(i32 %15, i32 0)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = call i32 @hpfilt(i32 %17, i32 0)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = call i32 @deriv2(i32 %19, i32 0)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = call i32 @abs(i32 %21)
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = call i32 @mvwint(i32 %23, i32 0)
store i32 %24, i32* %5
%25 = load i32, i32* %5
ret i32 %25
}

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
}