#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 PIDcontroller(double, double, double *, double *, double, double,
                     double);
double MotorControl(double TarPWM, double NowPWM, double *PWMPE, double *PWMDS,
                    int MotorNum) {
  static double result = 0.0;
  switch (MotorNum) {
  case 1:
    result = PIDcontroller(TarPWM, NowPWM, PWMPE, PWMDS, 1.0, 0.0, 0.0);
    break;
  case 2:
    result = PIDcontroller(TarPWM, NowPWM, PWMPE, PWMDS, 1.0, 0.0, 0.0);
    break;
  case 3:
    result = PIDcontroller(TarPWM, NowPWM, PWMPE, PWMDS, 1.0, 0.0, 0.0);
    break;
  case 4:
    result = PIDcontroller(TarPWM, NowPWM, PWMPE, PWMDS, 1.0, 0.0, 0.0);
    break;
  }
  return result;
}


x86 assembly (clang, -O0):
<MotorControl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     1219 <MotorControl+0x109>
mov    -0x30(%rbp),%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movsd  0xe90(%rip),%xmm2
xorps  %xmm4,%xmm4
movaps %xmm4,%xmm3
call   1030 <PIDcontroller@plt>
movsd  %xmm0,0x2ead(%rip)
jmp    1219 <MotorControl+0x109>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movsd  0xe5e(%rip),%xmm2
xorps  %xmm4,%xmm4
movaps %xmm4,%xmm3
call   1030 <PIDcontroller@plt>
movsd  %xmm0,0x2e7b(%rip)
jmp    1219 <MotorControl+0x109>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movsd  0xe2c(%rip),%xmm2
xorps  %xmm4,%xmm4
movaps %xmm4,%xmm3
call   1030 <PIDcontroller@plt>
movsd  %xmm0,0x2e49(%rip)
jmp    1219 <MotorControl+0x109>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movsd  0xdfa(%rip),%xmm2
xorps  %xmm4,%xmm4
movaps %xmm4,%xmm3
call   1030 <PIDcontroller@plt>
movsd  %xmm0,0x2e17(%rip)
movsd  0x2e0f(%rip),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MotorControl>:
push   %rax
add    $0xffffffff,%edx
cmp    $0x3,%edx
ja     1146 <MotorControl+0x36>
lea    0xee8(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movsd  0xecf(%rip),%xmm2
xorps  %xmm3,%xmm3
xorps  %xmm4,%xmm4
call   1030 <PIDcontroller@plt>
movsd  %xmm0,0x2eec(%rip)
pop    %rax
ret
movsd  0x2ee2(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@MotorControl.result = internal global double 0.000000e+00
define double @MotorControl(double %0, double %1, double* %2, double* %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
store double %0, double* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
%11 = load i32, i32* %10
switch i32 %11, label %36 [
i32 1, label %12
i32 2, label %18
i32 3, label %24
i32 4, label %30
]
12: ; preds = %5
%13 = load double, double* %6
%14 = load double, double* %7
%15 = load double*, double** %8
%16 = load double*, double** %9
%17 = call double @PIDcontroller(double %13, double %14, double* %15, double* %16, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %17, double* @MotorControl.result
br label %36
18: ; preds = %5
%19 = load double, double* %6
%20 = load double, double* %7
%21 = load double*, double** %8
%22 = load double*, double** %9
%23 = call double @PIDcontroller(double %19, double %20, double* %21, double* %22, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %23, double* @MotorControl.result
br label %36
24: ; preds = %5
%25 = load double, double* %6
%26 = load double, double* %7
%27 = load double*, double** %8
%28 = load double*, double** %9
%29 = call double @PIDcontroller(double %25, double %26, double* %27, double* %28, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %29, double* @MotorControl.result
br label %36
30: ; preds = %5
%31 = load double, double* %6
%32 = load double, double* %7
%33 = load double*, double** %8
%34 = load double*, double** %9
%35 = call double @PIDcontroller(double %31, double %32, double* %33, double* %34, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %35, double* @MotorControl.result
br label %36
36: ; preds = %5, %30, %24, %18, %12
%37 = load double, double* @MotorControl.result
ret double %37
}

LLVM IR (-O2):
@MotorControl.result = internal unnamed_addr global double 0.000000e+00
define double @MotorControl(double %0, double %1, double* %2, double* %3, i32 %4) {
switch i32 %4, label %6 [
i32 1, label %8
i32 2, label %10
i32 3, label %12
i32 4, label %14
]
6: ; preds = %5
%7 = load double, double* @MotorControl.result
br label %16
8: ; preds = %5
%9 = tail call double @PIDcontroller(double %0, double %1, double* %2, double* %3, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %9, double* @MotorControl.result
br label %16
10: ; preds = %5
%11 = tail call double @PIDcontroller(double %0, double %1, double* %2, double* %3, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %11, double* @MotorControl.result
br label %16
12: ; preds = %5
%13 = tail call double @PIDcontroller(double %0, double %1, double* %2, double* %3, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %13, double* @MotorControl.result
br label %16
14: ; preds = %5
%15 = tail call double @PIDcontroller(double %0, double %1, double* %2, double* %3, double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
store double %15, double* @MotorControl.result
br label %16
16: ; preds = %6, %14, %12, %10, %8
%17 = phi double [ %7, %6 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ]
ret double %17
}