#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] = {0};
  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 iss 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    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x8(%rbp),%rdi
call   1060 <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    0xe57(%rip),%rdx
call   1070 <strftime@plt>
cmp    $0x0,%rax
jne    11cb <main+0x6b>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11dd <main+0x7d>
lea    -0x20(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x40,%esi
lea    0xe0f(%rip),%rdx
call   1070 <strftime@plt>
cmp    $0x0,%rax
jne    1213 <main+0xb3>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1225 <main+0xc5>
lea    -0x60(%rbp),%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
lea    0xe84(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
test   %rax,%rax
jne    119c <main+0x4c>
lea    0xea5(%rip),%rdi
jmp    11a1 <main+0x51>
lea    0x10(%rsp),%rdi
call   1040 <puts@plt>
lea    0xe53(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
test   %rax,%rax
jne    11cd <main+0x7d>
lea    0xe55(%rip),%rdi
jmp    11d2 <main+0x82>
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 = [32 x i8] c"buffer length 64 iss 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 = bitcast [16 x i8]* %4 to i8*
%7 = call i32 @time(i32* %2)
%8 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %8, %struct.tm** %3
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%10 = load %struct.tm*, %struct.tm** %3
%11 = call i64 @strftime(i8* %9, i32 16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %struct.tm* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %18
15: ; preds = %0
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %13
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%20 = load %struct.tm*, %struct.tm** %3
%21 = call i64 @strftime(i8* %19, i32 64, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %struct.tm* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %28
25: ; preds = %18
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %25, %23
%29 = 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 = [31 x i8] c"buffer length 64 iss 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 ([31 x i8], [31 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
}