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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ snprintf(char *, scalar_t__, char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *getlogtime_str(char *buf) {
  char tmp[25];
  time_t now;
  struct tm now_tm;
  struct timeval tv;
  now = time(NULL);
  gettimeofday(&tv, NULL);
  localtime_r(&now, &now_tm);
  strftime(tmp, sizeof(tmp), "%y/%m/%d %H:%M:%S", &now_tm);
  snprintf(buf, strlen(tmp) + 1, "%s", tmp);
  return buf;
}


x86 assembly (clang, -O0):
<getlogtime_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x34(%rbp)
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
lea    -0x34(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    -0x30(%rbp),%rdi
mov    $0x19,%esi
lea    0xe5e(%rip),%rdx
lea    -0x38(%rbp),%rcx
call   1080 <strftime@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
lea    -0x30(%rbp),%rcx
lea    0xe40(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getlogtime_str>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r15
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    0xc(%rsp),%rdi
lea    0x18(%rsp),%r14
mov    %r14,%rsi
call   1030 <localtime_r@plt>
lea    0xe64(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x19,%esi
mov    %r14,%rcx
call   1080 <strftime@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rsi
lea    0xe4e(%rip),%rdx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %r15,%rax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.timeval = type { i32 }
@.str = [18 x i8] c"%y/%m/%d %H:%M:%S\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @getlogtime_str(i8* %0) {
%2 = alloca i8*
%3 = alloca [25 x i8]
%4 = alloca i32
%5 = alloca %struct.tm
%6 = alloca %struct.timeval
store i8* %0, i8** %2
%7 = call i32 @time(i32* null)
store i32 %7, i32* %4
%8 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%9 = call i32 @localtime_r(i32* %4, %struct.tm* %5)
%10 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%11 = call i32 @strftime(i8* %10, i32 25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %5)
%12 = load i8*, i8** %2
%13 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 %14, 1
%16 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%17 = call i32 @snprintf(i8* %12, i64 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
%struct.tm = type { i32 }
%struct.timeval = type { i32 }
@.str = [18 x i8] c"%y/%m/%d %H:%M:%S\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @getlogtime_str(i8* returned %0) {
%2 = alloca [25 x i8]
%3 = alloca i32
%4 = alloca %struct.tm
%5 = alloca %struct.timeval
%6 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast %struct.tm* %4 to i8*
%9 = bitcast %struct.timeval* %5 to i8*
%10 = tail call i32 @time(i32* null)
store i32 %10, i32* %3
%11 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%12 = call i32 @localtime_r(i32* %3, %struct.tm* %4)
%13 = call i32 @strftime(i8* %6, i32 25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%14 = call i64 @strlen(i8* %6)
%15 = add nsw i64 %14, 1
%16 = call i32 @snprintf(i8* %0, i64 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
ret i8* %0
}