#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 errno;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char const *const);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void ab_terror(char const *const errormsg) {
  char ctime[20];
  int errno_old = errno;
  time_t stime;
  stime = time(NULL);
  strftime(ctime, 20, "%Y/%m/%d %H:%M:%S", localtime(&stime));
  fputs(ctime, stderr);
  fputs(" # ", stderr);
  errno = errno_old;
  perror(errormsg);
  return;
}


x86 assembly (clang, -O0):
<ab_terror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%ecx
mov    $0x14,%esi
lea    0xe69(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x20(%rbp),%rdi
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
lea    0xe54(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x24(%rbp),%ecx
mov    0x2e0b(%rip),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1070 <perror@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ab_terror>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
mov    0x2e72(%rip),%r15
mov    (%r15),%r12d
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe7b(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   1060 <strftime@plt>
mov    0x2e40(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1040 <fputs@plt>
mov    0x0(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1040 <fputs@plt>
mov    %r12d,(%r15)
mov    %r14,%rdi
call   1070 <perror@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c" # \00"
define void @ab_terror(i8* %0) {
%2 = alloca i8*
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i32, i32* @errno
store i32 %6, i32* %4
%7 = call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = call i32 @localtime(i32* %5)
%10 = call i32 @strftime(i8* %8, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* %11, i32 %12)
%14 = load i32, i32* @stderr
%15 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %4
store i32 %16, i32* @errno
%17 = load i8*, i8** %2
%18 = call i32 @perror(i8* %17)
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c" # \00"
define void @ab_terror(i8* nocapture %0) {
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @errno
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %3
%8 = call i32 @localtime(i32* %3)
%9 = call i32 @strftime(i8* %4, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @stderr
%11 = call i32 @fputs(i8* %4, i32 %10)
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
store i32 %5, i32* @errno
%14 = call i32 @perror(i8* %0)
ret void
}