#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*/ u_long;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
char *p_secstodate(u_long secs) {
  static char output[15];
  time_t clock = secs;
  struct tm *time;
  time = gmtime(&clock);
  time->tm_year += 1900;
  time->tm_mon += 1;
  sprintf(output, "%04d%02d%02d%02d%02d%02d", time->tm_year, time->tm_mon,
          time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec);
  return (output);
}


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

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

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

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@p_secstodate.output = internal global [15 x i8] zeroinitializer
@.str = [25 x i8] c"%04d%02d%02d%02d%02d%02d\00"
define i8* @p_secstodate(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 %0, i32* %2
%4 = call %struct.tm* @gmtime(i32* %2)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1900
store i32 %7, i32* %5
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
store i32 %10, i32* %8
%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 5
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%18 = load i32, i32* %17
%19 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @p_secstodate.output, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %12, i32 %14, i32 %16, i32 %18)
ret i8* getelementptr inbounds ([15 x i8], [15 x i8]* @p_secstodate.output, i64 0, i64 0)
}