#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 */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
size_t strftime(char *, size_t, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
size_t _localtime(char *buf, size_t size) {
  static time_t raw_t;
  static struct tm result;
  setlocale(LC_ALL, "");
  raw_t = time(NULL);
  localtime_r(&raw_t, &result);
  return strftime(buf, size, "%x %X - ", &result);
}


x86 assembly (clang, -O0):
<_localtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
call   1050 <setlocale@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,0x2ed0(%rip)
lea    0x2ec9(%rip),%rdi
lea    0x2ec6(%rip),%rsi
call   1030 <localtime_r@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe6a(%rip),%rdx
lea    0x2eab(%rip),%rcx
call   1060 <strftime@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_localtime>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
call   1050 <setlocale@plt>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x2ed7(%rip)
lea    0x2ed0(%rip),%rdi
lea    0x2ecd(%rip),%rbx
mov    %rbx,%rsi
call   1030 <localtime_r@plt>
lea    0xe76(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <strftime@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@_localtime.raw_t = internal global i32 0
@_localtime.result = internal global %struct.tm zeroinitializer
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%x %X - \00"
define i64 @_localtime(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i32, i32* @LC_ALL
%6 = call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @time(i32* null)
store i32 %7, i32* @_localtime.raw_t
%8 = call i32 @localtime_r(i32* @_localtime.raw_t, %struct.tm* @_localtime.result)
%9 = load i8*, i8** %3
%10 = load i64, i64* %4
%11 = call i64 @strftime(i8* %9, i64 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %struct.tm* @_localtime.result)
ret i64 %11
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@_localtime.raw_t = internal global i32 0
@_localtime.result = internal global %struct.tm zeroinitializer
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%x %X - \00"
define i64 @_localtime(i8* %0, i64 %1) {
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* @_localtime.raw_t
%6 = tail call i32 @localtime_r(i32* @_localtime.raw_t, %struct.tm* @_localtime.result)
%7 = tail call i64 @strftime(i8* %0, i64 %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %struct.tm* @_localtime.result)
ret i64 %7
}