#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int, int, ...);
int main(int argc, char *argv[]) {
  int curr_floor = 1;
  int high_dest = 0;
  int low_dest = 20 + 1;
  int time = 0;
  int floors = 0;
  int direction = 0;
  int request = 0;
  int Requests[20 + 1] = {0};
  int ServiceTimes[20 + 1] = {0};
  int MaxTime = 0;
  int MaxFloor = 0;
  FILE *fp = NULL;
  fp = fopen("prob08.in", "r");
  while (!feof(fp) || (high_dest >= curr_floor) || (low_dest <= curr_floor)) {
    if (!feof(fp)) {
      request = 0;
      fscanf(fp, "%d", &request);
      if ((request > curr_floor) && (request > high_dest))
        high_dest = request;
      if ((request > 0) && (request < curr_floor) && (request < low_dest))
        low_dest = request;
      if ((request > 0) && (Requests[request] == 0)) {
        Requests[request] = 1;
        ServiceTimes[request] = time;
        printf("Request logged on floor %d at %d\n", request, time);
      }
    } else
      request = 0;
    if (Requests[curr_floor] == 1) {
      printf("Serviced Floor %d at %d, was called at %d, Time to service is %d "
             "seconds.\n",
             curr_floor, time, ServiceTimes[curr_floor],
             (time - ServiceTimes[curr_floor]));
      if (MaxTime < (time - ServiceTimes[curr_floor])) {
        MaxTime = (time - ServiceTimes[curr_floor]);
        MaxFloor = curr_floor;
      }
      ServiceTimes[curr_floor] = 0;
      Requests[curr_floor] = 0;
    }
    if (curr_floor == high_dest) {
      high_dest = 0;
      direction = 0;
    }
    if (curr_floor == low_dest) {
      low_dest = 20 + 1;
      direction = 0;
    }
    if (direction == 0) {
      if (high_dest > curr_floor)
        direction = 1;
      if (low_dest < curr_floor)
        direction = -1;
    }
    curr_floor += direction;
    if (direction != 0)
      floors += 1;
    time += 5;
    printf("---Time = %03d, Low = %02d, Current = %02d, High = %02d\n", time,
           low_dest, curr_floor, high_dest);
  }
  fclose(fp);
  printf("%d\n%d\n", floors, MaxTime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x15,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x54,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x54,%edx
call   1050 <memset@plt>
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0xe8(%rbp)
movq   $0x0,-0xf0(%rbp)
lea    0xe0d(%rip),%rdi
lea    0xe10(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rdi
call   1070 <feof@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0xf1(%rbp)
je     1248 <main+0xe8>
mov    -0x18(%rbp),%ecx
mov    $0x1,%al
cmp    -0x14(%rbp),%ecx
mov    %al,-0xf1(%rbp)
jge    1248 <main+0xe8>
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
setle  %al
mov    %al,-0xf1(%rbp)
mov    -0xf1(%rbp),%al
test   $0x1,%al
jne    125b <main+0xfb>
jmp    1467 <main+0x307>
mov    -0xf0(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
jne    1320 <main+0x1c0>
movl   $0x0,-0x2c(%rbp)
mov    -0xf0(%rbp),%rdi
lea    0xd87(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    12ac <main+0x14c>
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    12ac <main+0x14c>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    12d4 <main+0x174>
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12d4 <main+0x174>
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12d4 <main+0x174>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    131b <main+0x1bb>
movslq -0x2c(%rbp),%rax
cmpl   $0x0,-0x80(%rbp,%rax,4)
jne    131b <main+0x1bb>
movslq -0x2c(%rbp),%rax
movl   $0x1,-0x80(%rbp,%rax,4)
mov    -0x20(%rbp),%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0xe0(%rbp,%rax,4)
mov    -0x2c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1327 <main+0x1c7>
movl   $0x0,-0x2c(%rbp)
movslq -0x14(%rbp),%rax
cmpl   $0x1,-0x80(%rbp,%rax,4)
jne    13b9 <main+0x259>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
movslq -0x14(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x20(%rbp),%r8d
movslq -0x14(%rbp),%rax
sub    -0xe0(%rbp,%rax,4),%r8d
ff
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe4(%rbp),%eax
mov    -0x20(%rbp),%ecx
movslq -0x14(%rbp),%rdx
sub    -0xe0(%rbp,%rdx,4),%ecx
cmp    %ecx,%eax
jge    139e <main+0x23e>
mov    -0x20(%rbp),%eax
movslq -0x14(%rbp),%rcx
sub    -0xe0(%rbp,%rcx,4),%eax
mov    %eax,-0xe4(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xe8(%rbp)
movslq -0x14(%rbp),%rax
movl   $0x0,-0xe0(%rbp,%rax,4)
movslq -0x14(%rbp),%rax
movl   $0x0,-0x80(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    13d3 <main+0x273>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    13ed <main+0x28d>
movl   $0x15,-0x1c(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1422 <main+0x2c2>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    140a <main+0x2aa>
movl   $0x1,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    141d <main+0x2bd>
movl   $0xffffffff,-0x28(%rbp)
jmp    1422 <main+0x2c2>
mov    -0x28(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     143e <main+0x2de>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xc21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1206 <main+0xa6>
mov    -0xf0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x24(%rbp),%esi
mov    -0xe4(%rbp),%edx
lea    0xc32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x70(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movl   $0x0,0xd0(%rsp)
lea    0xe39(%rip),%rdi
lea    0xe3c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <feof@plt>
xor    %r12d,%r12d
movl   $0x0,0x4(%rsp)
test   %eax,%eax
je     121e <main+0xce>
mov    %r13,%rdi
call   1030 <fclose@plt>
lea    0xeb9(%rip),%rdi
mov    %r12d,%esi
mov    0x4(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r15d
mov    $0x15,%ebx
movl   $0x0,0x4(%rsp)
xor    %ebp,%ebp
xor    %r12d,%r12d
movl   $0x0,0x8(%rsp)
xor    %r14d,%r14d
mov    %r13,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,0x10(%rsp)
mov    %r12d,0x14(%rsp)
mov    %r13,%rdi
call   1060 <feof@plt>
movl   $0x0,0xc(%rsp)
test   %eax,%eax
je     1370 <main+0x220>
mov    %r14d,%r12d
mov    %ebx,%r13d
movslq %r15d,%rbp
cmpl   $0x1,0x20(%rsp,%rbp,4)
jne    12c5 <main+0x175>
mov    0x80(%rsp,%rbp,4),%ecx
mov    0x8(%rsp),%edx
mov    %edx,%ebx
sub    %ecx,%ebx
lea    0xd9a(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jl     12ae <main+0x15e>
mov    %eax,%ebx
movl   $0x0,0x80(%rsp,%rbp,4)
movl   $0x0,0x20(%rsp,%rbp,4)
mov    %ebx,0x4(%rsp)
mov    $0x0,%r14d
mov    $0x0,%ecx
cmp    %r12d,%r15d
je     12dc <main+0x18c>
mov    %r12d,%r14d
mov    0x10(%rsp),%ecx
mov    $0x15,%ebx
mov    $0x0,%eax
cmp    %r13d,%r15d
je     12f0 <main+0x1a0>
mov    %r13d,%ebx
mov    %ecx,%eax
xor    %ecx,%ecx
cmp    %r15d,%r14d
setg   %dl
mov    $0xffffffff,%ebp
cmp    %r15d,%ebx
mov    0x14(%rsp),%r12d
jl     130b <main+0x1bb>
mov    %dl,%cl
mov    %ecx,%ebp
test   %eax,%eax
cmovne %eax,%ebp
add    %ebp,%r15d
cmp    $0x1,%ebp
sbb    $0xffffffff,%r12d
mov    0x8(%rsp),%esi
add    $0x5,%esi
lea    0xd54(%rip),%rdi
mov    %esi,0x8(%rsp)
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%r13
mov    %r13,%rdi
call   1060 <feof@plt>
cmp    %r15d,%ebx
jle    1250 <main+0x100>
cmp    %r15d,%r14d
jge    1250 <main+0x100>
test   %eax,%eax
je     1250 <main+0x100>
jmp    11ed <main+0x9d>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
lea    0xc92(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <fscanf@plt>
mov    0xc(%rsp),%esi
cmp    %r14d,%esi
mov    %r14d,%r12d
cmovg  %esi,%r12d
cmp    %r15d,%esi
cmovle %r14d,%r12d
mov    %ebx,%r13d
cmovl  %esi,%r13d
test   %esi,%esi
cmovle %ebx,%r13d
cmp    %ebx,%esi
cmovge %ebx,%r13d
test   %esi,%esi
jle    1277 <main+0x127>
cmpl   $0x0,0x20(%rsp,%rsi,4)
jne    1277 <main+0x127>
movl   $0x1,0x20(%rsp,%rsi,4)
mov    0x8(%rsp),%edx
mov    %edx,0x80(%rsp,%rsi,4)
lea    0xc36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1277 <main+0x127>

LLVM IR (-O0):
@.str = [10 x i8] c"prob08.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [34 x i8] c"Request logged on floor %d at %d\0A\00"
@.str.4 = [75 x i8] c"Serviced Floor %d at %d, was called at %d, Time to service is %d seconds.\0A\00"
@.str.5 = [57 x i8] c"---Time = %03d, Low = %02d, Current = %02d, High = %02d\0A\00"
@.str.6 = [7 x i8] c"%d\0A%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [21 x i32]
%14 = alloca [21 x i32]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %7
store i32 21, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%18 = bitcast [21 x i32]* %13 to i8*
%19 = bitcast [21 x i32]* %14 to i8*
store i32 0, i32* %15
store i32 0, i32* %16
store i32* null, i32** %17
%20 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %17
br label %21
21: ; preds = %162, %2
%22 = load i32*, i32** %17
%23 = call i32 @feof(i32* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp sge i32 %26, %27
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = icmp sle i32 %30, %31
br label %33
33: ; preds = %29, %25, %21
%34 = phi i1 [ true, %25 ], [ true, %21 ], [ %32, %29 ]
br i1 %34, label %35, label %170
35: ; preds = %33
%36 = load i32*, i32** %17
%37 = call i32 @feof(i32* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %85, label %39
39: ; preds = %35
store i32 0, i32* %12
%40 = load i32*, i32** %17
%41 = call i32 @fscanf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%42 = load i32, i32* %12
%43 = load i32, i32* %6
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %39
%46 = load i32, i32* %12
%47 = load i32, i32* %7
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = load i32, i32* %12
store i32 %50, i32* %7
br label %51
51: ; preds = %49, %45, %39
%52 = load i32, i32* %12
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %64
54: ; preds = %51
%55 = load i32, i32* %12
%56 = load i32, i32* %6
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %64
58: ; preds = %54
%59 = load i32, i32* %12
%60 = load i32, i32* %8
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = load i32, i32* %12
store i32 %63, i32* %8
br label %64
64: ; preds = %62, %58, %54, %51
%65 = load i32, i32* %12
%66 = icmp sgt i32 %65, 0
br i1 %66, label %67, label %84
67: ; preds = %64
%68 = load i32, i32* %12
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [21 x i32], [21 x i32]* %13, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %84
73: ; preds = %67
%74 = load i32, i32* %12
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [21 x i32], [21 x i32]* %13, i64 0, i64 %75
store i32 1, i32* %76
%77 = load i32, i32* %9
%78 = load i32, i32* %12
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [21 x i32], [21 x i32]* %14, i64 0, i64 %79
store i32 %77, i32* %80
%81 = load i32, i32* %12
%82 = load i32, i32* %9
%83 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %81, i32 %82)
br label %84
84: ; preds = %73, %67, %64
br label %86
85: ; preds = %35
store i32 0, i32* %12
br label %86
86: ; preds = %85, %84
%87 = load i32, i32* %6
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [21 x i32], [21 x i32]* %13, i64 0, i64 %88
%90 = load i32, i32* %89
%91 = icmp eq i32 %90, 1
br i1 %91, label %92, label %129
92: ; preds = %86
%93 = load i32, i32* %6
%94 = load i32, i32* %9
%95 = load i32, i32* %6
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [21 x i32], [21 x i32]* %14, i64 0, i64 %96
%98 = load i32, i32* %97
%99 = load i32, i32* %9
%100 = load i32, i32* %6
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [21 x i32], [21 x i32]* %14, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = sub nsw i32 %99, %103
%105 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 %93, i32 %94, i32 %98, i32 %104)
%106 = load i32, i32* %15
%107 = load i32, i32* %9
%108 = load i32, i32* %6
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [21 x i32], [21 x i32]* %14, i64 0, i64 %109
%111 = load i32, i32* %110
%112 = sub nsw i32 %107, %111
%113 = icmp slt i32 %106, %112
br i1 %113, label %114, label %122
114: ; preds = %92
%115 = load i32, i32* %9
%116 = load i32, i32* %6
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [21 x i32], [21 x i32]* %14, i64 0, i64 %117
%119 = load i32, i32* %118
%120 = sub nsw i32 %115, %119
store i32 %120, i32* %15
%121 = load i32, i32* %6
store i32 %121, i32* %16
br label %122
122: ; preds = %114, %92
%123 = load i32, i32* %6
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds [21 x i32], [21 x i32]* %14, i64 0, i64 %124
store i32 0, i32* %125
%126 = load i32, i32* %6
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [21 x i32], [21 x i32]* %13, i64 0, i64 %127
store i32 0, i32* %128
br label %129
129: ; preds = %122, %86
%130 = load i32, i32* %6
%131 = load i32, i32* %7
%132 = icmp eq i32 %130, %131
br i1 %132, label %133, label %134
133: ; preds = %129
store i32 0, i32* %7
store i32 0, i32* %11
br label %134
134: ; preds = %133, %129
%135 = load i32, i32* %6
%136 = load i32, i32* %8
%137 = icmp eq i32 %135, %136
br i1 %137, label %138, label %139
138: ; preds = %134
store i32 21, i32* %8
store i32 0, i32* %11
br label %139
139: ; preds = %138, %134
%140 = load i32, i32* %11
%141 = icmp eq i32 %140, 0
br i1 %141, label %142, label %153
142: ; preds = %139
%143 = load i32, i32* %7
%144 = load i32, i32* %6
%145 = icmp sgt i32 %143, %144
br i1 %145, label %146, label %147
146: ; preds = %142
store i32 1, i32* %11
br label %147
147: ; preds = %146, %142
%148 = load i32, i32* %8
%149 = load i32, i32* %6
%150 = icmp slt i32 %148, %149
br i1 %150, label %151, label %152
151: ; preds = %147
store i32 -1, i32* %11
br label %152
152: ; preds = %151, %147
br label %153
153: ; preds = %152, %139
%154 = load i32, i32* %11
%155 = load i32, i32* %6
%156 = add nsw i32 %155, %154
store i32 %156, i32* %6
%157 = load i32, i32* %11
%158 = icmp ne i32 %157, 0
br i1 %158, label %159, label %162
159: ; preds = %153
%160 = load i32, i32* %10
%161 = add nsw i32 %160, 1
store i32 %161, i32* %10
br label %162
162: ; preds = %159, %153
%163 = load i32, i32* %9
%164 = add nsw i32 %163, 5
store i32 %164, i32* %9
%165 = load i32, i32* %9
%166 = load i32, i32* %8
%167 = load i32, i32* %6
%168 = load i32, i32* %7
%169 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %165, i32 %166, i32 %167, i32 %168)
br label %21
170: ; preds = %33
%171 = load i32*, i32** %17
%172 = call i32 @fclose(i32* %171)
%173 = load i32, i32* %10
%174 = load i32, i32* %15
%175 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %173, i32 %174)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"prob08.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [34 x i8] c"Request logged on floor %d at %d\0A\00"
@.str.4 = [75 x i8] c"Serviced Floor %d at %d, was called at %d, Time to service is %d seconds.\0A\00"
@.str.5 = [57 x i8] c"---Time = %03d, Low = %02d, Current = %02d, High = %02d\0A\00"
@.str.6 = [7 x i8] c"%d\0A%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [21 x i32]
%5 = alloca [21 x i32]
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast [21 x i32]* %4 to i8*
%8 = bitcast [21 x i32]* %5 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @feof(i32* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %83
12: ; preds = %2, %57
%13 = phi i32 [ %58, %57 ], [ 0, %2 ]
%14 = phi i32 [ %70, %57 ], [ 0, %2 ]
%15 = phi i32 [ %74, %57 ], [ 0, %2 ]
%16 = phi i32 [ %75, %57 ], [ 0, %2 ]
%17 = phi i32 [ %62, %57 ], [ 21, %2 ]
%18 = phi i32 [ %60, %57 ], [ 0, %2 ]
%19 = phi i32 [ %71, %57 ], [ 1, %2 ]
%20 = call i32 @feof(i32* %9)
%21 = icmp eq i32 %20, 0
store i32 0, i32* %3
br i1 %21, label %22, label %43
22: ; preds = %12
%23 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, %19
%26 = icmp sgt i32 %24, %18
%27 = and i1 %25, %26
%28 = select i1 %27, i32 %24, i32 %18
%29 = icmp sgt i32 %24, 0
%30 = icmp slt i32 %24, %19
%31 = and i1 %29, %30
%32 = icmp slt i32 %24, %17
%33 = and i1 %32, %31
%34 = select i1 %33, i32 %24, i32 %17
br i1 %29, label %35, label %43
35: ; preds = %22
%36 = zext i32 %24 to i64
%37 = getelementptr inbounds [21 x i32], [21 x i32]* %4, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
store i32 1, i32* %37
%41 = getelementptr inbounds [21 x i32], [21 x i32]* %5, i64 0, i64 %36
store i32 %16, i32* %41
%42 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %16)
br label %43
43: ; preds = %12, %22, %35, %40
%44 = phi i32 [ %28, %40 ], [ %28, %35 ], [ %28, %22 ], [ %18, %12 ]
%45 = phi i32 [ %34, %40 ], [ %34, %35 ], [ %34, %22 ], [ %17, %12 ]
%46 = sext i32 %19 to i64
%47 = getelementptr inbounds [21 x i32], [21 x i32]* %4, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %57
50: ; preds = %43
%51 = getelementptr inbounds [21 x i32], [21 x i32]* %5, i64 0, i64 %46
%52 = load i32, i32* %51
%53 = sub nsw i32 %16, %52
%54 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0), i32 %19, i32 %16, i32 %52, i32 %53)
%55 = icmp slt i32 %13, %53
%56 = select i1 %55, i32 %53, i32 %13
store i32 0, i32* %51
store i32 0, i32* %47
br label %57
57: ; preds = %50, %43
%58 = phi i32 [ %56, %50 ], [ %13, %43 ]
%59 = icmp eq i32 %19, %44
%60 = select i1 %59, i32 0, i32 %44
%61 = icmp eq i32 %19, %45
%62 = select i1 %61, i32 21, i32 %45
%63 = select i1 %61, i1 true, i1 %59
%64 = select i1 %63, i32 0, i32 %14
%65 = icmp eq i32 %64, 0
%66 = icmp sgt i32 %60, %19
%67 = zext i1 %66 to i32
%68 = icmp slt i32 %62, %19
%69 = select i1 %68, i32 -1, i32 %67
%70 = select i1 %65, i32 %69, i32 %64
%71 = add nsw i32 %70, %19
%72 = icmp ne i32 %70, 0
%73 = zext i1 %72 to i32
%74 = add nuw nsw i32 %15, %73
%75 = add nuw nsw i32 %16, 5
%76 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i32 %75, i32 %62, i32 %71, i32 %60)
%77 = call i32 @feof(i32* %9)
%78 = icmp ne i32 %77, 0
%79 = icmp slt i32 %60, %71
%80 = and i1 %79, %78
%81 = icmp sgt i32 %62, %71
%82 = and i1 %81, %80
br i1 %82, label %83, label %12
83: ; preds = %57, %2
%84 = phi i32 [ 0, %2 ], [ %74, %57 ]
%85 = phi i32 [ 0, %2 ], [ %58, %57 ]
%86 = call i32 @fclose(i32* %9)
%87 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %84, i32 %85)
ret i32 0
}