#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 */
double inclino_getX_value(int);
double inclino_getY_value(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ relay_set_state(int, int);
double rot_get_value(int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ socket_tx(unsigned char *, int);
void processSetSensorValue(int relayNbPlus, int relayNbMoins, int sensorNb,
                           double sensorValueToBe,
                           unsigned char *toSendOnFinish, int length) {
  bool notFinish = true;
  double sensorValue;
  double sensorValueToBeMin = sensorValueToBe - 3;
  double sensorValueToBeMax = sensorValueToBe + 3;
  printf("sensorValueToBe=%.1f +- 3\n", sensorValueToBe);
  while (notFinish) {
    if (sensorNb == 4)
      sensorValue = inclino_getX_value(4);
    else if (sensorNb == 5)
      sensorValue = inclino_getY_value(5);
    else
      sensorValue = rot_get_value(sensorNb);
    if (sensorValue < sensorValueToBeMin) {
      relay_set_state(relayNbMoins, 1);
      relay_set_state(relayNbPlus, 0);
    } else if (sensorValue > sensorValueToBeMax) {
      relay_set_state(relayNbPlus, 1);
      relay_set_state(relayNbMoins, 0);
    } else {
      relay_set_state(relayNbPlus, 1);
      relay_set_state(relayNbMoins, 1);
      notFinish = false;
    }
    printf("sensorValue=%.1f\n", sensorValue);
    sleep(1);
  }
  socket_tx(toSendOnFinish, length);
}


x86 assembly (clang, -O0):
<processSetSensorValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe4d(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
je     12c8 <processSetSensorValue+0x158>
cmpl   $0x4,-0xc(%rbp)
jne    11f6 <processSetSensorValue+0x86>
mov    $0x4,%edi
call   1080 <inclino_getX_value@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    1226 <processSetSensorValue+0xb6>
cmpl   $0x5,-0xc(%rbp)
jne    1214 <processSetSensorValue+0xa4>
mov    $0x5,%edi
call   1060 <inclino_getY_value@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    1221 <processSetSensorValue+0xb1>
mov    -0xc(%rbp),%edi
call   1030 <rot_get_value@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    1226 <processSetSensorValue+0xb6>
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1256 <processSetSensorValue+0xe6>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1070 <relay_set_state@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1070 <relay_set_state@plt>
jmp    12a8 <processSetSensorValue+0x138>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1282 <processSetSensorValue+0x112>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1070 <relay_set_state@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1070 <relay_set_state@plt>
jmp    12a3 <processSetSensorValue+0x133>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1070 <relay_set_state@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1070 <relay_set_state@plt>
movl   $0x0,-0x28(%rbp)
jmp    12a8 <processSetSensorValue+0x138>
movsd  -0x30(%rbp),%xmm0
lea    0xd6f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    11ce <processSetSensorValue+0x5e>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <socket_tx@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processSetSensorValue>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%ebx
mov    %esi,%r12d
mov    %edi,%ebp
movsd  0xe6d(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe63(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe69(%rip),%r13
jmp    11fd <processSetSensorValue+0x8d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%edi
mov    $0x1,%esi
call   1070 <relay_set_state@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1070 <relay_set_state@plt>
mov    %r13,%rdi
movsd  (%rsp),%xmm0
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
cmp    $0x5,%ebx
je     1220 <processSetSensorValue+0xb0>
cmp    $0x4,%ebx
jne    1230 <processSetSensorValue+0xc0>
mov    $0x4,%edi
call   1080 <inclino_getX_value@plt>
jmp    1237 <processSetSensorValue+0xc7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x5,%edi
call   1060 <inclino_getY_value@plt>
jmp    1237 <processSetSensorValue+0xc7>
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <rot_get_value@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
ucomisd %xmm1,%xmm0
ja     11d0 <processSetSensorValue+0x60>
mov    %ebp,%edi
mov    $0x1,%esi
call   1070 <relay_set_state@plt>
movsd  (%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
mov    %r12d,%edi
ja     11df <processSetSensorValue+0x6f>
mov    %r12d,%edi
mov    $0x1,%esi
call   1070 <relay_set_state@plt>
lea    0xdab(%rip),%rdi
movsd  (%rsp),%xmm0
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    %r15,%rdi
mov    %r14d,%esi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <socket_tx@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"sensorValueToBe=%.1f +- 3\0A\00"
@.str.1 = [18 x i8] c"sensorValue=%.1f\0A\00"
define void @processSetSensorValue(i32 %0, i32 %1, i32 %2, double %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double %3, double* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store i32 1, i32* %13
%17 = load double, double* %10
%18 = fsub double %17, 3.000000e+00
store double %18, double* %15
%19 = load double, double* %10
%20 = fadd double %19, 3.000000e+00
store double %20, double* %16
%21 = load double, double* %10
%22 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %21)
br label %23
23: ; preds = %64, %6
%24 = load i32, i32* %13
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %68
26: ; preds = %23
%27 = load i32, i32* %9
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call double @inclino_getX_value(i32 4)
store double %30, double* %14
br label %40
31: ; preds = %26
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 5
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call double @inclino_getY_value(i32 5)
store double %35, double* %14
br label %39
36: ; preds = %31
%37 = load i32, i32* %9
%38 = call double @rot_get_value(i32 %37)
store double %38, double* %14
br label %39
39: ; preds = %36, %34
br label %40
40: ; preds = %39, %29
%41 = load double, double* %14
%42 = load double, double* %15
%43 = fcmp olt double %41, %42
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* %8
%46 = call i32 @relay_set_state(i32 %45, i32 1)
%47 = load i32, i32* %7
%48 = call i32 @relay_set_state(i32 %47, i32 0)
br label %64
49: ; preds = %40
%50 = load double, double* %14
%51 = load double, double* %16
%52 = fcmp ogt double %50, %51
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i32, i32* %7
%55 = call i32 @relay_set_state(i32 %54, i32 1)
%56 = load i32, i32* %8
%57 = call i32 @relay_set_state(i32 %56, i32 0)
br label %63
58: ; preds = %49
%59 = load i32, i32* %7
%60 = call i32 @relay_set_state(i32 %59, i32 1)
%61 = load i32, i32* %8
%62 = call i32 @relay_set_state(i32 %61, i32 1)
store i32 0, i32* %13
br label %63
63: ; preds = %58, %53
br label %64
64: ; preds = %63, %44
%65 = load double, double* %14
%66 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %65)
%67 = call i32 @sleep(i32 1)
br label %23
68: ; preds = %23
%69 = load i8*, i8** %11
%70 = load i32, i32* %12
%71 = call i32 @socket_tx(i8* %69, i32 %70)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"sensorValueToBe=%.1f +- 3\0A\00"
@.str.1 = [18 x i8] c"sensorValue=%.1f\0A\00"
define void @processSetSensorValue(i32 %0, i32 %1, i32 %2, double %3, i8* %4, i32 %5) {
%7 = fadd double %3, -3.000000e+00
%8 = fadd double %3, 3.000000e+00
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %3)
br label %10
10: ; preds = %25, %6
switch i32 %2, label %15 [
i32 4, label %11
i32 5, label %13
]
11: ; preds = %10
%12 = tail call double @inclino_getX_value(i32 4)
br label %17
13: ; preds = %10
%14 = tail call double @inclino_getY_value(i32 5)
br label %17
15: ; preds = %10
%16 = tail call double @rot_get_value(i32 %2)
br label %17
17: ; preds = %13, %15, %11
%18 = phi double [ %12, %11 ], [ %14, %13 ], [ %16, %15 ]
%19 = fcmp olt double %18, %7
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @relay_set_state(i32 %1, i32 1)
br label %25
22: ; preds = %17
%23 = fcmp ogt double %18, %8
%24 = tail call i32 @relay_set_state(i32 %0, i32 1)
br i1 %23, label %25, label %30
25: ; preds = %22, %20
%26 = phi i32 [ %0, %20 ], [ %1, %22 ]
%27 = tail call i32 @relay_set_state(i32 %26, i32 0)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %18)
%29 = tail call i32 @sleep(i32 1)
br label %10
30: ; preds = %22
%31 = tail call i32 @relay_set_state(i32 %1, i32 1)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %18)
%33 = tail call i32 @sleep(i32 1)
%34 = tail call i32 @socket_tx(i8* %4, i32 %5)
ret void
}