#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*/ exit(int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  time_t t;
  struct tm *tmp;
  char buf1[16];
  char buf2[64];
  time(&t);
  tmp = localtime(&t);
  if (strftime(buf1, 16, "time and date: %r, %a %b %d, %Y", tmp) == 0)
    printf("buffer length 16 is too small\n");
  else
    printf("%s\n", buf1);
  if (strftime(buf2, 64, "time and date: %r, %a %b %d, %Y", tmp) == 0)
    printf("buffer length 64 is too small\n");
  else
    printf("%s\n", buf2);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <time@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x10,%esi
lea    0xe77(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x0,%rax
jne    11ab <main+0x5b>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bd <main+0x6d>
lea    -0x20(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x40,%esi
lea    0xe2f(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x0,%rax
jne    11f3 <main+0xa3>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1205 <main+0xb5>
lea    -0x60(%rbp),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
lea    0xe8c(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
test   %rax,%rax
jne    1194 <main+0x44>
lea    0xeac(%rip),%rdi
jmp    1199 <main+0x49>
lea    0x10(%rsp),%rdi
call   1040 <puts@plt>
lea    0xe5b(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
test   %rax,%rax
jne    11c5 <main+0x75>
lea    0xe5d(%rip),%rdi
jmp    11ca <main+0x7a>
lea    0x20(%rsp),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [32 x i8] c"time and date: %r, %a %b %d, %Y\00"
@.str.1 = [31 x i8] c"buffer length 16 is too small\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [31 x i8] c"buffer length 64 is too small\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca [16 x i8]
%5 = alloca [64 x i8]
store i32 0, i32* %1
%6 = call i32 @time(i32* %2)
%7 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %7, %struct.tm** %3
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%9 = load %struct.tm*, %struct.tm** %3
%10 = call i64 @strftime(i8* %8, i32 16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %17
14: ; preds = %0
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %12
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%19 = load %struct.tm*, %struct.tm** %3
%20 = call i64 @strftime(i8* %18, i32 64, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %struct.tm* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %27
24: ; preds = %17
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %22
%28 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [32 x i8] c"time and date: %r, %a %b %d, %Y\00"
@str = [30 x i8] c"buffer length 64 is too small\00"
@str.4 = [30 x i8] c"buffer length 16 is too small\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca [64 x i8]
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%7 = call i32 @time(i32* %1)
%8 = call %struct.tm* @localtime(i32* %1)
%9 = call i64 @strftime(i8* %5, i32 16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
br label %15
13: ; preds = %0
%14 = call i32 @puts(i8* %5)
br label %15
15: ; preds = %13, %11
%16 = call i64 @strftime(i8* %6, i32 64, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = call i32 @puts(i8* %6)
br label %22
22: ; preds = %20, %18
%23 = call i32 @exit(i32 0)
unreachable
}