#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*/ find_closest_flight(int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  int hours;
  int minutes;
  int mins_from_midnight;
  int departure = 0;
  int arrival = 0;
  printf("Enter a time (24H format): ");
  scanf("%2d:%2d", &hours, &minutes);
  mins_from_midnight = hours * 60 + minutes;
  find_closest_flight(mins_from_midnight, &departure, &arrival);
  printf("Closest flight:\n");
  printf("Deparating: %.2d:%.2d, arriving: %2d:%2d\n", departure / 60,
         departure % 60, arrival / 60, arrival % 60);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
imul   $0x3c,-0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <find_closest_flight@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
mov    $0x3c,%edi
cltd
idiv   %edi
mov    %edx,%r8d
mov    -0x1c(%rbp),%edx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1060 <scanf@plt>
imul   $0x3c,0x14(%rsp),%edi
add    0x10(%rsp),%edi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <find_closest_flight@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
movslq 0xc(%rsp),%rdx
imul   $0xffffffff88888889,%rdx,%rsi
shr    $0x20,%rsi
add    %edx,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x5,%esi
add    %eax,%esi
imul   $0x3c,%esi,%eax
sub    %eax,%edx
movslq 0x8(%rsp),%r8
imul   $0xffffffff88888889,%r8,%rcx
shr    $0x20,%rcx
add    %r8d,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x5,%ecx
add    %eax,%ecx
imul   $0x3c,%ecx,%eax
sub    %eax,%r8d
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter a time (24H format): \00"
@.str.1 = [8 x i8] c"%2d:%2d\00"
@.str.2 = [17 x i8] c"Closest flight:\0A\00"
@.str.3 = [42 x i8] c"Deparating: %.2d:%.2d, arriving: %2d:%2d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 60
%11 = load i32, i32* %3
%12 = add nsw i32 %10, %11
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = call i32 @find_closest_flight(i32 %13, i32* %5, i32* %6)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %5
%17 = sdiv i32 %16, 60
%18 = load i32, i32* %5
%19 = srem i32 %18, 60
%20 = load i32, i32* %6
%21 = sdiv i32 %20, 60
%22 = load i32, i32* %6
%23 = srem i32 %22, 60
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %19, i32 %21, i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter a time (24H format): \00"
@.str.1 = [8 x i8] c"%2d:%2d\00"
@.str.3 = [42 x i8] c"Deparating: %.2d:%.2d, arriving: %2d:%2d\0A\00"
@str = [16 x i8] c"Closest flight:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%11 = load i32, i32* %1
%12 = mul nsw i32 %11, 60
%13 = load i32, i32* %2
%14 = add nsw i32 %12, %13
%15 = call i32 @find_closest_flight(i32 %14, i32* %3, i32* %4)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* %3
%18 = sdiv i32 %17, 60
%19 = srem i32 %17, 60
%20 = load i32, i32* %4
%21 = sdiv i32 %20, 60
%22 = srem i32 %20, 60
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %19, i32 %21, i32 %22)
ret i32 0
}