#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;
char *ctime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  time_t t;
  struct tm *lt;
  char buf[1000];
  if (setlocale(LC_ALL, "") == NULL) {
    printf("setlocale failed\n");
  }
  t = time(NULL);
  printf("ctime: %s", ctime(&t));
  lt = localtime(&t);
  strftime(buf, 1000, "%R %A %e %B", lt);
  printf("strftime: %s\n", buf);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1070 <setlocale@plt>
cmp    $0x0,%rax
jne    119f <main+0x3f>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xe33(%rip),%rdx
call   1080 <strftime@plt>
lea    -0x400(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x400,%rsp
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1080 <setlocale@plt>
test   %rax,%rax
jne    119e <main+0x2e>
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <ctime@plt>
lea    0xe43(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe34(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %rax,%rcx
call   1090 <strftime@plt>
lea    0xe24(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [18 x i8] c"setlocale failed\0A\00"
@.str.2 = [10 x i8] c"ctime: %s\00"
@.str.3 = [12 x i8] c"%R %A %e %B\00"
@.str.4 = [14 x i8] c"strftime: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca [1000 x i8]
store i32 0, i32* %1
%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 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = call i32 @time(i32* null)
store i32 %11, i32* %2
%12 = call i8* @ctime(i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %14, %struct.tm** %3
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%16 = load %struct.tm*, %struct.tm** %3
%17 = call i32 @strftime(i8* %15, i32 1000, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %16)
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"ctime: %s\00"
@.str.3 = [12 x i8] c"%R %A %e %B\00"
@.str.4 = [14 x i8] c"strftime: %s\0A\00"
@str = [17 x i8] c"setlocale failed\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @LC_ALL
%6 = tail call i32* @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = tail call i32 @time(i32* null)
store i32 %11, i32* %1
%12 = call i8* @ctime(i32* %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = call %struct.tm* @localtime(i32* %1)
%15 = call i32 @strftime(i8* %4, i32 1000, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %4)
ret i32 0
}