#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 time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
struct tm *gmtime(int *);
struct tm *localtime(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int *);
int main() {
  time_t tm;
  char buff[100];
  struct tm *pgm;
  struct tm *plocal;
  time(&tm);
  printf("%d\n", tm);
  pgm = gmtime(&tm);
  strftime(buff, sizeof(buff), "%Y-%m-%d %H:%M:%S", pgm);
  printf("%s\n", buff);
  plocal = localtime(&tm);
  strftime(buff, sizeof(buff), "%Y-%m-%d %H:%M:%S", plocal);
  printf("%s\n", buff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <time@plt>
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1070 <gmtime@plt>
mov    %rax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rcx
mov    $0x64,%esi
lea    0xe67(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x70(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rcx
mov    $0x64,%esi
lea    0xe2f(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x70(%rbp),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
lea    0xc(%rsp),%r15
mov    %r15,%rdi
call   1060 <time@plt>
mov    0xc(%rsp),%esi
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1080 <gmtime@plt>
lea    0xe6a(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1070 <strftime@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1030 <localtime@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   1070 <strftime@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca %struct.tm*
%5 = alloca %struct.tm*
store i32 0, i32* %1
%6 = call i32 @time(i32* %2)
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call %struct.tm* @gmtime(i32* %2)
store %struct.tm* %9, %struct.tm** %4
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = load %struct.tm*, %struct.tm** %4
%12 = call i32 @strftime(i8* %10, i32 100, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %15, %struct.tm** %5
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = load %struct.tm*, %struct.tm** %5
%18 = call i32 @strftime(i8* %16, i32 100, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, 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)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @time(i32* %1)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call %struct.tm* @gmtime(i32* %1)
%9 = call i32 @strftime(i8* %4, i32 100, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %8)
%10 = call i32 @puts(i8* %4)
%11 = call %struct.tm* @localtime(i32* %1)
%12 = call i32 @strftime(i8* %4, i32 100, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %11)
%13 = call i32 @puts(i8* %4)
ret i32 0
}