#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 constrain(double, double, double);
int /*<<< orphan*/ delay(int);
scalar_t__ digitalRead(char const);
unsigned long millis();
double SetValue(double Value, double MinValue, double MaxValue,
                double SmallStep, double LargeStep, unsigned long *press_time,
                const char Pin_up, const char Pin_dn) {
  double StepSize;
  double ScrollTime = 2;
  Value = constrain(Value, MinValue, MaxValue);
  if ((millis() - *press_time) / 1000 >= ScrollTime)
    StepSize = LargeStep;
  else
    StepSize = SmallStep;
  if (digitalRead(Pin_up) == 0) {
    delay(60);
    if (digitalRead(Pin_up) == 0) {
      if (Value + StepSize > MaxValue)
        Value = MaxValue;
      else
        Value += StepSize;
    }
  } else if (digitalRead(Pin_dn) == 0) {
    delay(60);
    if (digitalRead(Pin_dn) == 0) {
      if (Value - StepSize < MinValue)
        Value = MinValue;
      else
        Value -= StepSize;
    }
  } else
    *press_time = millis();
  return Value;
}


x86 assembly (clang, -O0):
<SetValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dl,%al
mov    %sil,%cl
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %rdi,-0x30(%rbp)
mov    %cl,-0x31(%rbp)
mov    %al,-0x32(%rbp)
movabs $0x4000000000000000,%rax
mov    %rax,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1050 <constrain@plt>
movsd  %xmm0,-0x8(%rbp)
xor    %eax,%eax
call   1060 <millis@plt>
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
cvtsi2sd %rdx,%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     11dc <SetValue+0x9c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11e6 <SetValue+0xa6>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsbl -0x31(%rbp),%edi
call   1030 <digitalRead@plt>
cmp    $0x0,%rax
jne    1253 <SetValue+0x113>
mov    $0x3c,%edi
call   1040 <delay@plt>
movsbl -0x31(%rbp),%edi
call   1030 <digitalRead@plt>
cmp    $0x0,%rax
jne    124e <SetValue+0x10e>
movsd  -0x8(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    123a <SetValue+0xfa>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1249 <SetValue+0x109>
movsd  -0x40(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124e <SetValue+0x10e>
jmp    12de <SetValue+0x19e>
movsbl -0x32(%rbp),%edi
call   1030 <digitalRead@plt>
cmp    $0x0,%rax
jne    12c8 <SetValue+0x188>
mov    $0x3c,%edi
call   1040 <delay@plt>
movsbl -0x32(%rbp),%edi
call   1030 <digitalRead@plt>
cmp    $0x0,%rax
jne    12c3 <SetValue+0x183>
movsd  -0x8(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ab <SetValue+0x16b>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12be <SetValue+0x17e>
movsd  -0x40(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c3 <SetValue+0x183>
jmp    12d9 <SetValue+0x199>
mov    $0x0,%al
call   1060 <millis@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
jmp    12de <SetValue+0x19e>
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetValue>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
movsd  %xmm4,0x8(%rsp)
movsd  %xmm3,0x28(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x20(%rsp)
call   1050 <constrain@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1060 <millis@plt>
sub    (%rbx),%rax
cmp    $0x7d0,%rax
jae    1191 <SetValue+0x51>
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1030 <digitalRead@plt>
test   %rax,%rax
je     11bf <SetValue+0x7f>
movsbl %r14b,%ebp
mov    %ebp,%edi
call   1030 <digitalRead@plt>
test   %rax,%rax
je     11ef <SetValue+0xaf>
xor    %eax,%eax
call   1060 <millis@plt>
mov    %rax,(%rbx)
movsd  0x10(%rsp),%xmm0
jmp    121f <SetValue+0xdf>
mov    $0x3c,%edi
call   1040 <delay@plt>
movsbl %bpl,%edi
call   1030 <digitalRead@plt>
test   %rax,%rax
movsd  0x10(%rsp),%xmm0
jne    121f <SetValue+0xdf>
addsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
minsd  %xmm0,%xmm1
jmp    121b <SetValue+0xdb>
mov    $0x3c,%edi
call   1040 <delay@plt>
mov    %ebp,%edi
call   1030 <digitalRead@plt>
test   %rax,%rax
movsd  0x10(%rsp),%xmm0
jne    121f <SetValue+0xdf>
subsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
maxsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @SetValue(double %0, double %1, double %2, double %3, double %4, i64* %5, i8 signext %6, i8 signext %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i64*
%15 = alloca i8
%16 = alloca i8
%17 = alloca double
%18 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store i64* %5, i64** %14
store i8 %6, i8* %15
store i8 %7, i8* %16
store double 2.000000e+00, double* %18
%19 = load double, double* %9
%20 = load double, double* %10
%21 = load double, double* %11
%22 = call double @constrain(double %19, double %20, double %21)
store double %22, double* %9
%23 = call i64 (...) @millis()
%24 = load i64*, i64** %14
%25 = load i64, i64* %24
%26 = sub i64 %23, %25
%27 = udiv i64 %26, 1000
%28 = uitofp i64 %27 to double
%29 = load double, double* %18
%30 = fcmp oge double %28, %29
br i1 %30, label %31, label %33
31: ; preds = %8
%32 = load double, double* %13
store double %32, double* %17
br label %35
33: ; preds = %8
%34 = load double, double* %12
store double %34, double* %17
br label %35
35: ; preds = %33, %31
%36 = load i8, i8* %15
%37 = call i64 @digitalRead(i8 signext %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %58
39: ; preds = %35
%40 = call i32 @delay(i32 60)
%41 = load i8, i8* %15
%42 = call i64 @digitalRead(i8 signext %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %57
44: ; preds = %39
%45 = load double, double* %9
%46 = load double, double* %17
%47 = fadd double %45, %46
%48 = load double, double* %11
%49 = fcmp ogt double %47, %48
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = load double, double* %11
store double %51, double* %9
br label %56
52: ; preds = %44
%53 = load double, double* %17
%54 = load double, double* %9
%55 = fadd double %54, %53
store double %55, double* %9
br label %56
56: ; preds = %52, %50
br label %57
57: ; preds = %56, %39
br label %85
58: ; preds = %35
%59 = load i8, i8* %16
%60 = call i64 @digitalRead(i8 signext %59)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %81
62: ; preds = %58
%63 = call i32 @delay(i32 60)
%64 = load i8, i8* %16
%65 = call i64 @digitalRead(i8 signext %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %80
67: ; preds = %62
%68 = load double, double* %9
%69 = load double, double* %17
%70 = fsub double %68, %69
%71 = load double, double* %10
%72 = fcmp olt double %70, %71
br i1 %72, label %73, label %75
73: ; preds = %67
%74 = load double, double* %10
store double %74, double* %9
br label %79
75: ; preds = %67
%76 = load double, double* %17
%77 = load double, double* %9
%78 = fsub double %77, %76
store double %78, double* %9
br label %79
79: ; preds = %75, %73
br label %80
80: ; preds = %79, %62
br label %84
81: ; preds = %58
%82 = call i64 (...) @millis()
%83 = load i64*, i64** %14
store i64 %82, i64* %83
br label %84
84: ; preds = %81, %80
br label %85
85: ; preds = %84, %57
%86 = load double, double* %9
ret double %86
}

LLVM IR (-O2):
define double @SetValue(double %0, double %1, double %2, double %3, double %4, i64* nocapture %5, i8 signext %6, i8 signext %7) {
%9 = tail call double @constrain(double %0, double %1, double %2)
%10 = tail call i64 (...) @millis()
%11 = load i64, i64* %5
%12 = sub i64 %10, %11
%13 = icmp ugt i64 %12, 1999
%14 = select i1 %13, double %4, double %3
%15 = tail call i64 @digitalRead(i8 signext %6)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %8
%18 = tail call i32 @delay(i32 60)
%19 = tail call i64 @digitalRead(i8 signext %6)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %38
21: ; preds = %17
%22 = fadd double %9, %14
%23 = fcmp ogt double %22, %2
%24 = select i1 %23, double %2, double %22
br label %38
25: ; preds = %8
%26 = tail call i64 @digitalRead(i8 signext %7)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = tail call i32 @delay(i32 60)
%30 = tail call i64 @digitalRead(i8 signext %7)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = fsub double %9, %14
%34 = fcmp olt double %33, %1
%35 = select i1 %34, double %1, double %33
br label %38
36: ; preds = %25
%37 = tail call i64 (...) @millis()
store i64 %37, i64* %5
br label %38
38: ; preds = %32, %21, %36, %28, %17
%39 = phi double [ %9, %17 ], [ %9, %28 ], [ %9, %36 ], [ %24, %21 ], [ %35, %32 ]
ret double %39
}