#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 */
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 const *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 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);
  }
  return 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    0xe80(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x0,%rax
jne    11a2 <main+0x62>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b4 <main+0x74>
lea    -0x30(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x40,%esi
lea    0xe38(%rip),%rdx
call   1060 <strftime@plt>
cmp    $0x0,%rax
jne    11ea <main+0xaa>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fc <main+0xbc>
lea    -0x70(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

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    0xe9c(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
test   %rax,%rax
je     1182 <main+0x42>
lea    0x10(%rsp),%rdi
jmp    1189 <main+0x49>
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6b(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
test   %rax,%rax
je     11b3 <main+0x73>
lea    0x20(%rsp),%rdi
jmp    11ba <main+0x7a>
lea    0xe66(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

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(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 ([4 x i8], [4 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 ([32 x i8], [32 x i8]* @.str, 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.3, 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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %26
ret i32 0
}

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(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.4, i64 0, i64 0))
br label %17
15: ; preds = %2
%16 = call i32 @puts(i8* %7)
br label %17
17: ; preds = %15, %13
%18 = call i64 @strftime(i8* %8, i32 64, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, 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 @puts(i8* %8)
br label %24
24: ; preds = %22, %20
ret i32 0
}