#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_mday;
  int tm_mon;
  int tm_year;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int ffgsdt(int *day, int *month, int *year, int *status) {
  time_t now;
  struct tm *date;
  now = time(NULL);
  date = gmtime(&now);
  if (!date) {
    date = localtime(&now);
  }
  *day = date->tm_mday;
  *month = date->tm_mon + 1;
  *year = date->tm_year + 1900;
  return (*status);
}


x86 assembly (clang, -O0):
<ffgsdt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1179 <ffgsdt+0x49>
lea    -0x24(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0x76c,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffgsdt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1050 <gmtime@plt>
test   %rax,%rax
jne    1168 <ffgsdt+0x38>
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%ecx
mov    %ecx,(%rbx)
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%r12)
mov    $0x76c,%ecx
add    0x8(%rax),%ecx
mov    %ecx,(%r15)
mov    (%r14),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
define i32 @ffgsdt(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca %struct.tm*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%11 = call i32 @time(i32* null)
store i32 %11, i32* %9
%12 = call %struct.tm* @gmtime(i32* %9)
store %struct.tm* %12, %struct.tm** %10
%13 = load %struct.tm*, %struct.tm** %10
%14 = icmp ne %struct.tm* %13, null
br i1 %14, label %17, label %15
15: ; preds = %4
%16 = call %struct.tm* @localtime(i32* %9)
store %struct.tm* %16, %struct.tm** %10
br label %17
17: ; preds = %15, %4
%18 = load %struct.tm*, %struct.tm** %10
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i32*, i32** %5
store i32 %20, i32* %21
%22 = load %struct.tm*, %struct.tm** %10
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
%26 = load i32*, i32** %6
store i32 %25, i32* %26
%27 = load %struct.tm*, %struct.tm** %10
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 2
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1900
%31 = load i32*, i32** %7
store i32 %30, i32* %31
%32 = load i32*, i32** %8
%33 = load i32, i32* %32
ret i32 %33
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
define i32 @ffgsdt(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = call %struct.tm* @gmtime(i32* %5)
%9 = icmp eq %struct.tm* %8, null
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call %struct.tm* @localtime(i32* %5)
br label %12
12: ; preds = %10, %4
%13 = phi %struct.tm* [ %8, %4 ], [ %11, %10 ]
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 0
%15 = load i32, i32* %14
store i32 %15, i32* %0
%16 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 1
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
%19 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 2
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1900
store i32 %21, i32* %2
%22 = load i32, i32* %3
ret i32 %22
}