#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 scanf(char *, int *, int *, int *, int *);
int main(void) {
  int horaInicial, minutoInicial, horaFinal, minutoFinal, dtHora, dtMinuto;
  while (scanf("%d %d %d %d", &horaInicial, &minutoInicial, &horaFinal,
               &minutoFinal),
         horaInicial != 0 || minutoInicial != 0 || horaFinal != 0 ||
             minutoFinal != 0) {
    dtHora = horaFinal - horaInicial;
    dtMinuto = minutoFinal - minutoInicial;
    if (dtMinuto < 0) {
      dtMinuto = 60 + dtMinuto;
      dtHora -= 1;
    }
    if (dtHora < 0) {
      dtHora = 24 + dtHora;
    }
    printf("%d\n", dtHora * 60 + dtMinuto);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x1d(%rbp)
jne    1182 <main+0x62>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x1d(%rbp)
jne    1182 <main+0x62>
mov    $0x1,%al
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x1d(%rbp)
jne    1182 <main+0x62>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1192 <main+0x72>
jmp    11eb <main+0xcb>
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11c0 <main+0xa0>
mov    -0x1c(%rbp),%eax
add    $0x3c,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11d3 <main+0xb3>
mov    -0x18(%rbp),%eax
add    $0x18,%eax
mov    %eax,-0x18(%rbp)
imul   $0x3c,-0x18(%rbp),%esi
add    -0x1c(%rbp),%esi
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%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    118a <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
sub    %edx,%eax
sub    %esi,%ecx
lea    0x3c(%rcx),%edx
mov    %ecx,%esi
sar    $0x1f,%esi
lea    (%rsi,%rax,1),%edi
test   %ecx,%ecx
cmovns %ecx,%edx
test   %edi,%edi
lea    0x18(%rsi,%rax,1),%eax
cmovns %edi,%eax
imul   $0x3c,%eax,%esi
add    %edx,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1040 <scanf@plt>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ecx
test   %edx,%edx
jne    1160 <main+0x40>
test   %esi,%esi
jne    1160 <main+0x40>
test   %eax,%eax
jne    1160 <main+0x40>
test   %ecx,%ecx
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
store i32 0, i32* %1
br label %8
8: ; preds = %43, %0
%9 = 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)
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %18, %15, %12, %8
%22 = phi i1 [ true, %15 ], [ true, %12 ], [ true, %8 ], [ %20, %18 ]
br i1 %22, label %23, label %49
23: ; preds = %21
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %6
%27 = load i32, i32* %5
%28 = load i32, i32* %3
%29 = sub nsw i32 %27, %28
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %23
%33 = load i32, i32* %7
%34 = add nsw i32 60, %33
store i32 %34, i32* %7
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
store i32 %36, i32* %6
br label %37
37: ; preds = %32, %23
%38 = load i32, i32* %6
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i32, i32* %6
%42 = add nsw i32 24, %41
store i32 %42, i32* %6
br label %43
43: ; preds = %40, %37
%44 = load i32, i32* %6
%45 = mul nsw i32 %44, 60
%46 = load i32, i32* %7
%47 = add nsw i32 %45, %46
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %8
49: ; preds = %21
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
%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 ne i32 %11, 0
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
%15 = select i1 %12, i1 true, i1 %14
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 0
%18 = select i1 %15, i1 true, i1 %17
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %22, label %36
22: ; preds = %9
%23 = sub nsw i32 %16, %11
%24 = sub nsw i32 %19, %13
%25 = icmp slt i32 %24, 0
%26 = add nsw i32 %24, 60
%27 = ashr i32 %24, 31
%28 = add nsw i32 %27, %23
%29 = select i1 %25, i32 %26, i32 %24
%30 = icmp slt i32 %28, 0
%31 = add nsw i32 %28, 24
%32 = select i1 %30, i32 %31, i32 %28
%33 = mul nsw i32 %32, 60
%34 = add nsw i32 %33, %29
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %9
36: ; preds = %9
ret i32 0
}