#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 scalar_t__ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
struct tm *localtime(scalar_t__ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
char *TimeString(time_t start, time_t end) {
  static char datestr[255];
  char t1[64], t2[64];
  struct tm *tbuff;
  if (start) {
    tbuff = localtime(&start);
    if (!tbuff) {
      perror("Error time convert");
      exit(250);
    }
    strftime(t1, 63, "%Y-%m-%d %H:%M:%S", tbuff);
    tbuff = localtime(&end);
    if (!tbuff) {
      perror("Error time convert");
      exit(250);
    }
    strftime(t2, 63, "%Y-%m-%d %H:%M:%S", tbuff);
    snprintf(datestr, 254, "%s - %s", t1, t2);
  } else {
    snprintf(datestr, 254, "Time Window unknown");
  }
  datestr[254] = 0;
  return datestr;
}


x86 assembly (clang, -O0):
<TimeString>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     123b <TimeString+0xeb>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    11a2 <TimeString+0x52>
lea    0xe6d(%rip),%rdi
call   1060 <perror@plt>
mov    $0xfa,%edi
call   1070 <exit@plt>
lea    -0x50(%rbp),%rdi
mov    -0x98(%rbp),%rcx
mov    $0x3f,%esi
lea    0xe5a(%rip),%rdx
call   1050 <strftime@plt>
lea    -0x10(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    11f2 <TimeString+0xa2>
lea    0xe1d(%rip),%rdi
call   1060 <perror@plt>
mov    $0xfa,%edi
call   1070 <exit@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rcx
mov    $0x3f,%esi
lea    0xe07(%rip),%rdx
call   1050 <strftime@plt>
lea    -0x50(%rbp),%rcx
lea    -0x90(%rbp),%r8
lea    0x2e3d(%rip),%rdi
mov    $0xfe,%esi
lea    0xdf6(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    1255 <TimeString+0x105>
lea    0x2e1e(%rip),%rdi
mov    $0xfe,%esi
lea    0xddf(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
movb   $0x0,0x2f02(%rip)
lea    0x2dfd(%rip),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimeString>:
push   %rbx
sub    $0x90,%rsp
mov    %rdi,0x8(%rsp)
mov    %rsi,(%rsp)
test   %rdi,%rdi
je     11df <TimeString+0x8f>
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     1210 <TimeString+0xc0>
lea    0xe93(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x3f,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
mov    %rsp,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     1210 <TimeString+0xc0>
lea    0xe6d(%rip),%rdx
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3f,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
lea    0x2e9e(%rip),%rdi
lea    0xe5c(%rip),%rdx
lea    0x10(%rsp),%rcx
mov    $0xfe,%esi
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11f9 <TimeString+0xa9>
lea    0x2e7a(%rip),%rdi
lea    0xe40(%rip),%rdx
mov    $0xfe,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
movb   $0x0,0x2f5e(%rip)
lea    0x2e59(%rip),%rax
add    $0x90,%rsp
pop    %rbx
ret
lea    0xde9(%rip),%rdi
call   1060 <perror@plt>
mov    $0xfa,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@TimeString.datestr = internal global [255 x i8] zeroinitializer
@.str = [19 x i8] c"Error time convert\00"
@.str.1 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.2 = [8 x i8] c"%s - %s\00"
@.str.3 = [20 x i8] c"Time Window unknown\00"
define i8* @TimeString(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
%7 = alloca %struct.tm*
store i64 %0, i64* %3
store i64 %1, i64* %4
%8 = load i64, i64* %3
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %34
10: ; preds = %2
%11 = call %struct.tm* @localtime(i64* %3)
store %struct.tm* %11, %struct.tm** %7
%12 = load %struct.tm*, %struct.tm** %7
%13 = icmp ne %struct.tm* %12, null
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 250)
unreachable
17: ; preds = %10
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%19 = load %struct.tm*, %struct.tm** %7
%20 = call i32 @strftime(i8* %18, i32 63, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %19)
%21 = call %struct.tm* @localtime(i64* %4)
store %struct.tm* %21, %struct.tm** %7
%22 = load %struct.tm*, %struct.tm** %7
%23 = icmp ne %struct.tm* %22, null
br i1 %23, label %27, label %24
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 250)
unreachable
27: ; preds = %17
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%29 = load %struct.tm*, %struct.tm** %7
%30 = call i32 @strftime(i8* %28, i32 63, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %29)
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%33 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 0), i32 254, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
br label %36
34: ; preds = %2
%35 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 0), i32 254, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %27
store i8 0, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 254)
ret i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@TimeString.datestr = internal global [255 x i8] zeroinitializer
@.str = [19 x i8] c"Error time convert\00"
@.str.1 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.2 = [8 x i8] c"%s - %s\00"
@.str.3 = [20 x i8] c"Time Window unknown\00"
define i8* @TimeString(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%9 = icmp eq i64 %0, 0
br i1 %9, label %26, label %10
10: ; preds = %2
%11 = call %struct.tm* @localtime(i64* %3)
%12 = icmp eq %struct.tm* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 250)
unreachable
16: ; preds = %10
%17 = call i32 @strftime(i8* %7, i32 63, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %11)
%18 = call %struct.tm* @localtime(i64* %4)
%19 = icmp eq %struct.tm* %18, null
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 250)
unreachable
23: ; preds = %16
%24 = call i32 @strftime(i8* %8, i32 63, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %18)
%25 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 0), i32 254, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %8)
br label %28
26: ; preds = %2
%27 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 0), i32 254, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %23
store i8 0, i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 254)
ret i8* getelementptr inbounds ([255 x i8], [255 x i8]* @TimeString.datestr, i64 0, i64 0)
}