void srt_remainder(struct times **list, struct times **wait,
                   struct times **turnaround, struct times **plist) {
  int processCounter = 1, startTime = 0, stopTime = 0, searching = 1,
      curShort = 0, counter = 0;
  struct times *visited = 0;
  struct times *temp;
  struct times *curWait = *wait;
  struct times *curTurn = *turnaround;
  int locate = 0;
  struct times *pNewList = *plist;
  startTime = get_last_val(&curWait);
  stopTime = get_last_val(&curWait);
  temp = *list;
  if (temp == 0) {
    return;
  } else {
    while (searching == 1) {
      locate = srt_find_index(list);
      curShort = srt_findshortest(list);
      if (curShort == -1) {
        searching = 0;
      } else {
        stopTime = startTime + curShort;
        add_burst_time(&pNewList, locate);
        add_burst_time(&curWait, startTime);
        printf("P%d\t\t\t%d\t\t\t\t\%d\t\t\t\t%d\n", locate, curShort,
               startTime, stopTime);
        locate = 0;
        add_burst_time(&curTurn, stopTime);
        startTime = startTime + curShort;
      }
      counter++;
    }
  }
  char message[50] = {"Computing Wait Times\0"};
  output_srt_summary(&curWait, &pNewList, message);
  char turnMessage[50] = {"Computing Turn around Times\0"};
  output_srt_summary(&curTurn, &pNewList, turnMessage);
}


x86 assembly (clang, -O0):
<srt_remainder>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x0,%al
call   1050 <get_last_val@plt>
mov    %eax,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x0,%al
call   1050 <get_last_val@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    121c <srt_remainder+0xac>
jmp    132a <srt_remainder+0x1ba>
jmp    1221 <srt_remainder+0xb1>
cmpl   $0x1,-0x30(%rbp)
jne    12c9 <srt_remainder+0x159>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <srt_find_index@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1060 <srt_findshortest@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    125d <srt_remainder+0xed>
movl   $0x0,-0x30(%rbp)
jmp    12bb <srt_remainder+0x14b>
mov    -0x28(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x5c(%rbp),%esi
lea    -0x68(%rbp),%rdi
mov    $0x0,%al
call   1030 <add_burst_time@plt>
mov    -0x28(%rbp),%esi
lea    -0x50(%rbp),%rdi
mov    $0x0,%al
call   1030 <add_burst_time@plt>
mov    -0x5c(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x2c(%rbp),%esi
lea    -0x58(%rbp),%rdi
mov    $0x0,%al
call   1030 <add_burst_time@plt>
mov    -0x28(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1221 <srt_remainder+0xb1>
jmp    12ce <srt_remainder+0x15e>
lea    -0xa0(%rbp),%rdi
lea    0xd44(%rip),%rsi
mov    $0x32,%edx
call   1070 <memcpy@plt>
lea    -0xa0(%rbp),%rdx
lea    -0x50(%rbp),%rdi
lea    -0x68(%rbp),%rsi
mov    $0x0,%al
call   1090 <output_srt_summary@plt>
lea    -0xe0(%rbp),%rdi
lea    0xd56(%rip),%rsi
mov    $0x32,%edx
call   1070 <memcpy@plt>
lea    -0xe0(%rbp),%rdx
lea    -0x58(%rbp),%rdi
lea    -0x68(%rbp),%rsi
mov    $0x0,%al
call   1090 <output_srt_summary@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srt_remainder>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r14
mov    (%rsi),%rax
mov    %rax,0x8(%rsp)
mov    (%rdx),%rax
mov    %rax,0x18(%rsp)
mov    (%rcx),%rax
mov    %rax,0x10(%rsp)
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <get_last_val@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <get_last_val@plt>
cmpq   $0x0,(%r14)
je     12d2 <srt_remainder+0x172>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <srt_find_index@plt>
mov    %eax,%r15d
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <srt_findshortest@plt>
cmp    $0xffffffff,%eax
je     1249 <srt_remainder+0xe9>
mov    %eax,%r12d
lea    0x18(%rsp),%rbp
nopl   0x0(%rax)
lea    (%r12,%rbx,1),%r13d
lea    0x10(%rsp),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <add_burst_time@plt>
lea    0x8(%rsp),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <add_burst_time@plt>
lea    0xdf8(%rip),%rdi
mov    %r15d,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <add_burst_time@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <srt_find_index@plt>
mov    %eax,%r15d
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <srt_findshortest@plt>
mov    %eax,%r12d
mov    %r13d,%ebx
cmp    $0xffffffff,%eax
jne    11e0 <srt_remainder+0x80>
movaps 0xdf0(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xdd1(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xdb5(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movw   $0x0,0x90(%rsp)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rbx
lea    0x60(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <output_srt_summary@plt>
movaps 0xde6(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xdca(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xdae(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movw   $0x0,0x50(%rsp)
lea    0x18(%rsp),%rdi
lea    0x20(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <output_srt_summary@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.times = type opaque
@.str = [22 x i8] c"P%d\09\09\09%d\09\09\09\09%d\09\09\09\09%d\0A\00"
@__const.srt_remainder.message = [50 x i8] c"Computing Wait Times\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.srt_remainder.turnMessage = [50 x i8] c"Computing Turn around Times\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define void @srt_remainder(%struct.times** %0, %struct.times** %1, %struct.times** %2, %struct.times** %3) {
%5 = alloca %struct.times**
%6 = alloca %struct.times**
%7 = alloca %struct.times**
%8 = alloca %struct.times**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.times*
%16 = alloca %struct.times*
%17 = alloca %struct.times*
%18 = alloca %struct.times*
%19 = alloca i32
%20 = alloca %struct.times*
%21 = alloca [50 x i8]
%22 = alloca [50 x i8]
store %struct.times** %0, %struct.times*** %5
store %struct.times** %1, %struct.times*** %6
store %struct.times** %2, %struct.times*** %7
store %struct.times** %3, %struct.times*** %8
store i32 1, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 1, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store %struct.times* null, %struct.times** %15
%23 = load %struct.times**, %struct.times*** %6
%24 = load %struct.times*, %struct.times** %23
store %struct.times* %24, %struct.times** %17
%25 = load %struct.times**, %struct.times*** %7
%26 = load %struct.times*, %struct.times** %25
store %struct.times* %26, %struct.times** %18
store i32 0, i32* %19
%27 = load %struct.times**, %struct.times*** %8
%28 = load %struct.times*, %struct.times** %27
store %struct.times* %28, %struct.times** %20
%29 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @get_last_val to i32 (%struct.times**, ...)*)(%struct.times** %17)
store i32 %29, i32* %10
%30 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @get_last_val to i32 (%struct.times**, ...)*)(%struct.times** %17)
store i32 %30, i32* %11
%31 = load %struct.times**, %struct.times*** %5
%32 = load %struct.times*, %struct.times** %31
store %struct.times* %32, %struct.times** %16
%33 = load %struct.times*, %struct.times** %16
%34 = icmp eq %struct.times* %33, null
br i1 %34, label %35, label %36
35: ; preds = %4
br label %77
36: ; preds = %4
br label %37
37: ; preds = %66, %36
%38 = load i32, i32* %12
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %69
40: ; preds = %37
%41 = load %struct.times**, %struct.times*** %5
%42 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @srt_find_index to i32 (%struct.times**, ...)*)(%struct.times** %41)
store i32 %42, i32* %19
%43 = load %struct.times**, %struct.times*** %5
%44 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @srt_findshortest to i32 (%struct.times**, ...)*)(%struct.times** %43)
store i32 %44, i32* %13
%45 = load i32, i32* %13
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %48
47: ; preds = %40
store i32 0, i32* %12
br label %66
48: ; preds = %40
%49 = load i32, i32* %10
%50 = load i32, i32* %13
%51 = add nsw i32 %49, %50
store i32 %51, i32* %11
%52 = load i32, i32* %19
%53 = call i32 (%struct.times**, i32, ...) bitcast (i32 (...)* @add_burst_time to i32 (%struct.times**, i32, ...)*)(%struct.times** %20, i32 %52)
%54 = load i32, i32* %10
%55 = call i32 (%struct.times**, i32, ...) bitcast (i32 (...)* @add_burst_time to i32 (%struct.times**, i32, ...)*)(%struct.times** %17, i32 %54)
%56 = load i32, i32* %19
%57 = load i32, i32* %13
%58 = load i32, i32* %10
%59 = load i32, i32* %11
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %56, i32 %57, i32 %58, i32 %59)
store i32 0, i32* %19
%61 = load i32, i32* %11
%62 = call i32 (%struct.times**, i32, ...) bitcast (i32 (...)* @add_burst_time to i32 (%struct.times**, i32, ...)*)(%struct.times** %18, i32 %61)
%63 = load i32, i32* %10
%64 = load i32, i32* %13
%65 = add nsw i32 %63, %64
store i32 %65, i32* %10
br label %66
66: ; preds = %48, %47
%67 = load i32, i32* %14
%68 = add nsw i32 %67, 1
store i32 %68, i32* %14
br label %37
69: ; preds = %37
br label %70
70: ; preds = %69
%71 = bitcast [50 x i8]* %21 to i8*
%72 = getelementptr inbounds [50 x i8], [50 x i8]* %21, i64 0, i64 0
%73 = call i32 (%struct.times**, %struct.times**, i8*, ...) bitcast (i32 (...)* @output_srt_summary to i32 (%struct.times**, %struct.times**, i8*, ...)*)(%struct.times** %17, %struct.times** %20, i8* %72)
%74 = bitcast [50 x i8]* %22 to i8*
%75 = getelementptr inbounds [50 x i8], [50 x i8]* %22, i64 0, i64 0
%76 = call i32 (%struct.times**, %struct.times**, i8*, ...) bitcast (i32 (...)* @output_srt_summary to i32 (%struct.times**, %struct.times**, i8*, ...)*)(%struct.times** %18, %struct.times** %20, i8* %75)
br label %77
77: ; preds = %70, %35
ret void
}

LLVM IR (-O2):
%struct.times = type opaque
@.str = [22 x i8] c"P%d\09\09\09%d\09\09\09\09%d\09\09\09\09%d\0A\00"
@__const.srt_remainder.message = [50 x i8] c"Computing Wait Times\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.srt_remainder.turnMessage = [50 x i8] c"Computing Turn around Times\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define void @srt_remainder(%struct.times** %0, %struct.times** nocapture %1, %struct.times** nocapture %2, %struct.times** nocapture %3) {
%5 = alloca %struct.times*
%6 = alloca %struct.times*
%7 = alloca %struct.times*
%8 = alloca [50 x i8]
%9 = alloca [50 x i8]
%10 = bitcast %struct.times** %5 to i8*
%11 = load %struct.times*, %struct.times** %1
store %struct.times* %11, %struct.times** %5
%12 = bitcast %struct.times** %6 to i8*
%13 = load %struct.times*, %struct.times** %2
store %struct.times* %13, %struct.times** %6
%14 = bitcast %struct.times** %7 to i8*
%15 = load %struct.times*, %struct.times** %3
store %struct.times* %15, %struct.times** %7
%16 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @get_last_val to i32 (%struct.times**, ...)*)(%struct.times** %5)
%17 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @get_last_val to i32 (%struct.times**, ...)*)(%struct.times** %5)
%18 = load %struct.times*, %struct.times** %0
%19 = icmp eq %struct.times* %18, null
br i1 %19, label %41, label %20
20: ; preds = %4
%21 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @srt_find_index to i32 (%struct.times**, ...)*)(%struct.times** %0)
%22 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @srt_findshortest to i32 (%struct.times**, ...)*)(%struct.times** %0)
%23 = icmp eq i32 %22, -1
br i1 %23, label %36, label %24
24: ; preds = %20, %24
%25 = phi i32 [ %34, %24 ], [ %22, %20 ]
%26 = phi i32 [ %33, %24 ], [ %21, %20 ]
%27 = phi i32 [ %28, %24 ], [ %16, %20 ]
%28 = add nsw i32 %25, %27
%29 = call i32 (%struct.times**, i32, ...) bitcast (i32 (...)* @add_burst_time to i32 (%struct.times**, i32, ...)*)(%struct.times** %7, i32 %26)
%30 = call i32 (%struct.times**, i32, ...) bitcast (i32 (...)* @add_burst_time to i32 (%struct.times**, i32, ...)*)(%struct.times** %5, i32 %27)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %25, i32 %27, i32 %28)
%32 = call i32 (%struct.times**, i32, ...) bitcast (i32 (...)* @add_burst_time to i32 (%struct.times**, i32, ...)*)(%struct.times** %6, i32 %28)
%33 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @srt_find_index to i32 (%struct.times**, ...)*)(%struct.times** %0)
%34 = call i32 (%struct.times**, ...) bitcast (i32 (...)* @srt_findshortest to i32 (%struct.times**, ...)*)(%struct.times** %0)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %24
36: ; preds = %24, %20
%37 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%38 = call i32 (%struct.times**, %struct.times**, i8*, ...) bitcast (i32 (...)* @output_srt_summary to i32 (%struct.times**, %struct.times**, i8*, ...)*)(%struct.times** %5, %struct.times** %7, i8* %37)
%39 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%40 = call i32 (%struct.times**, %struct.times**, i8*, ...) bitcast (i32 (...)* @output_srt_summary to i32 (%struct.times**, %struct.times**, i8*, ...)*)(%struct.times** %6, %struct.times** %7, i8* %39)
br label %41
41: ; preds = %4, %36
ret void
}