#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);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *);
int main() {
  int h1 = 0, m1 = 0, h2 = 0, m2 = 0, min1 = 0, min2 = 0, res = 0,
      dia = 24 * 60;
  while (1 == 1) {
    h1 = 0;
    m1 = 0;
    h2 = 0;
    m2 = 0;
    min1 = 0;
    min2 = 0;
    res = 0;
    scanf("%d %d %d %d", &h1, &m1, &h2, &m2);
    if (h1 == 0 && m1 == 0 && h2 == 0 && m2 == 0)
      break;
    min1 = h1 * 60 + m1;
    min2 = h2 * 60 + m2;
    if (min1 > min2) {
      res = dia - min1 + min2;
    } else {
      res = min2 - min1;
    }
    printf("%d\n", res);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x5a0,-0x24(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe61(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11e1 <main+0xc1>
cmpl   $0x0,-0xc(%rbp)
jne    11e1 <main+0xc1>
cmpl   $0x0,-0x10(%rbp)
jne    11e1 <main+0xc1>
cmpl   $0x0,-0x14(%rbp)
jne    11e1 <main+0xc1>
jmp    122f <main+0x10f>
imul   $0x3c,-0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
imul   $0x3c,-0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1212 <main+0xf2>
mov    -0x24(%rbp),%eax
sub    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    121b <main+0xfb>
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
jmp    1167 <main+0x47>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%rbx
lea    0xebc(%rip),%rbp
jmp    1180 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
imul   $0x3c,%ecx,%ecx
add    %edx,%ecx
imul   $0x3c,%esi,%esi
add    %eax,%esi
mov    %esi,%eax
sub    %ecx,%eax
add    $0x5a0,%eax
sub    %ecx,%esi
cmovl  %eax,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1040 <scanf@plt>
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%eax
test   %ecx,%ecx
jne    1160 <main+0x40>
test   %edx,%edx
jne    1160 <main+0x40>
test   %esi,%esi
jne    1160 <main+0x40>
test   %eax,%eax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%d %d %d %d\00"
@.str.1 = [4 x i8] c"%d\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
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 1440, i32* %9
br label %10
10: ; preds = %0, %46
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%11 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4, i32* %5)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
br label %49
24: ; preds = %20, %17, %14, %10
%25 = load i32, i32* %2
%26 = mul nsw i32 %25, 60
%27 = load i32, i32* %3
%28 = add nsw i32 %26, %27
store i32 %28, i32* %6
%29 = load i32, i32* %4
%30 = mul nsw i32 %29, 60
%31 = load i32, i32* %5
%32 = add nsw i32 %30, %31
store i32 %32, i32* %7
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %24
%37 = load i32, i32* %9
%38 = load i32, i32* %6
%39 = sub nsw i32 %37, %38
%40 = load i32, i32* %7
%41 = add nsw i32 %39, %40
store i32 %41, i32* %8
br label %46
42: ; preds = %24
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = sub nsw i32 %43, %44
store i32 %45, i32* %8
br label %46
46: ; preds = %42, %36
%47 = load i32, i32* %8
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %10
49: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d %d %d %d\00"
@.str.1 = [4 x i8] c"%d\0A\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*
%8 = bitcast i32* %4 to i8*
br label %9
9: ; preds = %22, %0
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%10 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
%15 = select i1 %12, i1 %14, i1 false
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
%18 = select i1 %15, i1 %17, i1 false
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 0
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %32, label %22
22: ; preds = %9
%23 = mul nsw i32 %11, 60
%24 = add nsw i32 %23, %13
%25 = mul nsw i32 %16, 60
%26 = add nsw i32 %25, %19
%27 = icmp slt i32 %26, %24
%28 = select i1 %27, i32 1440, i32 0
%29 = sub i32 %26, %24
%30 = add i32 %29, %28
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %9
32: ; preds = %9
ret i32 0
}