#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*/ __softboundmpx_store_null_return_metadata();
int /*<<< orphan*/ __softboundmpx_store_return_metadata(char *, char *);
char *ctime(int /*<<< orphan*/ const *);
int strlen(char *);
__attribute__((__weak__, __always___)) char *
softboundmpx_ctime(const time_t *timep) {
  char *ret_ptr = ctime(timep);
  if (ret_ptr == NULL) {
    __softboundmpx_store_null_return_metadata();
  } else {
    __softboundmpx_store_return_metadata(ret_ptr,
                                         ret_ptr + strlen(ret_ptr) + 1);
  }
  return ret_ptr;
}


x86 assembly (clang, -O0):
<softboundmpx_ctime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1170 <softboundmpx_ctime+0x30>
mov    $0x0,%al
call   1060 <__softboundmpx_store_null_return_metadata@plt>
jmp    119f <softboundmpx_ctime+0x5f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdi
cltq
add    %rax,%rsi
add    $0x1,%rsi
call   1050 <__softboundmpx_store_return_metadata@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<softboundmpx_ctime>:
push   %rbx
call   1030 <ctime@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116a <softboundmpx_ctime+0x2a>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rsi
add    $0x1,%rsi
mov    %rbx,%rdi
call   1050 <__softboundmpx_store_return_metadata@plt>
jmp    1171 <softboundmpx_ctime+0x31>
xor    %eax,%eax
call   1060 <__softboundmpx_store_null_return_metadata@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define weak i8* @softboundmpx_ctime(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i8* @ctime(i32* %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 (...) @__softboundmpx_store_null_return_metadata()
br label %19
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i8*, i8** %3
%13 = load i8*, i8** %3
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i32 @__softboundmpx_store_return_metadata(i8* %11, i8* %17)
br label %19
19: ; preds = %10, %8
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
define weak i8* @softboundmpx_ctime(i32* %0) {
%2 = tail call i8* @ctime(i32* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (...) @__softboundmpx_store_null_return_metadata()
br label %12
6: ; preds = %1
%7 = tail call i32 @strlen(i8* %2)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %2, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = tail call i32 @__softboundmpx_store_return_metadata(i8* %2, i8* %10)
br label %12
12: ; preds = %6, %4
ret i8* %2
}