#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 timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                           int /*<<< orphan*/, char const *, int, char const *,
                           char const *, ...);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
void fprint_timestamp(FILE *fd, const char *file, int line, const char *func,
                      int priority, const char *message, const char *appendix) {
  struct timeval tv = {};
  gettimeofday(&tv, 0);
  if (appendix)
    fprintf(fd, "%lu.%6.6lu %s:%u %s(...) %s: %s\n", tv.tv_sec, tv.tv_usec,
            file, line, func, message, appendix);
  else
    fprintf(fd, "%lu.%6.6lu %s:%u %s(...) %s\n", tv.tv_sec, tv.tv_usec, file,
            line, func, message);
}


x86 assembly (clang, -O0):
<fprint_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
cmpq   $0x0,0x10(%rbp)
je     11b8 <fprint_timestamp+0x88>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x20(%rbp),%r11
mov    -0x30(%rbp),%r10
mov    0x10(%rbp),%rax
lea    0xe62(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11e9 <fprint_timestamp+0xb9>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    -0x14(%rbp),%r9d
mov    -0x20(%rbp),%r10
mov    -0x30(%rbp),%rax
lea    0xe48(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_timestamp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    0x40(%rsp),%r13
movq   $0x0,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    (%rsp),%ecx
mov    0x4(%rsp),%edx
test   %r13,%r13
je     1184 <fprint_timestamp+0x64>
sub    $0x8,%rsp
lea    0xe98(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%r8
mov    %r12d,%r9d
xor    %eax,%eax
push   %r13
push   %r15
push   %r14
call   1040 <fprintf@plt>
add    $0x20,%rsp
jmp    11a3 <fprint_timestamp+0x83>
lea    0xe96(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%r8
mov    %r12d,%r9d
xor    %eax,%eax
push   %r15
push   %r14
call   1040 <fprintf@plt>
add    $0x10,%rsp
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [33 x i8] c"%lu.%6.6lu %s:%u %s(...) %s: %s\0A\00"
@.str.1 = [29 x i8] c"%lu.%6.6lu %s:%u %s(...) %s\0A\00"
define void @fprint_timestamp(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i8* %6) {
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca %struct.timeval
store i32* %0, i32** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store i8* %6, i8** %14
%16 = bitcast %struct.timeval* %15 to i8*
%17 = call i32 @gettimeofday(%struct.timeval* %15, i32 0)
%18 = load i8*, i8** %14
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %32
20: ; preds = %7
%21 = load i32*, i32** %8
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%25 = load i32, i32* %24
%26 = load i8*, i8** %9
%27 = load i32, i32* %10
%28 = load i8*, i8** %11
%29 = load i8*, i8** %13
%30 = load i8*, i8** %14
%31 = call i32 (i32*, i8*, i32, i32, i8*, i32, i8*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %25, i8* %26, i32 %27, i8* %28, i8* %29, i8* %30)
br label %43
32: ; preds = %7
%33 = load i32*, i32** %8
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%37 = load i32, i32* %36
%38 = load i8*, i8** %9
%39 = load i32, i32* %10
%40 = load i8*, i8** %11
%41 = load i8*, i8** %13
%42 = call i32 (i32*, i8*, i32, i32, i8*, i32, i8*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %37, i8* %38, i32 %39, i8* %40, i8* %41)
br label %43
43: ; preds = %32, %20
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [33 x i8] c"%lu.%6.6lu %s:%u %s(...) %s: %s\0A\00"
@.str.1 = [29 x i8] c"%lu.%6.6lu %s:%u %s(...) %s\0A\00"
define void @fprint_timestamp(i32* nocapture %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i8* %6) {
%8 = alloca i64
%9 = bitcast i64* %8 to %struct.timeval*
%10 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%11 = call i32 @gettimeofday(%struct.timeval* %9, i32 0)
%12 = icmp eq i8* %6, null
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 1
%14 = load i32, i32* %13
%15 = bitcast i64* %8 to i32*
%16 = load i32, i32* %15
br i1 %12, label %19, label %17
17: ; preds = %7
%18 = call i32 (i32*, i8*, i32, i32, i8*, i32, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %16, i8* %1, i32 %2, i8* %3, i8* %5, i8* %6)
br label %21
19: ; preds = %7
%20 = call i32 (i32*, i8*, i32, i32, i8*, i32, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %16, i8* %1, i32 %2, i8* %3, i8* %5)
br label %21
21: ; preds = %19, %17
ret void
}