#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*/ va_list;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void vwarn(const char *format, va_list ap) {
  int error = errno;
  static char timestr[32];
  time_t t = time(0);
  struct tm *tm = localtime(&t);
  strftime(timestr, sizeof timestr, "%d/%H:%M:%S ", tm);
  vfprintf(stderr, format, ap);
  if (format[strlen(format) - 1] == ':')
    fprintf(stderr, " %s\n", strerror(error));
  else
    fputs("\n", stderr);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<vwarn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
lea    0x2ec3(%rip),%rdi
mov    $0x20,%esi
lea    0xe27(%rip),%rdx
call   1090 <strftime@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   10a0 <vfprintf@plt>
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
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1248 <vwarn+0xb8>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
call   10b0 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xdcf(%rip),%rsi
call   1060 <fprintf@plt>
jmp    125d <vwarn+0xcd>
mov    0x2d91(%rip),%rax
mov    (%rax),%esi
lea    0xdb8(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vwarn>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e35(%rip),%rax
mov    (%rax),%r14d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
lea    0x2ece(%rip),%rdi
lea    0xe37(%rip),%rdx
mov    $0x20,%esi
mov    %rax,%rcx
call   1090 <strftime@plt>
mov    0x2e03(%rip),%r15
mov    (%r15),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   10a0 <vfprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x3a,-0x1(%rax,%rbx,1)
mov    (%r15),%ebx
jne    1219 <vwarn+0x89>
mov    %r14d,%edi
call   10b0 <strerror@plt>
lea    0xe00(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
jmp    1227 <vwarn+0x97>
lea    0xdf0(%rip),%rdi
mov    %ebx,%esi
call   1050 <fputs@plt>
mov    (%r15),%edi
call   1080 <fflush@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@errno = global i32 0
@vwarn.timestr = internal global [32 x i8] zeroinitializer
@.str = [13 x i8] c"%d/%H:%M:%S \00"
@stderr = global i32 0
@.str.1 = [5 x i8] c" %s\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @vwarn(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.tm*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i32, i32* @errno
store i32 %8, i32* %5
%9 = call i32 @time(i32 0)
store i32 %9, i32* %6
%10 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %10, %struct.tm** %7
%11 = load %struct.tm*, %struct.tm** %7
%12 = call i32 @strftime(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @vwarn.timestr, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = call i32 @vfprintf(i32 %13, i8* %14, i32 %15)
%17 = load i8*, i8** %3
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 58
br i1 %25, label %26, label %31
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = load i32, i32* %5
%29 = call i8* @strerror(i32 %28)
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %34
31: ; preds = %2
%32 = load i32, i32* @stderr
%33 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %26
%35 = load i32, i32* @stderr
%36 = call i32 @fflush(i32 %35)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@errno = global i32 0
@vwarn.timestr = internal global [32 x i8] zeroinitializer
@.str = [13 x i8] c"%d/%H:%M:%S \00"
@stderr = global i32 0
@.str.1 = [5 x i8] c" %s\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @vwarn(i8* %0, i32 %1) {
%3 = alloca i32
%4 = load i32, i32* @errno
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @time(i32 0)
store i32 %6, i32* %3
%7 = call %struct.tm* @localtime(i32* %3)
%8 = call i32 @strftime(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @vwarn.timestr, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%9 = load i32, i32* @stderr
%10 = call i32 @vfprintf(i32 %9, i8* %0, i32 %1)
%11 = call i32 @strlen(i8* %0)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 58
%17 = load i32, i32* @stderr
br i1 %16, label %18, label %21
18: ; preds = %2
%19 = call i8* @strerror(i32 %4)
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %23
21: ; preds = %2
%22 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %23
23: ; preds = %21, %18
%24 = load i32, i32* @stderr
%25 = call i32 @fflush(i32 %24)
ret void
}