#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 /*<<< orphan*/ fzz_addRule(char *);
int /*<<< orphan*/ fzz_calculateOutput();
int /*<<< orphan*/ fzz_deinit();
double fzz_getOutput(int /*<<< orphan*/);
int /*<<< orphan*/ fzz_init(int, int);
int /*<<< orphan*/ fzz_initInputFcns(int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ fzz_initOutputFcns(int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ fzz_printSystem();
int /*<<< orphan*/ fzz_setInput(int /*<<< orphan*/, double);
int /*<<< orphan*/ fzz_setInputFcn(int, int /*<<< orphan*/, double, double,
                                   double, char *);
int /*<<< orphan*/ fzz_setOutputFcn(int, int /*<<< orphan*/, double, double,
                                    double, char *);
int /*<<< orphan*/ printf(char *, ...);
void fzz_test1() {
  double x1 = 0;
  fzz_init(1, 1);
  fzz_initInputFcns(0, 3, "input");
  fzz_initOutputFcns(0, 3, "output");
  fzz_setInputFcn(0, 0, -2.0, -1.0, 0.0, "negative");
  fzz_setInputFcn(1, 0, -1.0, 0.0, 1.0, "zero");
  fzz_setInputFcn(2, 0, 0.0, 1.0, 2.0, "pozitive");
  fzz_setOutputFcn(0, 0, -2.0, -1.0, 0.0, "negative");
  fzz_setOutputFcn(1, 0, -1.0, 0.0, 1.0, "zero");
  fzz_setOutputFcn(2, 0, 0.0, 1.0, 2.0, "pozitive");
  fzz_addRule("if input is negative then output is pozitive");
  fzz_addRule("if input is zero then output is zero");
  fzz_addRule("if input is pozitive then output is negative");
  fzz_printSystem();
  printf("\nCalculated outputs:\n");
  for (x1 = -1; x1 <= 1; x1 += 0.1) {
    fzz_setInput(0, x1);
    fzz_calculateOutput();
    printf("%+f => %+f\n", x1, fzz_getOutput(0));
  }
  fzz_deinit();
}


x86 assembly (clang, -O0):
<fzz_test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1050 <fzz_init@plt>
xor    %edi,%edi
mov    $0x3,%esi
lea    0xe3e(%rip),%rdx
call   10a0 <fzz_initInputFcns@plt>
xor    %edi,%edi
mov    $0x3,%esi
lea    0xe31(%rip),%rdx
call   1060 <fzz_initOutputFcns@plt>
xor    %esi,%esi
movsd  0xe0c(%rip),%xmm0
movsd  0xdec(%rip),%xmm1
xorps  %xmm2,%xmm2
lea    0xe8d(%rip),%rdx
mov    %esi,%edi
call   10d0 <fzz_setInputFcn@plt>
mov    $0x1,%edi
xor    %esi,%esi
movsd  0xdcc(%rip),%xmm0
xorps  %xmm1,%xmm1
movsd  0xdc9(%rip),%xmm2
lea    0xe3c(%rip),%rdx
call   10d0 <fzz_setInputFcn@plt>
mov    $0x2,%edi
xor    %esi,%esi
xorps  %xmm0,%xmm0
movsd  0xdab(%rip),%xmm1
movsd  0xdab(%rip),%xmm2
lea    0xded(%rip),%rdx
call   10d0 <fzz_setInputFcn@plt>
xor    %esi,%esi
movsd  0xd9d(%rip),%xmm0
movsd  0xd7d(%rip),%xmm1
xorps  %xmm2,%xmm2
lea    0xe1e(%rip),%rdx
mov    %esi,%edi
call   10e0 <fzz_setOutputFcn@plt>
mov    $0x1,%edi
xor    %esi,%esi
movsd  0xd5d(%rip),%xmm0
xorps  %xmm1,%xmm1
movsd  0xd5a(%rip),%xmm2
lea    0xdcd(%rip),%rdx
call   10e0 <fzz_setOutputFcn@plt>
mov    $0x2,%edi
xor    %esi,%esi
xorps  %xmm0,%xmm0
movsd  0xd3c(%rip),%xmm1
movsd  0xd3c(%rip),%xmm2
lea    0xd7e(%rip),%rdx
call   10e0 <fzz_setOutputFcn@plt>
lea    0xd4e(%rip),%rdi
call   1040 <fzz_addRule@plt>
lea    0xd6f(%rip),%rdi
call   1040 <fzz_addRule@plt>
lea    0xd88(%rip),%rdi
call   1040 <fzz_addRule@plt>
mov    $0x0,%al
call   1030 <fzz_printSystem@plt>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movsd  0xcdf(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xcda(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     138a <fzz_test1+0x1ca>
movsd  -0x8(%rbp),%xmm0
xor    %edi,%edi
call   1070 <fzz_setInput@plt>
mov    $0x0,%al
call   1090 <fzz_calculateOutput@plt>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xor    %edi,%edi
call   10b0 <fzz_getOutput@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
lea    0xd5e(%rip),%rdi
mov    $0x2,%al
call   1080 <printf@plt>
movsd  0xca5(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1326 <fzz_test1+0x166>
mov    $0x0,%al
call   10c0 <fzz_deinit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fzz_test1>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <fzz_init@plt>
lea    0xe39(%rip),%rdx
xor    %edi,%edi
mov    $0x3,%esi
call   10b0 <fzz_initInputFcns@plt>
lea    0xe2c(%rip),%rdx
xor    %edi,%edi
mov    $0x3,%esi
call   1070 <fzz_initOutputFcns@plt>
lea    0xe96(%rip),%r14
movsd  0xde3(%rip),%xmm0
movsd  0xde3(%rip),%xmm1
xorps  %xmm2,%xmm2
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   10e0 <fzz_setInputFcn@plt>
lea    0xe47(%rip),%r15
movsd  0xdcd(%rip),%xmm2
xorps  %xmm1,%xmm1
mov    $0x1,%edi
xor    %esi,%esi
movsd  0xdb3(%rip),%xmm0
mov    %r15,%rdx
call   10e0 <fzz_setInputFcn@plt>
lea    0xdf5(%rip),%rbx
movsd  0xdac(%rip),%xmm2
xorps  %xmm0,%xmm0
mov    $0x2,%edi
xor    %esi,%esi
movsd  0xd92(%rip),%xmm1
mov    %rbx,%rdx
call   10e0 <fzz_setInputFcn@plt>
xorps  %xmm2,%xmm2
xor    %edi,%edi
xor    %esi,%esi
movsd  0xd6b(%rip),%xmm0
movsd  0xd6b(%rip),%xmm1
mov    %r14,%rdx
call   10f0 <fzz_setOutputFcn@plt>
xorps  %xmm1,%xmm1
mov    $0x1,%edi
xor    %esi,%esi
movsd  0xd51(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xd43(%rip),%xmm0
movsd  0xd43(%rip),%xmm2
mov    %r15,%rdx
call   10f0 <fzz_setOutputFcn@plt>
xorpd  %xmm0,%xmm0
mov    $0x2,%edi
xor    %esi,%esi
movsd  0xd28(%rip),%xmm1
movsd  0xd28(%rip),%xmm2
mov    %rbx,%rdx
call   10f0 <fzz_setOutputFcn@plt>
lea    0xd36(%rip),%rdi
call   1040 <fzz_addRule@plt>
lea    0xd57(%rip),%rdi
call   1040 <fzz_addRule@plt>
lea    0xd70(%rip),%rdi
call   1040 <fzz_addRule@plt>
xor    %eax,%eax
call   1030 <fzz_printSystem@plt>
lea    0xd96(%rip),%rdi
call   1050 <puts@plt>
lea    0xd7e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
movsd  0x8(%rsp),%xmm0
call   1080 <fzz_setInput@plt>
xor    %eax,%eax
call   10a0 <fzz_calculateOutput@plt>
xor    %edi,%edi
call   10c0 <fzz_getOutput@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1090 <printf@plt>
movsd  0x8(%rsp),%xmm1
addsd  0xca4(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xc86(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    1340 <fzz_test1+0x170>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    10d0 <fzz_deinit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"input\00"
@.str.1 = [7 x i8] c"output\00"
@.str.2 = [9 x i8] c"negative\00"
@.str.3 = [5 x i8] c"zero\00"
@.str.4 = [9 x i8] c"pozitive\00"
@.str.5 = [45 x i8] c"if input is negative then output is pozitive\00"
@.str.6 = [37 x i8] c"if input is zero then output is zero\00"
@.str.7 = [45 x i8] c"if input is pozitive then output is negative\00"
@.str.8 = [22 x i8] c"\0ACalculated outputs:\0A\00"
@.str.9 = [12 x i8] c"%+f => %+f\0A\00"
define void @fzz_test1() {
%1 = alloca double
store double 0.000000e+00, double* %1
%2 = call i32 @fzz_init(i32 1, i32 1)
%3 = call i32 @fzz_initInputFcns(i32 0, i32 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @fzz_initOutputFcns(i32 0, i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @fzz_setInputFcn(i32 0, i32 0, double -2.000000e+00, double -1.000000e+00, double 0.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @fzz_setInputFcn(i32 1, i32 0, double -1.000000e+00, double 0.000000e+00, double 1.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @fzz_setInputFcn(i32 2, i32 0, double 0.000000e+00, double 1.000000e+00, double 2.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @fzz_setOutputFcn(i32 0, i32 0, double -2.000000e+00, double -1.000000e+00, double 0.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @fzz_setOutputFcn(i32 1, i32 0, double -1.000000e+00, double 0.000000e+00, double 1.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @fzz_setOutputFcn(i32 2, i32 0, double 0.000000e+00, double 1.000000e+00, double 2.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @fzz_addRule(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @fzz_addRule(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @fzz_addRule(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 (...) @fzz_printSystem()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
store double -1.000000e+00, double* %1
br label %16
16: ; preds = %26, %0
%17 = load double, double* %1
%18 = fcmp ole double %17, 1.000000e+00
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load double, double* %1
%21 = call i32 @fzz_setInput(i32 0, double %20)
%22 = call i32 (...) @fzz_calculateOutput()
%23 = load double, double* %1
%24 = call double @fzz_getOutput(i32 0)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), double %23, double %24)
br label %26
26: ; preds = %19
%27 = load double, double* %1
%28 = fadd double %27, 1.000000e-01
store double %28, double* %1
br label %16
29: ; preds = %16
%30 = call i32 (...) @fzz_deinit()
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"input\00"
@.str.1 = [7 x i8] c"output\00"
@.str.2 = [9 x i8] c"negative\00"
@.str.3 = [5 x i8] c"zero\00"
@.str.4 = [9 x i8] c"pozitive\00"
@.str.5 = [45 x i8] c"if input is negative then output is pozitive\00"
@.str.6 = [37 x i8] c"if input is zero then output is zero\00"
@.str.7 = [45 x i8] c"if input is pozitive then output is negative\00"
@.str.9 = [12 x i8] c"%+f => %+f\0A\00"
@str = [21 x i8] c"\0ACalculated outputs:\00"
define void @fzz_test1() {
%1 = tail call i32 @fzz_init(i32 1, i32 1)
%2 = tail call i32 @fzz_initInputFcns(i32 0, i32 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @fzz_initOutputFcns(i32 0, i32 3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @fzz_setInputFcn(i32 0, i32 0, double -2.000000e+00, double -1.000000e+00, double 0.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @fzz_setInputFcn(i32 1, i32 0, double -1.000000e+00, double 0.000000e+00, double 1.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @fzz_setInputFcn(i32 2, i32 0, double 0.000000e+00, double 1.000000e+00, double 2.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @fzz_setOutputFcn(i32 0, i32 0, double -2.000000e+00, double -1.000000e+00, double 0.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @fzz_setOutputFcn(i32 1, i32 0, double -1.000000e+00, double 0.000000e+00, double 1.000000e+00, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 @fzz_setOutputFcn(i32 2, i32 0, double 0.000000e+00, double 1.000000e+00, double 2.000000e+00, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @fzz_addRule(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 @fzz_addRule(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%12 = tail call i32 @fzz_addRule(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%13 = tail call i32 (...) @fzz_printSystem()
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %0, %15
%16 = phi double [ -1.000000e+00, %0 ], [ %21, %15 ]
%17 = tail call i32 @fzz_setInput(i32 0, double %16)
%18 = tail call i32 (...) @fzz_calculateOutput()
%19 = tail call double @fzz_getOutput(i32 0)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), double %16, double %19)
%21 = fadd double %16, 1.000000e-01
%22 = fcmp ugt double %21, 1.000000e+00
br i1 %22, label %23, label %15
23: ; preds = %15
%24 = tail call i32 (...) @fzz_deinit()
ret void
}