#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*/ printf(char *, ...);
void runRMS(int serveA, int cycA, int serveB, int cycB) {
  int A, B;
  float m;
  int i, j, a = 0, b = 0, ka = 0, kb = 0;
  int numa = 0, numb = 0;
  int T;
  printf("\t\t\t------------------------------------------------\n");
  printf("\t\t\t\trate monotonic schedule algorithm\n");
  printf("\t\t\t------------------------------------------------\n");
  printf("Process A runs every %d seconds and needs %d seconds to finish\n",
         cycA, serveA);
  printf("Process B runs every %d seconds and needs %d seconds to finish\n",
         cycB, serveB);
  m = (float)serveA / cycA + (float)serveB / cycB;
  for (T = 0; T <= 100; T++) {
    if (cycA < cycB) {
      kb = 0;
      ka = 1;
    } else {
      kb = 1;
      ka = 0;
    }
    if (numa == serveA) {
      numa = serveA + 1;
      printf("when T=%d, ", T);
      printf("process A%d is done\n", a);
      if (numb < serveB) {
        printf("run process B%d\n", b);
        kb = 1;
      }
      ka = 0;
    }
    if (numb == serveB) {
      numb = serveB + 1;
      printf("when T=%d, ", T);
      printf("process B%d is done\n", b);
      if (numa < serveA) {
        printf("run process A%d\n", a);
        ka = 1;
      }
      kb = 0;
    }
    if (T % cycA == 0 && T % cycB == 0) {
      A = B = T;
      j = ++a;
      i = ++b;
      printf("when T=%d, process A%d and process B%d are generated together\n",
             T, j, i);
      if (cycA <= cycB) {
        printf("run process A%d and suspend process B%d\n", j, i);
        printf("---------------------------------------\n");
        ka = 1;
        kb = 0;
      } else {
        printf("run process B%d and suspend process A%d\n", i, j);
        ka = 0;
        kb = 1;
      }
      numa = numb = 0;
    }
    if (T % cycA == 0 && T % cycB != 0) {
      A = T;
      printf("when T=%d, ", T);
      printf("process A%d is generated\n", ++a);
      numa = 0;
      if (numb < serveB) {
        if (cycB > cycA) {
          printf("run process A%d\n", a);
          ka = 1;
          kb = 0;
        } else {
          printf("process B%d is moving forward\n", b);
        }
      } else {
        printf("process A%d is run\n", a);
        ka = 1;
      }
    }
    if (T % cycA != 0 && T % cycB == 0) {
      B = T;
      printf("when T=%d, ", T);
      printf("process B%d is generated\n", ++b);
      numb = 0;
      if (numa < serveA) {
        if (cycB >= cycA) {
          printf("process A%d is on run\n", a);
        } else {
          printf("process B%d is to run\n", b);
          kb = 1;
          ka = 0;
        }
      } else {
        printf("process B%d is on run\n", b);
        kb = 1;
      }
    }
    if (ka) {
      numa++;
    }
    if (kb) {
      numb++;
    }
  }
}


x86 assembly (clang, -O0):
<runRMS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x4(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
cvtsi2ssl -0x10(%rbp),%xmm2
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x64,-0x40(%rbp)
jg     1551 <runRMS+0x441>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f5 <runRMS+0xe5>
movl   $0x0,-0x34(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1203 <runRMS+0xf3>
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1265 <runRMS+0x155>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x40(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    125e <runRMS+0x14e>
mov    -0x2c(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    12c7 <runRMS+0x1b7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x40(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c0 <runRMS+0x1b0>
mov    -0x28(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x40(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1390 <runRMS+0x280>
mov    -0x40(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1390 <runRMS+0x280>
mov    -0x40(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    %eax,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x40(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1360 <runRMS+0x250>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
jmp    1382 <runRMS+0x272>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x40(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1454 <runRMS+0x344>
mov    -0x40(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
je     1454 <runRMS+0x344>
mov    -0x40(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x40(%rbp),%esi
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1437 <runRMS+0x327>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1421 <runRMS+0x311>
mov    -0x28(%rbp),%esi
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
jmp    1432 <runRMS+0x322>
mov    -0x2c(%rbp),%esi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    144f <runRMS+0x33f>
mov    -0x28(%rbp),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x30(%rbp)
jmp    1454 <runRMS+0x344>
mov    -0x40(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
je     1518 <runRMS+0x408>
mov    -0x40(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1518 <runRMS+0x408>
mov    -0x40(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x40(%rbp),%esi
lea    0xc58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x2c(%rbp)
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    14fb <runRMS+0x3eb>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     14d7 <runRMS+0x3c7>
mov    -0x28(%rbp),%esi
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14f6 <runRMS+0x3e6>
mov    -0x2c(%rbp),%esi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    1513 <runRMS+0x403>
mov    -0x2c(%rbp),%esi
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
jmp    1518 <runRMS+0x408>
cmpl   $0x0,-0x30(%rbp)
je     152b <runRMS+0x41b>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     153e <runRMS+0x42e>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1543 <runRMS+0x433>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11cc <runRMS+0xbc>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runRMS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%r12d
lea    0x10fc(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0x10c7(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
mov    %ebx,0x10(%rsp)
mov    %ebp,0xc(%rsp)
cmp    %ebx,%ebp
setge  0x7(%rsp)
setl   %al
mov    %eax,0x34(%rsp)
mov    %r12,%rax
mov    %r12,0x20(%rsp)
lea    0x1(%r12),%eax
mov    %eax,0x1c(%rsp)
mov    %r15,%rax
mov    %r15,0x28(%rsp)
lea    0x1(%r15),%eax
mov    %eax,0x18(%rsp)
xor    %r13d,%r13d
xor    %r15d,%r15d
xor    %ebx,%ebx
movl   $0x0,0x8(%rsp)
xor    %r14d,%r14d
jmp    120e <runRMS+0xee>
xor    %r15d,%r15d
lea    0xf3e(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x105b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0x65,%r13d
je     14b1 <runRMS+0x391>
mov    0x34(%rsp),%r12d
movzbl 0x7(%rsp),%eax
cmp    0x20(%rsp),%ebx
jne    126e <runRMS+0x14e>
xor    %r12d,%r12d
lea    0xe58(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe53(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x7(%rsp),%eax
mov    0x1c(%rsp),%ebx
cmp    0x28(%rsp),%r15d
jge    126e <runRMS+0x14e>
xor    %r12d,%r12d
lea    0xe44(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%al
mov    0x1c(%rsp),%ebx
cmp    0x28(%rsp),%r15d
jne    12d0 <runRMS+0x1b0>
xor    %ebp,%ebp
lea    0xe02(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe23(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%r15d
cmp    0x20(%rsp),%ebx
jge    12d3 <runRMS+0x1b3>
xor    %ebp,%ebp
lea    0xe19(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r12d
mov    0x18(%rsp),%r15d
jmp    12d3 <runRMS+0x1b3>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %al,%ebp
mov    %r13d,%eax
cltd
idivl  0xc(%rsp)
mov    %edx,%ecx
mov    %r13d,%eax
cltd
idivl  0x10(%rsp)
test   %ecx,%ecx
je     1300 <runRMS+0x1e0>
test   %edx,%edx
je     1360 <runRMS+0x240>
test   %r12d,%r12d
je     14a0 <runRMS+0x380>
add    $0x1,%ebx
jmp    14a0 <runRMS+0x380>
xchg   %ax,%ax
test   %edx,%edx
je     13d1 <runRMS+0x2b1>
lea    0xd71(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
lea    0xe45(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x28(%rsp),%r15d
jge    1423 <runRMS+0x303>
mov    0xc(%rsp),%eax
cmp    0x10(%rsp),%eax
jge    1464 <runRMS+0x344>
lea    0xd79(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f1 <runRMS+0xd1>
nopl   (%rax)
mov    %r14d,0x14(%rsp)
lea    0xd14(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%r14d
add    $0x1,%r14d
lea    0xe30(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x20(%rsp),%ebx
mov    %r14d,0x8(%rsp)
jge    143b <runRMS+0x31b>
mov    0xc(%rsp),%eax
cmp    %eax,0x10(%rsp)
jge    1473 <runRMS+0x353>
xor    %r15d,%r15d
lea    0xe30(%rip),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
mov    0x14(%rsp),%r14d
jmp    14a0 <runRMS+0x380>
add    $0x1,%r14d
mov    0x8(%rsp),%ebx
add    $0x1,%ebx
lea    0xcf5(%rip),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    %eax,0x10(%rsp)
mov    %ebx,0x8(%rsp)
jge    11cf <runRMS+0xaf>
xor    %r15d,%r15d
lea    0xd32(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
xor    %ebx,%ebx
jmp    14a0 <runRMS+0x380>
lea    0xd78(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
jmp    14a0 <runRMS+0x380>
xor    %r15d,%r15d
lea    0xdb9(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
mov    0x14(%rsp),%r14d
test   %r12d,%r12d
jne    12f6 <runRMS+0x1d6>
jmp    14a0 <runRMS+0x380>
xor    %ebx,%ebx
lea    0xd16(%rip),%rdi
mov    0x8(%rsp),%esi
jmp    1485 <runRMS+0x365>
xor    %r15d,%r15d
lea    0xd53(%rip),%rdi
mov    0x14(%rsp),%r14d
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
jne    12f6 <runRMS+0x1d6>
cs nopw 0x0(%rax,%rax,1)
nop
test   %ebp,%ebp
je     1200 <runRMS+0xe0>
add    $0x1,%r15d
jmp    1200 <runRMS+0xe0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"\09\09\09------------------------------------------------\0A\00"
@.str.1 = [39 x i8] c"\09\09\09\09rate monotonic schedule algorithm\0A\00"
@.str.2 = [64 x i8] c"Process A runs every %d seconds and needs %d seconds to finish\0A\00"
@.str.3 = [64 x i8] c"Process B runs every %d seconds and needs %d seconds to finish\0A\00"
@.str.4 = [12 x i8] c"when T=%d, \00"
@.str.5 = [21 x i8] c"process A%d is done\0A\00"
@.str.6 = [17 x i8] c"run process B%d\0A\00"
@.str.7 = [21 x i8] c"process B%d is done\0A\00"
@.str.8 = [17 x i8] c"run process A%d\0A\00"
@.str.9 = [63 x i8] c"when T=%d, process A%d and process B%d are generated together\0A\00"
@.str.10 = [41 x i8] c"run process A%d and suspend process B%d\0A\00"
@.str.11 = [41 x i8] c"---------------------------------------\0A\00"
@.str.12 = [41 x i8] c"run process B%d and suspend process A%d\0A\00"
@.str.13 = [26 x i8] c"process A%d is generated\0A\00"
@.str.14 = [31 x i8] c"process B%d is moving forward\0A\00"
@.str.15 = [20 x i8] c"process A%d is run\0A\00"
@.str.16 = [26 x i8] c"process B%d is generated\0A\00"
@.str.17 = [23 x i8] c"process A%d is on run\0A\00"
@.str.18 = [23 x i8] c"process B%d is to run\0A\00"
@.str.19 = [23 x i8] c"process B%d is on run\0A\00"
define void @runRMS(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* %6
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28)
%30 = load i32, i32* %5
%31 = sitofp i32 %30 to float
%32 = load i32, i32* %6
%33 = sitofp i32 %32 to float
%34 = fdiv float %31, %33
%35 = load i32, i32* %7
%36 = sitofp i32 %35 to float
%37 = load i32, i32* %8
%38 = sitofp i32 %37 to float
%39 = fdiv float %36, %38
%40 = fadd float %34, %39
store float %40, float* %11
store i32 0, i32* %20
br label %41
41: ; preds = %202, %4
%42 = load i32, i32* %20
%43 = icmp sle i32 %42, 100
br i1 %43, label %44, label %205
44: ; preds = %41
%45 = load i32, i32* %6
%46 = load i32, i32* %8
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 0, i32* %17
store i32 1, i32* %16
br label %50
49: ; preds = %44
store i32 1, i32* %17
store i32 0, i32* %16
br label %50
50: ; preds = %49, %48
%51 = load i32, i32* %18
%52 = load i32, i32* %5
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %68
54: ; preds = %50
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %18
%57 = load i32, i32* %20
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %14
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %19
%62 = load i32, i32* %7
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %67
64: ; preds = %54
%65 = load i32, i32* %15
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %65)
store i32 1, i32* %17
br label %67
67: ; preds = %64, %54
store i32 0, i32* %16
br label %68
68: ; preds = %67, %50
%69 = load i32, i32* %19
%70 = load i32, i32* %7
%71 = icmp eq i32 %69, %70
br i1 %71, label %72, label %86
72: ; preds = %68
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %19
%75 = load i32, i32* %20
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %75)
%77 = load i32, i32* %15
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %77)
%79 = load i32, i32* %18
%80 = load i32, i32* %5
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %85
82: ; preds = %72
%83 = load i32, i32* %14
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %83)
store i32 1, i32* %16
br label %85
85: ; preds = %82, %72
store i32 0, i32* %17
br label %86
86: ; preds = %85, %68
%87 = load i32, i32* %20
%88 = load i32, i32* %6
%89 = srem i32 %87, %88
%90 = icmp eq i32 %89, 0
br i1 %90, label %91, label %119
91: ; preds = %86
%92 = load i32, i32* %20
%93 = load i32, i32* %8
%94 = srem i32 %92, %93
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %119
96: ; preds = %91
%97 = load i32, i32* %20
store i32 %97, i32* %10
store i32 %97, i32* %9
%98 = load i32, i32* %14
%99 = add nsw i32 %98, 1
store i32 %99, i32* %14
store i32 %99, i32* %13
%100 = load i32, i32* %15
%101 = add nsw i32 %100, 1
store i32 %101, i32* %15
store i32 %101, i32* %12
%102 = load i32, i32* %20
%103 = load i32, i32* %13
%104 = load i32, i32* %12
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.9, i64 0, i64 0), i32 %102, i32 %103, i32 %104)
%106 = load i32, i32* %6
%107 = load i32, i32* %8
%108 = icmp sle i32 %106, %107
br i1 %108, label %109, label %114
109: ; preds = %96
%110 = load i32, i32* %13
%111 = load i32, i32* %12
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0), i32 %110, i32 %111)
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %16
store i32 0, i32* %17
br label %118
114: ; preds = %96
%115 = load i32, i32* %12
%116 = load i32, i32* %13
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0), i32 %115, i32 %116)
store i32 0, i32* %16
store i32 1, i32* %17
br label %118
118: ; preds = %114, %109
store i32 0, i32* %19
store i32 0, i32* %18
br label %119
119: ; preds = %118, %91, %86
%120 = load i32, i32* %20
%121 = load i32, i32* %6
%122 = srem i32 %120, %121
%123 = icmp eq i32 %122, 0
br i1 %123, label %124, label %154
124: ; preds = %119
%125 = load i32, i32* %20
%126 = load i32, i32* %8
%127 = srem i32 %125, %126
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %154
129: ; preds = %124
%130 = load i32, i32* %20
store i32 %130, i32* %9
%131 = load i32, i32* %20
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %131)
%133 = load i32, i32* %14
%134 = add nsw i32 %133, 1
store i32 %134, i32* %14
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %134)
store i32 0, i32* %18
%136 = load i32, i32* %19
%137 = load i32, i32* %7
%138 = icmp slt i32 %136, %137
br i1 %138, label %139, label %150
139: ; preds = %129
%140 = load i32, i32* %8
%141 = load i32, i32* %6
%142 = icmp sgt i32 %140, %141
br i1 %142, label %143, label %146
143: ; preds = %139
%144 = load i32, i32* %14
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %144)
store i32 1, i32* %16
store i32 0, i32* %17
br label %149
146: ; preds = %139
%147 = load i32, i32* %15
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %147)
br label %149
149: ; preds = %146, %143
br label %153
150: ; preds = %129
%151 = load i32, i32* %14
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %151)
store i32 1, i32* %16
br label %153
153: ; preds = %150, %149
br label %154
154: ; preds = %153, %124, %119
%155 = load i32, i32* %20
%156 = load i32, i32* %6
%157 = srem i32 %155, %156
%158 = icmp ne i32 %157, 0
br i1 %158, label %159, label %189
159: ; preds = %154
%160 = load i32, i32* %20
%161 = load i32, i32* %8
%162 = srem i32 %160, %161
%163 = icmp eq i32 %162, 0
br i1 %163, label %164, label %189
164: ; preds = %159
%165 = load i32, i32* %20
store i32 %165, i32* %10
%166 = load i32, i32* %20
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %166)
%168 = load i32, i32* %15
%169 = add nsw i32 %168, 1
store i32 %169, i32* %15
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.16, i64 0, i64 0), i32 %169)
store i32 0, i32* %19
%171 = load i32, i32* %18
%172 = load i32, i32* %5
%173 = icmp slt i32 %171, %172
br i1 %173, label %174, label %185
174: ; preds = %164
%175 = load i32, i32* %8
%176 = load i32, i32* %6
%177 = icmp sge i32 %175, %176
br i1 %177, label %178, label %181
178: ; preds = %174
%179 = load i32, i32* %14
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i32 %179)
br label %184
181: ; preds = %174
%182 = load i32, i32* %15
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0), i32 %182)
store i32 1, i32* %17
store i32 0, i32* %16
br label %184
184: ; preds = %181, %178
br label %188
185: ; preds = %164
%186 = load i32, i32* %15
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0), i32 %186)
store i32 1, i32* %17
br label %188
188: ; preds = %185, %184
br label %189
189: ; preds = %188, %159, %154
%190 = load i32, i32* %16
%191 = icmp ne i32 %190, 0
br i1 %191, label %192, label %195
192: ; preds = %189
%193 = load i32, i32* %18
%194 = add nsw i32 %193, 1
store i32 %194, i32* %18
br label %195
195: ; preds = %192, %189
%196 = load i32, i32* %17
%197 = icmp ne i32 %196, 0
br i1 %197, label %198, label %201
198: ; preds = %195
%199 = load i32, i32* %19
%200 = add nsw i32 %199, 1
store i32 %200, i32* %19
br label %201
201: ; preds = %198, %195
br label %202
202: ; preds = %201
%203 = load i32, i32* %20
%204 = add nsw i32 %203, 1
store i32 %204, i32* %20
br label %41
205: ; preds = %41
ret void
}

LLVM IR (-O2):
@.str.2 = [64 x i8] c"Process A runs every %d seconds and needs %d seconds to finish\0A\00"
@.str.3 = [64 x i8] c"Process B runs every %d seconds and needs %d seconds to finish\0A\00"
@.str.4 = [12 x i8] c"when T=%d, \00"
@.str.5 = [21 x i8] c"process A%d is done\0A\00"
@.str.6 = [17 x i8] c"run process B%d\0A\00"
@.str.7 = [21 x i8] c"process B%d is done\0A\00"
@.str.8 = [17 x i8] c"run process A%d\0A\00"
@.str.9 = [63 x i8] c"when T=%d, process A%d and process B%d are generated together\0A\00"
@.str.10 = [41 x i8] c"run process A%d and suspend process B%d\0A\00"
@.str.12 = [41 x i8] c"run process B%d and suspend process A%d\0A\00"
@.str.13 = [26 x i8] c"process A%d is generated\0A\00"
@.str.14 = [31 x i8] c"process B%d is moving forward\0A\00"
@.str.15 = [20 x i8] c"process A%d is run\0A\00"
@.str.16 = [26 x i8] c"process B%d is generated\0A\00"
@.str.17 = [23 x i8] c"process A%d is on run\0A\00"
@.str.18 = [23 x i8] c"process B%d is to run\0A\00"
@.str.19 = [23 x i8] c"process B%d is on run\0A\00"
@str.20 = [38 x i8] c"\09\09\09\09rate monotonic schedule algorithm\00"
@str.21 = [52 x i8] c"\09\09\09------------------------------------------------\00"
@str.22 = [40 x i8] c"---------------------------------------\00"
define void @runRMS(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.21, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.20, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.21, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %0)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %3, i32 %2)
%10 = icmp slt i32 %1, %3
%11 = zext i1 %10 to i32
%12 = xor i1 %10, true
%13 = add nsw i32 %0, 1
%14 = add nsw i32 %2, 1
%15 = icmp slt i32 %3, %1
br label %16
16: ; preds = %4, %111
%17 = phi i32 [ 0, %4 ], [ %116, %111 ]
%18 = phi i32 [ 0, %4 ], [ %115, %111 ]
%19 = phi i32 [ 0, %4 ], [ %112, %111 ]
%20 = phi i32 [ 0, %4 ], [ %114, %111 ]
%21 = phi i32 [ 0, %4 ], [ %113, %111 ]
%22 = icmp eq i32 %19, %0
br i1 %22, label %23, label %29
23: ; preds = %16
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%26 = icmp slt i32 %18, %2
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %20)
br label %29
29: ; preds = %23, %27, %16
%30 = phi i32 [ %11, %16 ], [ 0, %27 ], [ 0, %23 ]
%31 = phi i1 [ %12, %16 ], [ true, %27 ], [ %12, %23 ]
%32 = phi i32 [ %19, %16 ], [ %13, %27 ], [ %13, %23 ]
%33 = zext i1 %31 to i32
%34 = icmp eq i32 %18, %2
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %20)
%38 = icmp slt i32 %32, %0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %21)
br label %41
41: ; preds = %35, %39, %29
%42 = phi i32 [ %30, %29 ], [ 1, %39 ], [ %30, %35 ]
%43 = phi i32 [ %33, %29 ], [ 0, %39 ], [ 0, %35 ]
%44 = phi i32 [ %18, %29 ], [ %14, %39 ], [ %14, %35 ]
%45 = srem i32 %17, %1
%46 = icmp eq i32 %45, 0
%47 = srem i32 %17, %3
%48 = icmp eq i32 %47, 0
br i1 %46, label %49, label %71
49: ; preds = %41
br i1 %48, label %50, label %59
50: ; preds = %49
%51 = add nsw i32 %21, 1
%52 = add nsw i32 %20, 1
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.9, i64 0, i64 0), i32 %17, i32 %51, i32 %52)
br i1 %15, label %57, label %54
54: ; preds = %50
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0), i32 %51, i32 %52)
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.22, i64 0, i64 0))
br label %106
57: ; preds = %50
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0), i32 %52, i32 %51)
br label %92
59: ; preds = %49
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%61 = add nsw i32 %21, 1
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0), i32 %61)
%63 = icmp slt i32 %44, %2
br i1 %63, label %64, label %69
64: ; preds = %59
br i1 %10, label %65, label %67
65: ; preds = %64
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %61)
br label %106
67: ; preds = %64
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %20)
br label %84
69: ; preds = %59
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i32 %61)
br label %98
71: ; preds = %41
br i1 %48, label %72, label %84
72: ; preds = %71
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%74 = add nsw i32 %20, 1
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.16, i64 0, i64 0), i32 %74)
%76 = icmp slt i32 %32, %0
br i1 %76, label %77, label %82
77: ; preds = %72
br i1 %15, label %80, label %78
78: ; preds = %77
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i32 %21)
br label %84
80: ; preds = %77
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0), i32 %74)
br label %92
82: ; preds = %72
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0), i32 %74)
br label %84
84: ; preds = %67, %82, %78, %71
%85 = phi i32 [ %32, %78 ], [ %32, %82 ], [ %32, %71 ], [ 0, %67 ]
%86 = phi i32 [ %21, %78 ], [ %21, %82 ], [ %21, %71 ], [ %61, %67 ]
%87 = phi i32 [ %74, %78 ], [ %74, %82 ], [ %20, %71 ], [ %20, %67 ]
%88 = phi i32 [ %43, %78 ], [ 1, %82 ], [ %43, %71 ], [ %43, %67 ]
%89 = phi i32 [ 0, %78 ], [ 0, %82 ], [ %44, %71 ], [ %44, %67 ]
%90 = icmp eq i32 %42, 0
%91 = add nsw i32 %85, 1
br i1 %90, label %92, label %98
92: ; preds = %57, %80, %84
%93 = phi i32 [ 0, %80 ], [ %89, %84 ], [ 0, %57 ]
%94 = phi i32 [ 1, %80 ], [ %88, %84 ], [ 1, %57 ]
%95 = phi i32 [ %74, %80 ], [ %87, %84 ], [ %52, %57 ]
%96 = phi i32 [ %21, %80 ], [ %86, %84 ], [ %51, %57 ]
%97 = phi i32 [ %32, %80 ], [ %85, %84 ], [ 0, %57 ]
br label %98
98: ; preds = %69, %84, %92
%99 = phi i32 [ %93, %92 ], [ %89, %84 ], [ %44, %69 ]
%100 = phi i32 [ %94, %92 ], [ %88, %84 ], [ %43, %69 ]
%101 = phi i32 [ %95, %92 ], [ %87, %84 ], [ %20, %69 ]
%102 = phi i32 [ %96, %92 ], [ %86, %84 ], [ %61, %69 ]
%103 = phi i32 [ %97, %92 ], [ %91, %84 ], [ 1, %69 ]
%104 = icmp eq i32 %100, 0
%105 = add nsw i32 %99, 1
br i1 %104, label %106, label %111
106: ; preds = %54, %65, %98
%107 = phi i32 [ 1, %65 ], [ %103, %98 ], [ 1, %54 ]
%108 = phi i32 [ %61, %65 ], [ %102, %98 ], [ %51, %54 ]
%109 = phi i32 [ %20, %65 ], [ %101, %98 ], [ %52, %54 ]
%110 = phi i32 [ %44, %65 ], [ %99, %98 ], [ 0, %54 ]
br label %111
111: ; preds = %98, %106
%112 = phi i32 [ %107, %106 ], [ %103, %98 ]
%113 = phi i32 [ %108, %106 ], [ %102, %98 ]
%114 = phi i32 [ %109, %106 ], [ %101, %98 ]
%115 = phi i32 [ %110, %106 ], [ %105, %98 ]
%116 = add nuw nsw i32 %17, 1
%117 = icmp eq i32 %116, 101
br i1 %117, label %118, label %16
118: ; preds = %111
ret void
}