#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 */
struct timeb {
  int time;
  long millitm;
};

/* Variables and functions */
int /*<<< orphan*/ ftime(struct timeb *);
int /*<<< orphan*/ printf(char *);
long int touchatag_time_return_count_time(struct timeb *time_data) {
  struct timeb temp;
  long int diff;
  ftime(&temp);
  if (time_data->time == 0) {
    printf("Begin missing\n");
    return -1;
  }
  diff = (temp.time * 1000 + temp.millitm) -
         (time_data->time * 1000 + time_data->millitm);
  return diff;
}


x86 assembly (clang, -O0):
<touchatag_time_return_count_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <ftime@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    115b <touchatag_time_return_count_time+0x3b>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    118c <touchatag_time_return_count_time+0x6c>
imul   $0x3e8,-0x20(%rbp),%eax
cltq
add    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
imul   $0x3e8,(%rcx),%ecx
movslq %ecx,%rcx
mov    -0x10(%rbp),%rdx
add    0x8(%rdx),%rcx
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<touchatag_time_return_count_time>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1040 <ftime@plt>
movslq (%rbx),%rcx
test   %rcx,%rcx
je     1158 <touchatag_time_return_count_time+0x38>
movslq (%rsp),%rax
imul   $0x3e8,%rax,%rax
add    0x8(%rsp),%rax
imul   $0x3e8,%rcx,%rcx
add    0x8(%rbx),%rcx
sub    %rcx,%rax
jmp    116b <touchatag_time_return_count_time+0x4b>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffffffffffff,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeb = type { i32, i64 }
@.str = [15 x i8] c"Begin missing\0A\00"
define i64 @touchatag_time_return_count_time(%struct.timeb* %0) {
%2 = alloca i64
%3 = alloca %struct.timeb*
%4 = alloca %struct.timeb
%5 = alloca i64
store %struct.timeb* %0, %struct.timeb** %3
%6 = call i32 @ftime(%struct.timeb* %4)
%7 = load %struct.timeb*, %struct.timeb** %3
%8 = getelementptr inbounds %struct.timeb, %struct.timeb* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i64 -1, i64* %2
br label %32
13: ; preds = %1
%14 = getelementptr inbounds %struct.timeb, %struct.timeb* %4, i32 0, i32 0
%15 = load i32, i32* %14
%16 = mul nsw i32 %15, 1000
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds %struct.timeb, %struct.timeb* %4, i32 0, i32 1
%19 = load i64, i64* %18
%20 = add nsw i64 %17, %19
%21 = load %struct.timeb*, %struct.timeb** %3
%22 = getelementptr inbounds %struct.timeb, %struct.timeb* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = mul nsw i32 %23, 1000
%25 = sext i32 %24 to i64
%26 = load %struct.timeb*, %struct.timeb** %3
%27 = getelementptr inbounds %struct.timeb, %struct.timeb* %26, i32 0, i32 1
%28 = load i64, i64* %27
%29 = add nsw i64 %25, %28
%30 = sub nsw i64 %20, %29
store i64 %30, i64* %5
%31 = load i64, i64* %5
store i64 %31, i64* %2
br label %32
32: ; preds = %13, %11
%33 = load i64, i64* %2
ret i64 %33
}

LLVM IR (-O2):
%struct.timeb = type { i32, i64 }
@str = [14 x i8] c"Begin missing\00"
define i64 @touchatag_time_return_count_time(%struct.timeb* nocapture %0) {
%2 = alloca %struct.timeb
%3 = bitcast %struct.timeb* %2 to i8*
%4 = call i32 @ftime(%struct.timeb* %2)
%5 = getelementptr inbounds %struct.timeb, %struct.timeb* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %24
10: ; preds = %1
%11 = getelementptr inbounds %struct.timeb, %struct.timeb* %2, i64 0, i32 0
%12 = load i32, i32* %11
%13 = mul nsw i32 %12, 1000
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds %struct.timeb, %struct.timeb* %2, i64 0, i32 1
%16 = load i64, i64* %15
%17 = mul nsw i32 %6, 1000
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds %struct.timeb, %struct.timeb* %0, i64 0, i32 1
%20 = load i64, i64* %19
%21 = add i64 %16, %14
%22 = add i64 %20, %18
%23 = sub i64 %21, %22
br label %24
24: ; preds = %10, %8
%25 = phi i64 [ -1, %8 ], [ %23, %10 ]
ret i64 %25
}