#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*/ mot_Close();
int /*<<< orphan*/ mot_Init();
int /*<<< orphan*/ mot_Run(float, float, float, float);
int /*<<< orphan*/ mot_SetLeds(int, int, int, int);
int /*<<< orphan*/ mot_Stop();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_yield();
int tolower(int /*<<< orphan*/);
int /*<<< orphan*/ util_getch();
int main() {
  printf("Motorboard Test Program ... Press q to quit\r\n");
  printf("Motor: 1,2,3,4=run single motor at 50%  5=run all motors at 50% "
         ",=throttle up 1%  .=throttle down 1%  space=stop\r\n");
  printf("Leds:  a=loff  s=green  d=orange  f=red\r\n");
  mot_Init();
  float throttle1 = 0;
  float throttle2 = 0;
  float throttle3 = 0;
  float throttle4 = 0;
  float step = 0.01;
  while (1) {
    int c = tolower(util_getch());
    if (c == 'q')
      break;
    if (c == '1') {
      printf("\rRun Motor1 50%            ");
      throttle1 = .50;
      throttle2 = 0;
      throttle3 = 0;
      throttle4 = 0;
      mot_Run(throttle1, throttle2, throttle3, throttle4);
    }
    if (c == '2') {
      printf("\rRun Motor2 50%            ");
      throttle1 = 0;
      throttle2 = .50;
      throttle3 = 0;
      throttle4 = 0;
      mot_Run(throttle1, throttle2, throttle3, throttle4);
    }
    if (c == '3') {
      printf("\rRun Motor3 50%            ");
      throttle1 = 0;
      throttle2 = 0;
      throttle3 = .50;
      throttle4 = 0;
      mot_Run(throttle1, throttle2, throttle3, throttle4);
    }
    if (c == '4') {
      printf("\rRun Motor4 50%            ");
      throttle1 = 0;
      throttle2 = 0;
      throttle3 = 0;
      throttle4 = .50;
      mot_Run(throttle1, throttle2, throttle3, throttle4);
    }
    if (c == '5') {
      printf("\rRun All Motors 50%            ");
      throttle1 = .50;
      throttle2 = .50;
      throttle3 = .50;
      throttle4 = .50;
      mot_Run(throttle1, throttle2, throttle3, throttle4);
    }
    if (c == ',') {
      printf("\rThrottle down            ");
      if (throttle1 > step)
        throttle1 -= step;
      if (throttle2 > step)
        throttle2 -= step;
      if (throttle3 > step)
        throttle3 -= step;
      if (throttle4 > step)
        throttle4 -= step;
      mot_Run(throttle1, throttle2, throttle3, throttle4);
    }
    if (c == '.') {
      printf("\rThrottle up            ");
      if (throttle1 > 0)
        throttle1 += step;
      if (throttle2 > 0)
        throttle2 += step;
      if (throttle3 > 0)
        throttle3 += step;
      if (throttle4 > 0)
        throttle4 += step;
      mot_Run(throttle1, throttle2, throttle3, throttle4);
    }
    if (c == ' ') {
      printf("\rStop            ");
      mot_Stop();
    }
    if (c == 'a') {
      printf("\rLeds off            ");
      mot_SetLeds(0, 0, 0, 0);
    }
    if (c == 's') {
      printf("\rLeds green            ");
      mot_SetLeds(2, 2, 2, 2);
    }
    if (c == 'd') {
      printf("\rLeds orange            ");
      mot_SetLeds(3, 3, 3, 3);
    }
    if (c == 'f') {
      printf("\rLeds red            ");
      mot_SetLeds(1, 1, 1, 1);
    }
    pthread_yield();
  }
  mot_Close();
  printf("\nDone...\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <mot_Init@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe0e(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1050 <util_getch@plt>
mov    %eax,%edi
call   1090 <tolower@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x71,-0x1c(%rbp)
jne    1217 <main+0x87>
jmp    15ee <main+0x45e>
cmpl   $0x31,-0x1c(%rbp)
jne    126b <main+0xdb>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
movss  0xdcf(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
call   1030 <mot_Run@plt>
cmpl   $0x32,-0x1c(%rbp)
jne    12bf <main+0x12f>
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xd73(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
call   1030 <mot_Run@plt>
cmpl   $0x33,-0x1c(%rbp)
jne    1313 <main+0x183>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xd17(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
call   1030 <mot_Run@plt>
cmpl   $0x34,-0x1c(%rbp)
jne    1367 <main+0x1d7>
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xcbb(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
call   1030 <mot_Run@plt>
cmpl   $0x35,-0x1c(%rbp)
jne    13ca <main+0x23a>
lea    0xdcb(%rip),%rdi
call   1040 <printf@plt>
movss  0xc7f(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xc72(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xc65(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xc58(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
call   1030 <mot_Run@plt>
cmpl   $0x2c,-0x1c(%rbp)
jne    1481 <main+0x2f1>
lea    0xd88(%rip),%rdi
call   1040 <printf@plt>
movss  -0x8(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1402 <main+0x272>
movss  -0x18(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1424 <main+0x294>
movss  -0x18(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1446 <main+0x2b6>
movss  -0x18(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x14(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    1468 <main+0x2d8>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
call   1030 <mot_Run@plt>
cmpl   $0x2e,-0x1c(%rbp)
jne    1530 <main+0x3a0>
lea    0xcec(%rip),%rdi
call   1040 <printf@plt>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    14b7 <main+0x327>
movss  -0x18(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    14d7 <main+0x347>
movss  -0x18(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    14f7 <main+0x367>
movss  -0x18(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1517 <main+0x387>
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
call   1030 <mot_Run@plt>
cmpl   $0x20,-0x1c(%rbp)
jne    154d <main+0x3bd>
lea    0xc56(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <mot_Stop@plt>
cmpl   $0x61,-0x1c(%rbp)
jne    1570 <main+0x3e0>
lea    0xc4b(%rip),%rdi
call   1040 <printf@plt>
xor    %ecx,%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   10b0 <mot_SetLeds@plt>
cmpl   $0x73,-0x1c(%rbp)
jne    1596 <main+0x406>
lea    0xc3e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   10b0 <mot_SetLeds@plt>
cmpl   $0x64,-0x1c(%rbp)
jne    15bc <main+0x42c>
lea    0xc30(%rip),%rdi
call   1040 <printf@plt>
mov    $0x3,%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   10b0 <mot_SetLeds@plt>
cmpl   $0x66,-0x1c(%rbp)
jne    15e2 <main+0x452>
lea    0xc23(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%ecx
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   10b0 <mot_SetLeds@plt>
mov    $0x0,%al
call   10a0 <pthread_yield@plt>
jmp    11f7 <main+0x67>
mov    $0x0,%al
call   1070 <mot_Close@plt>
lea    0xc0a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x11a5(%rip),%rdi
call   1040 <puts@plt>
lea    0xff3(%rip),%rdi
call   1050 <printf@plt>
lea    0x11ba(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <mot_Init@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
lea    0xe7d(%rip),%r14
lea    0x10a9(%rip),%r15
lea    0x1108(%rip),%r12
lea    0x112f(%rip),%r13
lea    0x1141(%rip),%rbx
lea    0x1109(%rip),%rbp
jmp    1234 <main+0x94>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   10c0 <mot_SetLeds@plt>
xor    %eax,%eax
call   10b0 <pthread_yield@plt>
xor    %eax,%eax
call   1060 <util_getch@plt>
mov    %eax,%edi
call   10a0 <tolower@plt>
add    $0xffffffe0,%eax
cmp    $0x53,%eax
ja     122d <main+0x8d>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
lea    0x1091(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <mot_Stop@plt>
jmp    122d <main+0x8d>
lea    0x1048(%rip),%rdi
call   1050 <printf@plt>
movaps 0xd85(%rip),%xmm2
movaps (%rsp),%xmm0
cmpltps %xmm0,%xmm2
movaps %xmm2,%xmm1
andnps %xmm0,%xmm1
addps  0xd80(%rip),%xmm0
jmp    12b6 <main+0x116>
lea    0x1039(%rip),%rdi
call   1050 <printf@plt>
xorps  %xmm2,%xmm2
movaps (%rsp),%xmm0
cmpltps %xmm0,%xmm2
movaps %xmm2,%xmm1
andnps %xmm0,%xmm1
addps  0xd4a(%rip),%xmm0
andps  %xmm2,%xmm0
orps   %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm3
pshufd $0xee,%xmm0,%xmm2
pshufd $0xff,%xmm0,%xmm1
movaps %xmm0,(%rsp)
call   1030 <mot_Run@plt>
jmp    122d <main+0x8d>
lea    0xf47(%rip),%rdi
call   1050 <printf@plt>
pxor   %xmm1,%xmm1
pxor   %xmm2,%xmm2
pxor   %xmm3,%xmm3
movss  0xd67(%rip),%xmm0
call   1030 <mot_Run@plt>
movss  0xd5a(%rip),%xmm0
movaps %xmm0,(%rsp)
jmp    122d <main+0x8d>
lea    0xf2d(%rip),%rdi
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
pxor   %xmm2,%xmm2
pxor   %xmm3,%xmm3
movd   0xd32(%rip),%xmm1
call   1030 <mot_Run@plt>
movaps 0xd16(%rip),%xmm0
movaps %xmm0,(%rsp)
jmp    122d <main+0x8d>
lea    0xf15(%rip),%rdi
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
pxor   %xmm1,%xmm1
pxor   %xmm3,%xmm3
movd   0xcfe(%rip),%xmm2
call   1030 <mot_Run@plt>
movaps 0xcd2(%rip),%xmm0
movaps %xmm0,(%rsp)
jmp    122d <main+0x8d>
lea    0xefd(%rip),%rdi
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
pxor   %xmm1,%xmm1
pxor   %xmm2,%xmm2
movd   0xcca(%rip),%xmm3
call   1030 <mot_Run@plt>
movaps 0xc8e(%rip),%xmm0
movaps %xmm0,(%rsp)
jmp    122d <main+0x8d>
mov    %r15,%rdi
call   1050 <printf@plt>
movd   0xca5(%rip),%xmm0
movdqa %xmm0,%xmm1
movdqa %xmm0,%xmm2
movdqa %xmm0,%xmm3
call   1030 <mot_Run@plt>
movaps 0xc4d(%rip),%xmm0
movaps %xmm0,(%rsp)
jmp    122d <main+0x8d>
mov    %r12,%rdi
call   1050 <printf@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
jmp    1228 <main+0x88>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    $0x3,%edi
mov    $0x3,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
jmp    1228 <main+0x88>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
mov    $0x2,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
jmp    1228 <main+0x88>
xor    %eax,%eax
call   1080 <mot_Close@plt>
lea    0xf6f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Motorboard Test Program ... Press q to quit\0D\0A\00"
@.str.1 = [115 x i8] c"Motor: 1,2,3,4=run single motor at 50% 5=run all motors at 50% ,=throttle up 1% .=throttle down 1% space=stop\0D\0A\00"
@.str.2 = [42 x i8] c"Leds: a=loff s=green d=orange f=red\0D\0A\00"
@.str.3 = [28 x i8] c"\0DRun Motor1 50% \00"
@.str.4 = [28 x i8] c"\0DRun Motor2 50% \00"
@.str.5 = [28 x i8] c"\0DRun Motor3 50% \00"
@.str.6 = [28 x i8] c"\0DRun Motor4 50% \00"
@.str.7 = [32 x i8] c"\0DRun All Motors 50% \00"
@.str.8 = [27 x i8] c"\0DThrottle down \00"
@.str.9 = [25 x i8] c"\0DThrottle up \00"
@.str.10 = [18 x i8] c"\0DStop \00"
@.str.11 = [22 x i8] c"\0DLeds off \00"
@.str.12 = [24 x i8] c"\0DLeds green \00"
@.str.13 = [25 x i8] c"\0DLeds orange \00"
@.str.14 = [22 x i8] c"\0DLeds red \00"
@.str.15 = [10 x i8] c"\0ADone...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (...) @mot_Init()
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store float 0x3F847AE140000000, float* %6
br label %12
12: ; preds = %0, %178
%13 = call i32 (...) @util_getch()
%14 = call i32 @tolower(i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 113
br i1 %16, label %17, label %18
17: ; preds = %12
br label %180
18: ; preds = %12
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 49
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store float 5.000000e-01, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
%23 = load float, float* %2
%24 = load float, float* %3
%25 = load float, float* %4
%26 = load float, float* %5
%27 = call i32 @mot_Run(float %23, float %24, float %25, float %26)
br label %28
28: ; preds = %21, %18
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 50
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store float 0.000000e+00, float* %2
store float 5.000000e-01, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
%33 = load float, float* %2
%34 = load float, float* %3
%35 = load float, float* %4
%36 = load float, float* %5
%37 = call i32 @mot_Run(float %33, float %34, float %35, float %36)
br label %38
38: ; preds = %31, %28
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 51
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 5.000000e-01, float* %4
store float 0.000000e+00, float* %5
%43 = load float, float* %2
%44 = load float, float* %3
%45 = load float, float* %4
%46 = load float, float* %5
%47 = call i32 @mot_Run(float %43, float %44, float %45, float %46)
br label %48
48: ; preds = %41, %38
%49 = load i32, i32* %7
%50 = icmp eq i32 %49, 52
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 5.000000e-01, float* %5
%53 = load float, float* %2
%54 = load float, float* %3
%55 = load float, float* %4
%56 = load float, float* %5
%57 = call i32 @mot_Run(float %53, float %54, float %55, float %56)
br label %58
58: ; preds = %51, %48
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, 53
br i1 %60, label %61, label %68
61: ; preds = %58
%62 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
store float 5.000000e-01, float* %2
store float 5.000000e-01, float* %3
store float 5.000000e-01, float* %4
store float 5.000000e-01, float* %5
%63 = load float, float* %2
%64 = load float, float* %3
%65 = load float, float* %4
%66 = load float, float* %5
%67 = call i32 @mot_Run(float %63, float %64, float %65, float %66)
br label %68
68: ; preds = %61, %58
%69 = load i32, i32* %7
%70 = icmp eq i32 %69, 44
br i1 %70, label %71, label %110
71: ; preds = %68
%72 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%73 = load float, float* %2
%74 = load float, float* %6
%75 = fcmp ogt float %73, %74
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = load float, float* %6
%78 = load float, float* %2
%79 = fsub float %78, %77
store float %79, float* %2
br label %80
80: ; preds = %76, %71
%81 = load float, float* %3
%82 = load float, float* %6
%83 = fcmp ogt float %81, %82
br i1 %83, label %84, label %88
84: ; preds = %80
%85 = load float, float* %6
%86 = load float, float* %3
%87 = fsub float %86, %85
store float %87, float* %3
br label %88
88: ; preds = %84, %80
%89 = load float, float* %4
%90 = load float, float* %6
%91 = fcmp ogt float %89, %90
br i1 %91, label %92, label %96
92: ; preds = %88
%93 = load float, float* %6
%94 = load float, float* %4
%95 = fsub float %94, %93
store float %95, float* %4
br label %96
96: ; preds = %92, %88
%97 = load float, float* %5
%98 = load float, float* %6
%99 = fcmp ogt float %97, %98
br i1 %99, label %100, label %104
100: ; preds = %96
%101 = load float, float* %6
%102 = load float, float* %5
%103 = fsub float %102, %101
store float %103, float* %5
br label %104
104: ; preds = %100, %96
%105 = load float, float* %2
%106 = load float, float* %3
%107 = load float, float* %4
%108 = load float, float* %5
%109 = call i32 @mot_Run(float %105, float %106, float %107, float %108)
br label %110
110: ; preds = %104, %68
%111 = load i32, i32* %7
%112 = icmp eq i32 %111, 46
br i1 %112, label %113, label %148
113: ; preds = %110
%114 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%115 = load float, float* %2
%116 = fcmp ogt float %115, 0.000000e+00
br i1 %116, label %117, label %121
117: ; preds = %113
%118 = load float, float* %6
%119 = load float, float* %2
%120 = fadd float %119, %118
store float %120, float* %2
br label %121
121: ; preds = %117, %113
%122 = load float, float* %3
%123 = fcmp ogt float %122, 0.000000e+00
br i1 %123, label %124, label %128
124: ; preds = %121
%125 = load float, float* %6
%126 = load float, float* %3
%127 = fadd float %126, %125
store float %127, float* %3
br label %128
128: ; preds = %124, %121
%129 = load float, float* %4
%130 = fcmp ogt float %129, 0.000000e+00
br i1 %130, label %131, label %135
131: ; preds = %128
%132 = load float, float* %6
%133 = load float, float* %4
%134 = fadd float %133, %132
store float %134, float* %4
br label %135
135: ; preds = %131, %128
%136 = load float, float* %5
%137 = fcmp ogt float %136, 0.000000e+00
br i1 %137, label %138, label %142
138: ; preds = %135
%139 = load float, float* %6
%140 = load float, float* %5
%141 = fadd float %140, %139
store float %141, float* %5
br label %142
142: ; preds = %138, %135
%143 = load float, float* %2
%144 = load float, float* %3
%145 = load float, float* %4
%146 = load float, float* %5
%147 = call i32 @mot_Run(float %143, float %144, float %145, float %146)
br label %148
148: ; preds = %142, %110
%149 = load i32, i32* %7
%150 = icmp eq i32 %149, 32
br i1 %150, label %151, label %154
151: ; preds = %148
%152 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%153 = call i32 (...) @mot_Stop()
br label %154
154: ; preds = %151, %148
%155 = load i32, i32* %7
%156 = icmp eq i32 %155, 97
br i1 %156, label %157, label %160
157: ; preds = %154
%158 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%159 = call i32 @mot_SetLeds(i32 0, i32 0, i32 0, i32 0)
br label %160
160: ; preds = %157, %154
%161 = load i32, i32* %7
%162 = icmp eq i32 %161, 115
br i1 %162, label %163, label %166
163: ; preds = %160
%164 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%165 = call i32 @mot_SetLeds(i32 2, i32 2, i32 2, i32 2)
br label %166
166: ; preds = %163, %160
%167 = load i32, i32* %7
%168 = icmp eq i32 %167, 100
br i1 %168, label %169, label %172
169: ; preds = %166
%170 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
%171 = call i32 @mot_SetLeds(i32 3, i32 3, i32 3, i32 3)
br label %172
172: ; preds = %169, %166
%173 = load i32, i32* %7
%174 = icmp eq i32 %173, 102
br i1 %174, label %175, label %178
175: ; preds = %172
%176 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%177 = call i32 @mot_SetLeds(i32 1, i32 1, i32 1, i32 1)
br label %178
178: ; preds = %175, %172
%179 = call i32 (...) @pthread_yield()
br label %12
180: ; preds = %17
%181 = call i32 (...) @mot_Close()
%182 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [115 x i8] c"Motor: 1,2,3,4=run single motor at 50% 5=run all motors at 50% ,=throttle up 1% .=throttle down 1% space=stop\0D\0A\00"
@.str.3 = [28 x i8] c"\0DRun Motor1 50% \00"
@.str.4 = [28 x i8] c"\0DRun Motor2 50% \00"
@.str.5 = [28 x i8] c"\0DRun Motor3 50% \00"
@.str.6 = [28 x i8] c"\0DRun Motor4 50% \00"
@.str.7 = [32 x i8] c"\0DRun All Motors 50% \00"
@.str.8 = [27 x i8] c"\0DThrottle down \00"
@.str.9 = [25 x i8] c"\0DThrottle up \00"
@.str.10 = [18 x i8] c"\0DStop \00"
@.str.11 = [22 x i8] c"\0DLeds off \00"
@.str.12 = [24 x i8] c"\0DLeds green \00"
@.str.13 = [25 x i8] c"\0DLeds orange \00"
@.str.14 = [22 x i8] c"\0DLeds red \00"
@str = [45 x i8] c"Motorboard Test Program ... Press q to quit\0D\00"
@str.16 = [41 x i8] c"Leds: a=loff s=green d=orange f=red\0D\00"
@str.17 = [9 x i8] c"\0ADone...\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.16, i64 0, i64 0))
%4 = tail call i32 (...) @mot_Init()
br label %5
5: ; preds = %59, %0
%6 = phi <4 x float> [ zeroinitializer, %0 ], [ %60, %59 ]
%7 = tail call i32 (...) @util_getch()
%8 = tail call i32 @tolower(i32 %7)
switch i32 %8, label %59 [
i32 113, label %62
i32 49, label %9
i32 50, label %12
i32 51, label %15
i32 52, label %18
i32 53, label %21
i32 44, label %24
i32 46, label %34
i32 32, label %44
i32 97, label %47
i32 115, label %50
i32 100, label %53
i32 102, label %56
]
9: ; preds = %5
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 @mot_Run(float 5.000000e-01, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00)
br label %59
12: ; preds = %5
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @mot_Run(float 0.000000e+00, float 5.000000e-01, float 0.000000e+00, float 0.000000e+00)
br label %59
15: ; preds = %5
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @mot_Run(float 0.000000e+00, float 0.000000e+00, float 5.000000e-01, float 0.000000e+00)
br label %59
18: ; preds = %5
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%20 = tail call i32 @mot_Run(float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 5.000000e-01)
br label %59
21: ; preds = %5
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%23 = tail call i32 @mot_Run(float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01)
br label %59
24: ; preds = %5
%25 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%26 = fcmp ogt <4 x float> %6, <float 0x3F847AE140000000, float 0x3F847AE140000000, float 0x3F847AE140000000, float 0x3F847AE140000000>
%27 = fadd <4 x float> %6, <float 0xBF847AE140000000, float 0xBF847AE140000000, float 0xBF847AE140000000, float 0xBF847AE140000000>
%28 = select <4 x i1> %26, <4 x float> %27, <4 x float> %6
%29 = extractelement <4 x float> %28, i64 0
%30 = extractelement <4 x float> %28, i64 1
%31 = extractelement <4 x float> %28, i64 2
%32 = extractelement <4 x float> %28, i64 3
%33 = tail call i32 @mot_Run(float %29, float %32, float %31, float %30)
br label %59
34: ; preds = %5
%35 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
%36 = fcmp ogt <4 x float> %6, zeroinitializer
%37 = fadd <4 x float> %6, <float 0x3F847AE140000000, float 0x3F847AE140000000, float 0x3F847AE140000000, float 0x3F847AE140000000>
%38 = select <4 x i1> %36, <4 x float> %37, <4 x float> %6
%39 = extractelement <4 x float> %38, i64 0
%40 = extractelement <4 x float> %38, i64 1
%41 = extractelement <4 x float> %38, i64 2
%42 = extractelement <4 x float> %38, i64 3
%43 = tail call i32 @mot_Run(float %39, float %42, float %41, float %40)
br label %59
44: ; preds = %5
%45 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%46 = tail call i32 (...) @mot_Stop()
br label %59
47: ; preds = %5
%48 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%49 = tail call i32 @mot_SetLeds(i32 0, i32 0, i32 0, i32 0)
br label %59
50: ; preds = %5
%51 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%52 = tail call i32 @mot_SetLeds(i32 2, i32 2, i32 2, i32 2)
br label %59
53: ; preds = %5
%54 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
%55 = tail call i32 @mot_SetLeds(i32 3, i32 3, i32 3, i32 3)
br label %59
56: ; preds = %5
%57 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%58 = tail call i32 @mot_SetLeds(i32 1, i32 1, i32 1, i32 1)
br label %59
59: ; preds = %5, %24, %21, %18, %15, %9, %12, %56, %44, %47, %50, %53, %34
%60 = phi <4 x float> [ %38, %34 ], [ %6, %53 ], [ %6, %50 ], [ %6, %47 ], [ %6, %44 ], [ %6, %56 ], [ <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 5.000000e-01>, %12 ], [ <float 5.000000e-01, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00>, %9 ], [ <float 0.000000e+00, float 0.000000e+00, float 5.000000e-01, float 0.000000e+00>, %15 ], [ <float 0.000000e+00, float 5.000000e-01, float 0.000000e+00, float 0.000000e+00>, %18 ], [ <float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01>, %21 ], [ %28, %24 ], [ %6, %5 ]
%61 = tail call i32 (...) @pthread_yield()
br label %5
62: ; preds = %5
%63 = tail call i32 (...) @mot_Close()
%64 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.17, i64 0, i64 0))
ret i32 0
}