#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, int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  const int MAX_TIMES[4] = {30, 24, 60, 60};
  int timeDiff = 0;
  int i;
  int durationTimes[4];
  int beginningTimes[4];
  int endingTimes[4];
  scanf("Dia %d", &beginningTimes[0]);
  scanf(" %d : %d : %d", &beginningTimes[1], &beginningTimes[2],
        &beginningTimes[3]);
  scanf(" Dia %d", &endingTimes[0]);
  scanf(" %d : %d : %d", &endingTimes[1], &endingTimes[2], &endingTimes[3]);
  for (i = 3; i >= 0; i--) {
    timeDiff = endingTimes[i] - beginningTimes[i] - (timeDiff < 0);
    durationTimes[i] = timeDiff;
    if (durationTimes[i] < 0)
      durationTimes[i] += MAX_TIMES[i];
  }
  printf("%d dia(s)\n%d hora(s)\n%d minuto(s)\n%d segundo(s)\n",
         durationTimes[0], durationTimes[1], durationTimes[2],
         durationTimes[3]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x50(%rbp),%rsi
add    $0x4,%rsi
lea    -0x50(%rbp),%rdx
add    $0x8,%rdx
lea    -0x50(%rbp),%rcx
add    $0xc,%rcx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x60(%rbp),%rsi
add    $0x4,%rsi
lea    -0x60(%rbp),%rdx
add    $0x8,%rdx
lea    -0x60(%rbp),%rcx
add    $0xc,%rcx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x3,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     1230 <main+0x110>
movslq -0x28(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
movslq -0x28(%rbp),%rcx
sub    -0x50(%rbp,%rcx,4),%eax
cmpl   $0x0,-0x24(%rbp)
setl   %cl
and    $0x1,%cl
movzbl %cl,%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
movslq -0x28(%rbp),%rax
cmpl   $0x0,-0x40(%rbp,%rax,4)
jge    121d <main+0xfd>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
movslq -0x28(%rbp),%rax
add    -0x40(%rbp,%rax,4),%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    1222 <main+0x102>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    11c3 <main+0xa3>
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xee3(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x1c(%rsp),%rcx
lea    0xeb2(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xeaf(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
sub    0x1c(%rsp),%eax
lea    0x3c(%rax),%r8d
test   %eax,%eax
cmovns %eax,%r8d
mov    0x8(%rsp),%edx
sub    0x18(%rsp),%edx
sar    $0x1f,%eax
lea    (%rdx,%rax,1),%ecx
add    $0x3c,%ecx
mov    %edx,%esi
add    %eax,%esi
cmovns %esi,%ecx
mov    0x4(%rsp),%eax
sub    0x14(%rsp),%eax
sar    $0x1f,%esi
lea    (%rax,%rsi,1),%edx
add    $0x18,%edx
add    %esi,%eax
cmovns %eax,%edx
mov    (%rsp),%edi
sub    0x10(%rsp),%edi
sar    $0x1f,%eax
lea    (%rdi,%rax,1),%esi
add    $0x1e,%esi
add    %eax,%edi
cmovns %edi,%esi
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.MAX_TIMES = [4 x i32] [i32 30, i32 24, i32 60, i32 60]
@.str = [7 x i8] c"Dia %d\00"
@.str.1 = [14 x i8] c" %d : %d : %d\00"
@.str.2 = [8 x i8] c" Dia %d\00"
@.str.3 = [49 x i8] c"%d dia(s)\0A%d hora(s)\0A%d minuto(s)\0A%d segundo(s)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i32]
%6 = alloca [4 x i32]
%7 = alloca [4 x i32]
store i32 0, i32* %1
%8 = bitcast [4 x i32]* %2 to i8*
store i32 0, i32* %3
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 1
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 2
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 3
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %11, i32* %12, i32* %13)
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 1
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 2
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 3
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %17, i32* %18, i32* %19)
store i32 3, i32* %4
br label %21
21: ; preds = %58, %0
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %61
24: ; preds = %21
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = sub nsw i32 %28, %32
%34 = load i32, i32* %3
%35 = icmp slt i32 %34, 0
%36 = zext i1 %35 to i32
%37 = sub nsw i32 %33, %36
store i32 %37, i32* %3
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %40
store i32 %38, i32* %41
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %57
47: ; preds = %24
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = add nsw i32 %55, %51
store i32 %56, i32* %54
br label %57
57: ; preds = %47, %24
br label %58
58: ; preds = %57
%59 = load i32, i32* %4
%60 = add nsw i32 %59, -1
store i32 %60, i32* %4
br label %21
61: ; preds = %21
%62 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%63 = load i32, i32* %62
%64 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 1
%65 = load i32, i32* %64
%66 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 2
%67 = load i32, i32* %66
%68 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 3
%69 = load i32, i32* %68
%70 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %63, i32 %65, i32 %67, i32 %69)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"Dia %d\00"
@.str.1 = [14 x i8] c" %d : %d : %d\00"
@.str.2 = [8 x i8] c" Dia %d\00"
@.str.3 = [49 x i8] c"%d dia(s)\0A%d hora(s)\0A%d minuto(s)\0A%d segundo(s)\0A\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [4 x i32]* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32* %14, i32* %15)
%17 = load i32, i32* %15
%18 = load i32, i32* %9
%19 = sub nsw i32 %17, %18
%20 = icmp slt i32 %19, 0
%21 = add nsw i32 %19, 60
%22 = select i1 %20, i32 %21, i32 %19
%23 = load i32, i32* %14
%24 = load i32, i32* %8
%25 = sub nsw i32 %23, %24
%26 = ashr i32 %19, 31
%27 = add i32 %25, %26
%28 = icmp slt i32 %27, 0
%29 = add nsw i32 %27, 60
%30 = select i1 %28, i32 %29, i32 %27
%31 = load i32, i32* %13
%32 = load i32, i32* %7
%33 = sub nsw i32 %31, %32
%34 = ashr i32 %27, 31
%35 = add i32 %33, %34
%36 = icmp slt i32 %35, 0
%37 = add nsw i32 %35, 24
%38 = select i1 %36, i32 %37, i32 %35
%39 = load i32, i32* %11
%40 = load i32, i32* %5
%41 = sub nsw i32 %39, %40
%42 = ashr i32 %35, 31
%43 = add i32 %41, %42
%44 = icmp slt i32 %43, 0
%45 = add nsw i32 %43, 30
%46 = select i1 %44, i32 %45, i32 %43
%47 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %46, i32 %38, i32 %30, i32 %22)
ret i32 0
}