#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*/ date_format(char *, int, int, int, int, int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
void time_diff(char *time_result, char *date_final, char *date_initial) {
  int year1, year2, year_result;
  int month1, month2, month_result;
  int day1, day2, day_result;
  int hour1, hour2, hour_result;
  int minute1, minute2, minute_result;
  int second1, second2, second_result;
  int milisecond1, milisecond2, milisecond_result;
  date_format(date_initial, year1, month1, day1, hour1, minute1, second1,
              milisecond1);
  date_format(date_final, year2, month2, day2, hour2, minute2, second2,
              milisecond2);
  milisecond_result = milisecond2 - milisecond1;
  if (milisecond_result < 0) {
    milisecond_result += 1000;
    second2--;
  }
  second_result = second2 - second1;
  if (second_result < 0) {
    second_result += 60;
    minute2--;
  }
  minute_result = minute2 - minute1;
  if (minute_result < 0) {
    minute_result += 60;
    hour2--;
  }
  hour_result = hour2 - hour1;
  if (hour_result < 0) {
    hour_result += 24;
    day2--;
  }
  day_result = day2 - day1;
  if (day_result < 0) {
    day_result += 30;
    month2--;
  }
  month_result = month2 - month1;
  if (month_result < 0) {
    month_result += 12;
    year2--;
  }
  year_result = year2 - year1;
  sprintf(time_result, "%02d:%02d:%02d.%03d", hour_result, minute_result,
          second_result, milisecond_result);
}


x86 assembly (clang, -O0):
<time_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x4c(%rbp),%r9d
mov    -0x58(%rbp),%r10d
mov    -0x64(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <date_format@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    -0x50(%rbp),%r9d
mov    -0x5c(%rbp),%r10d
mov    -0x68(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <date_format@plt>
mov    -0x68(%rbp),%eax
sub    -0x64(%rbp),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jge    11b0 <time_diff+0x90>
mov    -0x6c(%rbp),%eax
add    $0x3e8,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x5c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
sub    -0x58(%rbp),%eax
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jge    11d5 <time_diff+0xb5>
mov    -0x60(%rbp),%eax
add    $0x3c,%eax
mov    %eax,-0x60(%rbp)
mov    -0x50(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    11fa <time_diff+0xda>
mov    -0x54(%rbp),%eax
add    $0x3c,%eax
mov    %eax,-0x54(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
sub    -0x40(%rbp),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jge    121f <time_diff+0xff>
mov    -0x48(%rbp),%eax
add    $0x18,%eax
mov    %eax,-0x48(%rbp)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1244 <time_diff+0x124>
mov    -0x3c(%rbp),%eax
add    $0x1e,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    1269 <time_diff+0x149>
mov    -0x30(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    -0x60(%rbp),%r8d
mov    -0x6c(%rbp),%r9d
lea    0xd75(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_diff>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdx,%rdi
call   1030 <date_format@plt>
mov    %rbx,%rdi
call   1030 <date_format@plt>
lea    0xebc(%rip),%rsi
mov    %r14,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"%02d:%02d:%02d.%03d\00"
define void @time_diff(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%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
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = load i32, i32* %10
%31 = load i32, i32* %13
%32 = load i32, i32* %16
%33 = load i32, i32* %19
%34 = load i32, i32* %22
%35 = load i32, i32* %25
%36 = call i32 @date_format(i8* %28, i32 %29, i32 %30, i32 %31, i32 %32, i32 %33, i32 %34, i32 %35)
%37 = load i8*, i8** %5
%38 = load i32, i32* %8
%39 = load i32, i32* %11
%40 = load i32, i32* %14
%41 = load i32, i32* %17
%42 = load i32, i32* %20
%43 = load i32, i32* %23
%44 = load i32, i32* %26
%45 = call i32 @date_format(i8* %37, i32 %38, i32 %39, i32 %40, i32 %41, i32 %42, i32 %43, i32 %44)
%46 = load i32, i32* %26
%47 = load i32, i32* %25
%48 = sub nsw i32 %46, %47
store i32 %48, i32* %27
%49 = load i32, i32* %27
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %56
51: ; preds = %3
%52 = load i32, i32* %27
%53 = add nsw i32 %52, 1000
store i32 %53, i32* %27
%54 = load i32, i32* %23
%55 = add nsw i32 %54, -1
store i32 %55, i32* %23
br label %56
56: ; preds = %51, %3
%57 = load i32, i32* %23
%58 = load i32, i32* %22
%59 = sub nsw i32 %57, %58
store i32 %59, i32* %24
%60 = load i32, i32* %24
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %56
%63 = load i32, i32* %24
%64 = add nsw i32 %63, 60
store i32 %64, i32* %24
%65 = load i32, i32* %20
%66 = add nsw i32 %65, -1
store i32 %66, i32* %20
br label %67
67: ; preds = %62, %56
%68 = load i32, i32* %20
%69 = load i32, i32* %19
%70 = sub nsw i32 %68, %69
store i32 %70, i32* %21
%71 = load i32, i32* %21
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %67
%74 = load i32, i32* %21
%75 = add nsw i32 %74, 60
store i32 %75, i32* %21
%76 = load i32, i32* %17
%77 = add nsw i32 %76, -1
store i32 %77, i32* %17
br label %78
78: ; preds = %73, %67
%79 = load i32, i32* %17
%80 = load i32, i32* %16
%81 = sub nsw i32 %79, %80
store i32 %81, i32* %18
%82 = load i32, i32* %18
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %89
84: ; preds = %78
%85 = load i32, i32* %18
%86 = add nsw i32 %85, 24
store i32 %86, i32* %18
%87 = load i32, i32* %14
%88 = add nsw i32 %87, -1
store i32 %88, i32* %14
br label %89
89: ; preds = %84, %78
%90 = load i32, i32* %14
%91 = load i32, i32* %13
%92 = sub nsw i32 %90, %91
store i32 %92, i32* %15
%93 = load i32, i32* %15
%94 = icmp slt i32 %93, 0
br i1 %94, label %95, label %100
95: ; preds = %89
%96 = load i32, i32* %15
%97 = add nsw i32 %96, 30
store i32 %97, i32* %15
%98 = load i32, i32* %11
%99 = add nsw i32 %98, -1
store i32 %99, i32* %11
br label %100
100: ; preds = %95, %89
%101 = load i32, i32* %11
%102 = load i32, i32* %10
%103 = sub nsw i32 %101, %102
store i32 %103, i32* %12
%104 = load i32, i32* %12
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %111
106: ; preds = %100
%107 = load i32, i32* %12
%108 = add nsw i32 %107, 12
store i32 %108, i32* %12
%109 = load i32, i32* %8
%110 = add nsw i32 %109, -1
store i32 %110, i32* %8
br label %111
111: ; preds = %106, %100
%112 = load i32, i32* %8
%113 = load i32, i32* %7
%114 = sub nsw i32 %112, %113
store i32 %114, i32* %9
%115 = load i8*, i8** %4
%116 = load i32, i32* %18
%117 = load i32, i32* %21
%118 = load i32, i32* %24
%119 = load i32, i32* %27
%120 = call i32 @sprintf(i8* %115, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %116, i32 %117, i32 %118, i32 %119)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"%02d:%02d:%02d.%03d\00"
define void @time_diff(i8* nocapture writeonly %0, i8* %1, i8* %2) {
%4 = tail call i32 @date_format(i8* %2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef)
%5 = tail call i32 @date_format(i8* %1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef)
%6 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 undef, i32 undef, i32 undef, i32 undef)
ret void
}