#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;
};
struct compress {
  int dummy;
};
typedef int intmax_t;

/* Variables and functions */
char *compress_get_error(struct compress *);
scalar_t__ compress_get_hpointer(struct compress *, unsigned int *,
                                 struct timespec *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int print_time(struct compress *compress) {
  unsigned int avail;
  struct timespec tstamp;
  if (compress_get_hpointer(compress, &avail, &tstamp) != 0) {
    fprintf(stderr, "Error querying timestamp\n");
    fprintf(stderr, "ERR: %s\n", compress_get_error(compress));
    return -1;
  } else
    fprintf(stderr, "DSP played %jd.%jd\n", (intmax_t)tstamp.tv_sec,
            (intmax_t)tstamp.tv_nsec * 1000);
  return 0;
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <compress_get_hpointer@plt>
cmp    $0x0,%rax
je     11a3 <print_time+0x73>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <compress_get_error@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d1 <print_time+0xa1>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
mov    -0x28(%rbp),%rax
imul   $0x3e8,%eax,%ecx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <compress_get_hpointer@plt>
mov    0x2e91(%rip),%rbp
mov    0x0(%rbp),%edi
test   %rax,%rax
je     118a <print_time+0x5a>
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%ebp
mov    %rbx,%rdi
call   1050 <compress_get_error@plt>
lea    0xea3(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    11a6 <print_time+0x76>
mov    0x10(%rsp),%edx
imul   $0x3e8,0x8(%rsp),%ecx
lea    0xe86(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.compress = type { i32 }
%struct.timespec = type { i64, i64 }
@stderr = global i32 0
@.str = [26 x i8] c"Error querying timestamp\0A\00"
@.str.1 = [9 x i8] c"ERR: %s\0A\00"
@.str.2 = [20 x i8] c"DSP played %jd.%jd\0A\00"
define i32 @print_time(%struct.compress* %0) {
%2 = alloca i32
%3 = alloca %struct.compress*
%4 = alloca i32
%5 = alloca %struct.timespec
store %struct.compress* %0, %struct.compress** %3
%6 = load %struct.compress*, %struct.compress** %3
%7 = call i64 @compress_get_hpointer(%struct.compress* %6, i32* %4, %struct.timespec* %5)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = load %struct.compress*, %struct.compress** %3
%14 = call i8* @compress_get_error(%struct.compress* %13)
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %14)
store i32 -1, i32* %2
br label %27
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = mul nsw i32 %23, 1000
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %24)
br label %26
26: ; preds = %16
store i32 0, i32* %2
br label %27
27: ; preds = %26, %9
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
%struct.compress = type { i32 }
%struct.timespec = type { i64, i64 }
@stderr = global i32 0
@.str = [26 x i8] c"Error querying timestamp\0A\00"
@.str.1 = [9 x i8] c"ERR: %s\0A\00"
@.str.2 = [20 x i8] c"DSP played %jd.%jd\0A\00"
define i32 @print_time(%struct.compress* %0) {
%2 = alloca i32
%3 = alloca %struct.timespec
%4 = bitcast i32* %2 to i8*
%5 = bitcast %struct.timespec* %3 to i8*
%6 = call i64 @compress_get_hpointer(%struct.compress* %0, i32* %2, %struct.timespec* %3)
%7 = icmp eq i64 %6, 0
%8 = load i32, i32* @stderr
br i1 %7, label %14, label %9
9: ; preds = %1
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i8* @compress_get_error(%struct.compress* %0)
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %23
14: ; preds = %1
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = mul nsw i32 %20, 1000
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %21)
br label %23
23: ; preds = %14, %9
%24 = phi i32 [ -1, %9 ], [ 0, %14 ]
ret i32 %24
}