#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  int time_closest, a = 480, b = 585, c = 689, d = 767, e = 840;
  int time_arrival, a1 = 616, b1 = 712, c1 = 811, d1 = 900, e1 = 968;
  int hours, minutes, time;
  printf("Enter a 24-hour time: ");
  scanf("%d:%d", &hours, &minutes);
  time = 60 * hours + minutes;
  if (time < a || time < (a + b) / 2) {
    time_closest = a;
    time_arrival = a1;
  } else if (time < (b + c) / 2) {
    time_closest = b;
    time_arrival = b1;
  } else if (time < (c + d) / 2) {
    time_closest = c;
    time_arrival = c1;
  } else if (time < (d + e) / 2) {
    time_closest = d;
    time_arrival = d1;
  } else {
    time_closest = e;
    time_arrival = e1;
  }
  printf("Closest departure time is %.2d:%.2d ", time_closest / 60,
         time_closest % 60);
  if (time_closest / 60 < 12)
    printf("a.m.");
  else
    printf("p.m");
  printf(", arriving at %.2d:%.2d ", e1 / 60, e1 % 60);
  if (time_arrival / 60 < 12)
    printf("a.m.\n");
  else
    printf("p.m\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1e0,-0xc(%rbp)
movl   $0x249,-0x10(%rbp)
movl   $0x2b1,-0x14(%rbp)
movl   $0x2ff,-0x18(%rbp)
movl   $0x348,-0x1c(%rbp)
movl   $0x268,-0x24(%rbp)
movl   $0x2c8,-0x28(%rbp)
movl   $0x32b,-0x2c(%rbp)
movl   $0x384,-0x30(%rbp)
movl   $0x3c8,-0x34(%rbp)
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1040 <scanf@plt>
imul   $0x3c,-0x38(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11ce <main+0xae>
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    11df <main+0xbf>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1290 <main+0x170>
mov    -0x40(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cmp    %ecx,%eax
jge    1211 <main+0xf1>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    128b <main+0x16b>
mov    -0x40(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cmp    %ecx,%eax
jge    1243 <main+0x123>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1286 <main+0x166>
mov    -0x40(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
cmp    %ecx,%eax
jge    1275 <main+0x155>
mov    -0x18(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1281 <main+0x161>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1286 <main+0x166>
jmp    128b <main+0x16b>
jmp    1290 <main+0x170>
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0xc,%eax
jge    12dd <main+0x1bd>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12eb <main+0x1cb>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x34(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0xc,%eax
jge    1338 <main+0x218>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1346 <main+0x226>
lea    0xd2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
imul   $0x3c,0xc(%rsp),%eax
add    0x8(%rsp),%eax
mov    $0x1e0,%cx
cmp    $0x214,%eax
jl     1178 <main+0x48>
mov    $0x249,%cx
cmp    $0x27d,%eax
jae    11d3 <main+0xa3>
movzwl %cx,%eax
imul   $0x8889,%eax,%esi
shr    $0x15,%esi
imul   $0x3c,%esi,%ecx
sub    %ecx,%eax
movzwl %ax,%edx
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
mov    $0x10,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
cmp    $0x2d8,%eax
jae    1202 <main+0xd2>
lea    0xe3c(%rip),%rdi
mov    $0xb,%esi
mov    $0x1d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe62(%rip),%rbx
lea    0xe5f(%rip),%rdi
jmp    11a4 <main+0x74>
xor    %ecx,%ecx
cmp    $0x323,%eax
setae  %cl
mov    $0x2ff,%eax
mov    $0x348,%edx
cmovb  %eax,%edx
lea    (%rcx,%rcx,1),%esi
add    $0xc,%esi
imul   $0x3c,%esi,%eax
sub    %eax,%edx
movzwl %dx,%edx
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1f(%rip),%rdi
jmp    11a1 <main+0x71>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter a 24-hour time: \00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [37 x i8] c"Closest departure time is %.2d:%.2d \00"
@.str.3 = [5 x i8] c"a.m.\00"
@.str.4 = [4 x i8] c"p.m\00"
@.str.5 = [25 x i8] c", arriving at %.2d:%.2d \00"
@.str.6 = [6 x i8] c"a.m.\0A\00"
@.str.7 = [5 x i8] c"p.m\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %1
store i32 480, i32* %3
store i32 585, i32* %4
store i32 689, i32* %5
store i32 767, i32* %6
store i32 840, i32* %7
store i32 616, i32* %9
store i32 712, i32* %10
store i32 811, i32* %11
store i32 900, i32* %12
store i32 968, i32* %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %14, i32* %15)
%19 = load i32, i32* %14
%20 = mul nsw i32 60, %19
%21 = load i32, i32* %15
%22 = add nsw i32 %20, %21
store i32 %22, i32* %16
%23 = load i32, i32* %16
%24 = load i32, i32* %3
%25 = icmp slt i32 %23, %24
br i1 %25, label %33, label %26
26: ; preds = %0
%27 = load i32, i32* %16
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %28, %29
%31 = sdiv i32 %30, 2
%32 = icmp slt i32 %27, %31
br i1 %32, label %33, label %36
33: ; preds = %26, %0
%34 = load i32, i32* %3
store i32 %34, i32* %2
%35 = load i32, i32* %9
store i32 %35, i32* %8
br label %72
36: ; preds = %26
%37 = load i32, i32* %16
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = add nsw i32 %38, %39
%41 = sdiv i32 %40, 2
%42 = icmp slt i32 %37, %41
br i1 %42, label %43, label %46
43: ; preds = %36
%44 = load i32, i32* %4
store i32 %44, i32* %2
%45 = load i32, i32* %10
store i32 %45, i32* %8
br label %71
46: ; preds = %36
%47 = load i32, i32* %16
%48 = load i32, i32* %5
%49 = load i32, i32* %6
%50 = add nsw i32 %48, %49
%51 = sdiv i32 %50, 2
%52 = icmp slt i32 %47, %51
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = load i32, i32* %5
store i32 %54, i32* %2
%55 = load i32, i32* %11
store i32 %55, i32* %8
br label %70
56: ; preds = %46
%57 = load i32, i32* %16
%58 = load i32, i32* %6
%59 = load i32, i32* %7
%60 = add nsw i32 %58, %59
%61 = sdiv i32 %60, 2
%62 = icmp slt i32 %57, %61
br i1 %62, label %63, label %66
63: ; preds = %56
%64 = load i32, i32* %6
store i32 %64, i32* %2
%65 = load i32, i32* %12
store i32 %65, i32* %8
br label %69
66: ; preds = %56
%67 = load i32, i32* %7
store i32 %67, i32* %2
%68 = load i32, i32* %13
store i32 %68, i32* %8
br label %69
69: ; preds = %66, %63
br label %70
70: ; preds = %69, %53
br label %71
71: ; preds = %70, %43
br label %72
72: ; preds = %71, %33
%73 = load i32, i32* %2
%74 = sdiv i32 %73, 60
%75 = load i32, i32* %2
%76 = srem i32 %75, 60
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %74, i32 %76)
%78 = load i32, i32* %2
%79 = sdiv i32 %78, 60
%80 = icmp slt i32 %79, 12
br i1 %80, label %81, label %83
81: ; preds = %72
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %85
83: ; preds = %72
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %85
85: ; preds = %83, %81
%86 = load i32, i32* %13
%87 = sdiv i32 %86, 60
%88 = load i32, i32* %13
%89 = srem i32 %88, 60
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %87, i32 %89)
%91 = load i32, i32* %8
%92 = sdiv i32 %91, 60
%93 = icmp slt i32 %92, 12
br i1 %93, label %94, label %96
94: ; preds = %85
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %98
96: ; preds = %85
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %98
98: ; preds = %96, %94
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter a 24-hour time: \00"
@.str.1 = [6 x i8] c"%d:%d\00"
@.str.2 = [37 x i8] c"Closest departure time is %.2d:%.2d \00"
@.str.5 = [25 x i8] c", arriving at %.2d:%.2d \00"
@str = [4 x i8] c"p.m\00"
@str.8 = [5 x i8] c"a.m.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = mul nsw i32 %7, 60
%9 = load i32, i32* %2
%10 = add nsw i32 %8, %9
%11 = icmp slt i32 %10, 532
br i1 %11, label %24, label %12
12: ; preds = %0
%13 = icmp ult i32 %10, 637
br i1 %13, label %24, label %14
14: ; preds = %12
%15 = icmp ult i32 %10, 728
br i1 %15, label %31, label %16
16: ; preds = %14
%17 = icmp ult i32 %10, 803
%18 = select i1 %17, i16 767, i16 840
%19 = udiv i16 %18, 60
%20 = zext i16 %19 to i32
%21 = urem i16 %18, 60
%22 = zext i16 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %22)
br label %33
24: ; preds = %12, %0
%25 = phi i16 [ 585, %12 ], [ 480, %0 ]
%26 = udiv i16 %25, 60
%27 = zext i16 %26 to i32
%28 = urem i16 %25, 60
%29 = zext i16 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %29)
br label %33
31: ; preds = %14
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 11, i32 29)
br label %33
33: ; preds = %16, %31, %24
%34 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0), %24 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0), %31 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), %16 ]
%35 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0), %24 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), %31 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), %16 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %34)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 16, i32 8)
%38 = call i32 @puts(i8* dereferenceable(1) %35)
ret i32 0
}