#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 tv_sec;
  scalar_t__ tv_usec;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, char const *);
char *strrchr(char const *, char);
const char *xyz(const char *s) {
  static char buf[128];
  struct timeval t;
  const char *ret = strrchr(s, '/');
  if (ret)
    s = ret + 1;
  gettimeofday(&t, NULL);
  buf[sizeof(buf) - 1] = '\0';
  snprintf(buf, sizeof(buf), "[%4d.%06d] %s", (int)(t.tv_sec % 1000),
           (int)(t.tv_usec), s);
  return buf;
}


x86 assembly (clang, -O0):
<xyz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1165 <xyz+0x35>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movb   $0x0,0x2f56(%rip)
mov    -0x18(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x10(%rbp),%rax
mov    %eax,%r8d
mov    -0x8(%rbp),%r9
lea    0x2eb8(%rip),%rdi
mov    $0x80,%esi
lea    0xe5c(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2ea0(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xyz>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%r14
test   %rax,%rax
cmove  %rbx,%r14
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movb   $0x0,0x2f6d(%rip)
lea    0x2ee7(%rip),%rbx
movslq 0x8(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%ecx
mov    0x10(%rsp),%r8d
lea    0xe6a(%rip),%rdx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%r9
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@xyz.buf = internal global [128 x i8] zeroinitializer
@.str = [14 x i8] c"[%4d.%06d] %s\00"
define i8* @xyz(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timeval
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strrchr(i8* %5, i8 signext 47)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %11, i8** %2
br label %12
12: ; preds = %9, %1
%13 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @xyz.buf, i64 0, i64 127)
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%15 = load i32, i32* %14
%16 = srem i32 %15, 1000
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = load i8*, i8** %2
%21 = call i32 @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @xyz.buf, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %19, i8* %20)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @xyz.buf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@xyz.buf = internal global [128 x i8] zeroinitializer
@.str = [14 x i8] c"[%4d.%06d] %s\00"
define i8* @xyz(i8* %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %0, i8* %6
%8 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @xyz.buf, i64 0, i64 127)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = srem i32 %10, 1000
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = tail call i32 @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @xyz.buf, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %14, i8* %7)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @xyz.buf, i64 0, i64 0)
}