#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
struct statx_timestamp {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int strftime(char *, int, char *, struct tm *);
void print_time(const char *field, struct statx_timestamp *ts) {
  struct tm tm;
  time_t tim;
  char buffer[100];
  int len;
  tim = ts->tv_sec;
  if (!localtime_r(&tim, &tm)) {
    perror("localtime_r");
    exit(1);
  }
  len = strftime(buffer, 100, "%F %T", &tm);
  if (len == 0) {
    perror("strftime");
    exit(1);
  }
  printf("%s", field);
  fwrite(buffer, 1, len, stdout);
  printf(".%09u", ts->tv_nsec);
  len = strftime(buffer, 100, "%z", &tm);
  if (len == 0) {
    perror("strftime2");
    exit(1);
  }
  fwrite(buffer, 1, len, stdout);
  printf("\n");
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <localtime_r@plt>
cmp    $0x0,%eax
jne    11a9 <print_time+0x49>
lea    0xe66(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
lea    0xe53(%rip),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <strftime@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jne    11eb <print_time+0x8b>
lea    0xe36(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%edx
mov    0x2dd2(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1080 <fwrite@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
lea    0xde6(%rip),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <strftime@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jne    1270 <print_time+0x110>
lea    0xdc6(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%edx
mov    0x2d5f(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1080 <fwrite@plt>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x4(%rsi),%eax
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <localtime_r@plt>
test   %eax,%eax
je     1248 <print_time+0xd8>
lea    0xe67(%rip),%rdx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rcx
mov    $0x64,%esi
call   1060 <strftime@plt>
test   %eax,%eax
je     1251 <print_time+0xe1>
mov    %eax,%ebp
lea    0xe51(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e05(%rip),%r15
mov    (%r15),%ecx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
call   1090 <fwrite@plt>
mov    (%rbx),%esi
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1b(%rip),%rdx
lea    0x8(%rsp),%rcx
mov    %r14,%rdi
mov    $0x64,%esi
call   1060 <strftime@plt>
test   %eax,%eax
je     125a <print_time+0xea>
mov    (%r15),%ecx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1090 <fwrite@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdb1(%rip),%rdi
jmp    1261 <print_time+0xf1>
lea    0xdba(%rip),%rdi
jmp    1261 <print_time+0xf1>
lea    0xdc6(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.statx_timestamp = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [12 x i8] c"localtime_r\00"
@.str.1 = [6 x i8] c"%F %T\00"
@.str.2 = [9 x i8] c"strftime\00"
@.str.3 = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.4 = [6 x i8] c".%09u\00"
@.str.5 = [3 x i8] c"%z\00"
@.str.6 = [10 x i8] c"strftime2\00"
@.str.7 = [2 x i8] c"\0A\00"
define void @print_time(i8* %0, %struct.statx_timestamp* %1) {
%3 = alloca i8*
%4 = alloca %struct.statx_timestamp*
%5 = alloca %struct.tm
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i32
store i8* %0, i8** %3
store %struct.statx_timestamp* %1, %struct.statx_timestamp** %4
%9 = load %struct.statx_timestamp*, %struct.statx_timestamp** %4
%10 = getelementptr inbounds %struct.statx_timestamp, %struct.statx_timestamp* %9, i32 0, i32 1
%11 = load i32, i32* %10
store i32 %11, i32* %6
%12 = call i32 @localtime_r(i32* %6, %struct.tm* %5)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%19 = call i32 @strftime(i8* %18, i32 100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %5)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %17
%26 = load i8*, i8** %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%29 = load i32, i32* %8
%30 = load i32, i32* @stdout
%31 = call i32 @fwrite(i8* %28, i32 1, i32 %29, i32 %30)
%32 = load %struct.statx_timestamp*, %struct.statx_timestamp** %4
%33 = getelementptr inbounds %struct.statx_timestamp, %struct.statx_timestamp* %32, i32 0, i32 0
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%37 = call i32 @strftime(i8* %36, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %5)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %25
%41 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %25
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%45 = load i32, i32* %8
%46 = load i32, i32* @stdout
%47 = call i32 @fwrite(i8* %44, i32 1, i32 %45, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.statx_timestamp = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [12 x i8] c"localtime_r\00"
@.str.1 = [6 x i8] c"%F %T\00"
@.str.2 = [9 x i8] c"strftime\00"
@.str.3 = [3 x i8] c"%s\00"
@stdout = global i32 0
@.str.4 = [6 x i8] c".%09u\00"
@.str.5 = [3 x i8] c"%z\00"
@.str.6 = [10 x i8] c"strftime2\00"
define void @print_time(i8* %0, %struct.statx_timestamp* nocapture %1) {
%3 = alloca %struct.tm
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = bitcast %struct.tm* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds %struct.statx_timestamp, %struct.statx_timestamp* %1, i64 0, i32 1
%10 = load i32, i32* %9
store i32 %10, i32* %4
%11 = call i32 @localtime_r(i32* %4, %struct.tm* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i32 @strftime(i8* %8, i32 100, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%24 = load i32, i32* @stdout
%25 = call i32 @fwrite(i8* %8, i32 1, i32 %17, i32 %24)
%26 = getelementptr inbounds %struct.statx_timestamp, %struct.statx_timestamp* %1, i64 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = call i32 @strftime(i8* %8, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %3)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %22
%35 = load i32, i32* @stdout
%36 = call i32 @fwrite(i8* %8, i32 1, i32 %29, i32 %35)
%37 = call i32 @putchar(i32 10)
ret void
}