#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;
};

/* Variables and functions */
char *asctime(struct tm *);
struct tm *localtime(int /*<<< orphan*/ *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *sld_time_pretty_timestamp() {
  char *timestamp;
  time_t rawtime;
  struct tm *timedata;
  time(&rawtime);
  timedata = localtime(&rawtime);
  timestamp = asctime(timedata);
  if (timestamp[strlen(timestamp) - 1] == '\n')
    timestamp[strlen(timestamp) - 1] = '\0';
  return timestamp;
}


x86 assembly (clang, -O0):
<sld_time_pretty_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0xc(%rbp),%rdi
call   1060 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <asctime@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11b6 <sld_time_pretty_timestamp+0x76>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sld_time_pretty_timestamp>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rdi
call   1050 <asctime@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1185 <sld_time_pretty_timestamp+0x45>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i8* @sld_time_pretty_timestamp() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = call i32 @time(i32* %2)
%5 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %5, %struct.tm** %3
%6 = load %struct.tm*, %struct.tm** %3
%7 = call i8* @asctime(%struct.tm* %6)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = load i8*, i8** %1
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %8, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %24
17: ; preds = %0
%18 = load i8*, i8** %1
%19 = load i8*, i8** %1
%20 = call i32 @strlen(i8* %19)
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %18, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %17, %0
%25 = load i8*, i8** %1
ret i8* %25
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i8* @sld_time_pretty_timestamp() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* %1)
%4 = call %struct.tm* @localtime(i32* %1)
%5 = call i8* @asctime(%struct.tm* %4)
%6 = call i32 @strlen(i8* %5)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %17
12: ; preds = %0
%13 = call i32 @strlen(i8* %5)
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %5, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %12, %0
ret i8* %5
}