#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(int argc, char *argv[]) {
  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 samll\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    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x10,%esi
lea    0xe70(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x0,%rax
jne    11b2 <main+0x62>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c4 <main+0x74>
lea    -0x30(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x40,%esi
lea    0xe6c(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x0,%rax
jne    11fa <main+0xaa>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120c <main+0xbc>
lea    -0x70(%rbp),%rsi
lea    0xe3a(%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   1060 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
mov    %rax,%rcx
call   1070 <strftime@plt>
test   %rax,%rax
jne    11a9 <main+0x49>
lea    0xec3(%rip),%rdi
call   1040 <puts@plt>
jmp    11bc <main+0x5c>
lea    0xe70(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe62(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %rbx,%rcx
call   1070 <strftime@plt>
test   %rax,%rax
jne    11ed <main+0x8d>
lea    0xe66(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe2c(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <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 samll\0A\00"
@.str.2 = [5 x i8] c"%s \0A\00"
@.str.3 = [34 x i8] c"time and date: %r, %a, %b, %d, %Y\00"
@.str.4 = [31 x i8] c"buffer length 64 is too small\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.tm*
%8 = alloca [16 x i8]
%9 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @time(i32* %6)
%11 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %11, %struct.tm** %7
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%13 = load %struct.tm*, %struct.tm** %7
%14 = call i64 @strftime(i8* %12, i32 16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), %struct.tm* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %21
18: ; preds = %2
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %16
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%23 = load %struct.tm*, %struct.tm** %7
%24 = call i64 @strftime(i8* %22, i32 64, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %31
28: ; preds = %21
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %26
%32 = 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.2 = [5 x i8] c"%s \0A\00"
@.str.3 = [34 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.5 = [30 x i8] c"buffer length 16 is too samll\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [16 x i8]
%5 = alloca [64 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%9 = call i32 @time(i32* %3)
%10 = call %struct.tm* @localtime(i32* %3)
%11 = call i64 @strftime(i8* %7, 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 = %2
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
br label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %17
17: ; preds = %15, %13
%18 = call i64 @strftime(i8* %8, i32 64, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %10)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %24
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %24
24: ; preds = %22, %20
%25 = call i32 @exit(i32 0)
unreachable
}