#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 tm_year;
  int tm_mon;
  int /*<<< orphan*/ tm_mday;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ remove_sub_name(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, int,
                           int /*<<< orphan*/);
scalar_t__ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int getLogName(char *date, char *file_name) {
  char log_name[128];
  time_t lt;
  time(&lt);
  if (strlen("") == 0) {
    remove_sub_name(log_name, file_name);
  }
  struct tm *tm_1 = localtime(&lt);
  sprintf(date, "%s_%d%02d%02d.log", log_name, tm_1->tm_year + 1900,
          tm_1->tm_mon + 1, tm_1->tm_mday);
  return 0;
}


x86 assembly (clang, -O0):
<getLogName>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x94(%rbp),%rdi
call   1060 <time@plt>
lea    0xe9b(%rip),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    1195 <getLogName+0x45>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <remove_sub_name@plt>
lea    -0x94(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    -0xa0(%rbp),%rax
mov    (%rax),%ecx
add    $0x76c,%ecx
mov    -0xa0(%rbp),%rax
mov    0x4(%rax),%r8d
add    $0x1,%r8d
mov    -0xa0(%rbp),%rax
mov    0x8(%rax),%r9d
lea    0xe1d(%rip),%rsi
call   1070 <sprintf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLogName>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xc(%rsp),%r15
mov    %r15,%rdi
call   1050 <time@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <remove_sub_name@plt>
mov    %r15,%rdi
call   1030 <localtime@plt>
mov    $0x76c,%ecx
add    (%rax),%ecx
mov    0x4(%rax),%r8d
mov    0x8(%rax),%r9d
add    $0x1,%r8d
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
call   1060 <sprintf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [18 x i8] c"%s_%d%02d%02d.log\00"
define i32 @getLogName(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [128 x i8]
%6 = alloca i32
%7 = alloca %struct.tm*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 @time(i32* %6)
%9 = call i64 @strlen(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @remove_sub_name(i8* %12, i8* %13)
br label %15
15: ; preds = %11, %2
%16 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %16, %struct.tm** %7
%17 = load i8*, i8** %3
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%19 = load %struct.tm*, %struct.tm** %7
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1900
%23 = load %struct.tm*, %struct.tm** %7
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 1
%27 = load %struct.tm*, %struct.tm** %7
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 2
%29 = load i32, i32* %28
%30 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %22, i32 %26, i32 %29)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str.1 = [18 x i8] c"%s_%d%02d%02d.log\00"
define i32 @getLogName(i8* nocapture writeonly %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = call i32 @time(i32* %4)
%8 = call i32 @remove_sub_name(i8* %5, i8* %1)
%9 = call %struct.tm* @localtime(i32* %4)
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1900
%13 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
%16 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 2
%17 = load i32, i32* %16
%18 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %5, i32 %12, i32 %15, i32 %17)
ret i32 0
}