#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 timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ twatch_print(struct timespec *, char const *);
int /*<<< orphan*/ twatch_stop_set(struct timespec *, struct timespec *);
int64_t twatch_stop_print(struct timespec *start, const char *name) {
  struct timespec tmp;
  tmp.tv_sec = 0;
  tmp.tv_nsec = 0;
  twatch_stop_set(start, &tmp);
  twatch_print(&tmp, name);
  return (int64_t)(tmp.tv_sec) * 1000 * 1000 * 1000 + (int64_t)(tmp.tv_nsec);
}


x86 assembly (clang, -O0):
<twatch_stop_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <twatch_stop_set@plt>
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdi
call   1040 <twatch_print@plt>
mov    -0x18(%rbp),%rax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,%eax,%eax
mov    -0x20(%rbp),%rcx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twatch_stop_print>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rsi
call   1030 <twatch_stop_set@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <twatch_print@plt>
imul   $0x3b9aca00,0x8(%rsp),%eax
3b
add    (%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
define i32 @twatch_stop_print(%struct.timespec* %0, i8* %1) {
%3 = alloca %struct.timespec*
%4 = alloca i8*
%5 = alloca %struct.timespec
store %struct.timespec* %0, %struct.timespec** %3
store i8* %1, i8** %4
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
store i64 0, i64* %6
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
store i64 0, i64* %7
%8 = load %struct.timespec*, %struct.timespec** %3
%9 = call i32 @twatch_stop_set(%struct.timespec* %8, %struct.timespec* %5)
%10 = load i8*, i8** %4
%11 = call i32 @twatch_print(%struct.timespec* %5, i8* %10)
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = mul nsw i32 %14, 1000
%16 = mul nsw i32 %15, 1000
%17 = mul nsw i32 %16, 1000
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = add nsw i32 %17, %20
ret i32 %21
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define i32 @twatch_stop_print(%struct.timespec* %0, i8* %1) {
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %3 to i8*
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%7 = bitcast %struct.timespec* %3 to i8*
%8 = call i32 @twatch_stop_set(%struct.timespec* %0, %struct.timespec* %3)
%9 = call i32 @twatch_print(%struct.timespec* %3, i8* %1)
%10 = load i64, i64* %5
%11 = trunc i64 %10 to i32
%12 = mul i32 %11, 1000000000
%13 = load i64, i64* %6
%14 = trunc i64 %13 to i32
%15 = add nsw i32 %12, %14
ret i32 %15
}