#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 tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int);
char *timestr(time_t time, char *time_str) {
  struct tm *t = gmtime(&time);
  sprintf(time_str, "%i-%02i-%02i %02i:%02i", 1900 + t->tm_year, 1 + t->tm_mon,
          t->tm_mday, t->tm_hour, t->tm_min);
  return time_str;
}


x86 assembly (clang, -O0):
<timestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <gmtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
add    $0x76c,%edx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
lea    0xe8c(%rip),%rsi
mov    %eax,(%rsp)
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestr>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <gmtime@plt>
mov    $0x76c,%edx
add    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
add    $0x1,%ecx
mov    0xc(%rax),%r9d
mov    0x10(%rax),%eax
mov    %eax,(%rsp)
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [23 x i8] c"%i-%02i-%02i %02i:%02i\00"
define i8* @timestr(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.tm*
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = call %struct.tm* @gmtime(i32* %3)
store %struct.tm* %6, %struct.tm** %5
%7 = load i8*, i8** %4
%8 = load %struct.tm*, %struct.tm** %5
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = add nsw i32 1900, %10
%12 = load %struct.tm*, %struct.tm** %5
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 1, %14
%16 = load %struct.tm*, %struct.tm** %5
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
%18 = load i32, i32* %17
%19 = load %struct.tm*, %struct.tm** %5
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 3
%21 = load i32, i32* %20
%22 = load %struct.tm*, %struct.tm** %5
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 4
%24 = load i32, i32* %23
%25 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %15, i32 %18, i32 %21, i32 %24)
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [23 x i8] c"%i-%02i-%02i %02i:%02i\00"
define i8* @timestr(i32 %0, i8* returned writeonly %1) {
%3 = alloca i32
store i32 %0, i32* %3
%4 = call %struct.tm* @gmtime(i32* %3)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1900
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%16 = load i32, i32* %15
%17 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %12, i32 %14, i32 %16)
ret i8* %1
}