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

/* Variables and functions */
int /*<<< orphan*/ ctime_r(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ date_get_by_epoch(char *, char *, int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int date_get(char *ps_date, char *ps_format) {
  time_t t_lt = time(NULL);
  int len;
  if (ps_format && *ps_format) {
    date_get_by_epoch(ps_date, ps_format, &t_lt);
  } else {
    ctime_r(&t_lt, ps_date);
    len = strlen(ps_date);
    while (len > 0) {
      --len;
      if (isspace(ps_date[len])) {
        ps_date[len] = 0;
      } else {
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<date_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119d <date_get+0x4d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119d <date_get+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <date_get_by_epoch@plt>
jmp    1204 <date_get+0xb4>
mov    -0x8(%rbp),%rsi
lea    -0x14(%rbp),%rdi
call   1060 <ctime_r@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11ff <date_get+0xaf>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11f5 <date_get+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11fa <date_get+0xaa>
jmp    11ff <date_get+0xaf>
jmp    11b6 <date_get+0x66>
jmp    1204 <date_get+0xb4>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_get>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
test   %r14,%r14
je     1187 <date_get+0x37>
cmpb   $0x0,(%r14)
je     1187 <date_get+0x37>
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <date_get_by_epoch@plt>
jmp    11d2 <date_get+0x82>
lea    0xc(%rsp),%rdi
mov    %r15,%rsi
call   1060 <ctime_r@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11d2 <date_get+0x82>
mov    %eax,%ebx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
lea    -0x2(%rbx),%r14d
movsbl (%r15,%r14,1),%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     11d2 <date_get+0x82>
movb   $0x0,(%r15,%r14,1)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11b0 <date_get+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @date_get(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8*, i8** %4
%18 = call i32 @date_get_by_epoch(i8* %16, i8* %17, i32* %5)
br label %45
19: ; preds = %10, %2
%20 = load i8*, i8** %3
%21 = call i32 @ctime_r(i32* %5, i8* %20)
%22 = load i8*, i8** %3
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %6
br label %24
24: ; preds = %43, %19
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %44
27: ; preds = %24
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
%30 = load i8*, i8** %3
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = call i64 @isspace(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %27
%38 = load i8*, i8** %3
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
br label %43
42: ; preds = %27
br label %44
43: ; preds = %37
br label %24
44: ; preds = %42, %24
br label %45
45: ; preds = %44, %15
ret i32 0
}

LLVM IR (-O2):
define i32 @date_get(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = icmp eq i8* %1, null
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @date_get_by_epoch(i8* %0, i8* %1, i32* %3)
br label %28
12: ; preds = %7, %2
%13 = call i32 @ctime_r(i32* %3, i8* %0)
%14 = call i32 @strlen(i8* %0)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = zext i32 %14 to i64
br label %18
18: ; preds = %16, %26
%19 = phi i64 [ %17, %16 ], [ %20, %26 ]
%20 = add nsw i64 %19, -1
%21 = and i64 %20, 4294967295
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = call i64 @isspace(i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %18
store i8 0, i8* %22
%27 = icmp ugt i64 %19, 1
br i1 %27, label %18, label %28
28: ; preds = %18, %26, %12, %10
ret i32 0
}