#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_sec;
  int /*<<< orphan*/ tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, scalar_t__, ...);
void print_time(const struct timespec *const t) {
  if (t->tv_sec == 0) {
    printf("%ld\n", t->tv_nsec);
  } else {
    printf("%ld%09ld\n", t->tv_sec, t->tv_nsec);
  }
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1145 <print_time+0x35>
mov    -0x8(%rbp),%rax
movslq 0x8(%rax),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1161 <print_time+0x51>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
mov    (%rdi),%rsi
movslq 0x8(%rdi),%rdx
test   %rsi,%rsi
je     112a <print_time+0x1a>
lea    0xee2(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xecf(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timespec = type { i64, i32 }
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [10 x i8] c"%ld%09ld\0A\00"
define void @print_time(%struct.timespec* %0) {
%2 = alloca %struct.timespec*
store %struct.timespec* %0, %struct.timespec** %2
%3 = load %struct.timespec*, %struct.timespec** %2
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%5 = load i64, i64* %4
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load %struct.timespec*, %struct.timespec** %2
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 1
%10 = load i32, i32* %9
%11 = sext i32 %10 to i64
%12 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %11)
br label %21
13: ; preds = %1
%14 = load %struct.timespec*, %struct.timespec** %2
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load %struct.timespec*, %struct.timespec** %2
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %16, i32 %19)
br label %21
21: ; preds = %13, %7
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i32 }
@.str = [5 x i8] c"%ld\0A\00"
@.str.1 = [10 x i8] c"%ld%09ld\0A\00"
define void @print_time(%struct.timespec* nocapture %0) {
%2 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%3 = load i64, i64* %2
%4 = icmp eq i64 %3, 0
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%6 = load i32, i32* %5
br i1 %4, label %7, label %10
7: ; preds = %1
%8 = sext i32 %6 to i64
%9 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %8)
br label %12
10: ; preds = %1
%11 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %3, i32 %6)
br label %12
12: ; preds = %10, %7
ret void
}