#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 {
  unsigned int tm_year;
  unsigned int tm_mon;
  unsigned int tm_mday;
  scalar_t__ tm_isdst;
  scalar_t__ tm_sec;
  scalar_t__ tm_min;
  scalar_t__ tm_hour;
};

/* Variables and functions */
int /*<<< orphan*/ mktime(struct tm *);
int mk_result_date(unsigned year, unsigned month, unsigned day, time_t *tp) {
  struct tm tms;
  if (year > 1900)
    year -= 1900;
  tms.tm_year = year;
  tms.tm_mon = month - 1;
  tms.tm_mday = day;
  tms.tm_hour = 0;
  tms.tm_min = tms.tm_sec = 0;
  tms.tm_isdst = 0;
  *tp = mktime(&tms);
  if (*tp == (time_t)(-1))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<mk_result_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x76c,-0x8(%rbp)
jbe    113d <mk_result_date+0x2d>
mov    -0x8(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x48(%rbp),%rdi
call   1030 <mktime@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    119c <mk_result_date+0x8c>
movl   $0x0,-0x4(%rbp)
jmp    11a3 <mk_result_date+0x93>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk_result_date>:
push   %rbx
sub    $0x30,%rsp
lea    -0x76c(%rdi),%eax
cmp    $0x76d,%edi
cmovb  %edi,%eax
mov    %rcx,%rbx
mov    %eax,(%rsp)
add    $0xffffffff,%esi
mov    %esi,0x4(%rsp)
mov    %edx,0x8(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
movups %xmm0,0x20(%rsp)
mov    %rsp,%rdi
call   1030 <mktime@plt>
mov    %eax,(%rbx)
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
setne  %cl
mov    %ecx,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i64, i64, i64, i64 }
define i32 @mk_result_date(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* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%11 = load i32, i32* %6
%12 = icmp ugt i32 %11, 1900
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32, i32* %6
%15 = sub i32 %14, 1900
store i32 %15, i32* %6
br label %16
16: ; preds = %13, %4
%17 = load i32, i32* %6
%18 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
store i32 %17, i32* %18
%19 = load i32, i32* %7
%20 = sub i32 %19, 1
%21 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
store i32 %20, i32* %21
%22 = load i32, i32* %8
%23 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 2
store i32 %22, i32* %23
%24 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 6
store i64 0, i64* %24
%25 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 4
store i64 0, i64* %25
%26 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 5
store i64 0, i64* %26
%27 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 3
store i64 0, i64* %27
%28 = call i32 @mktime(%struct.tm* %10)
%29 = load i32*, i32** %9
store i32 %28, i32* %29
%30 = load i32*, i32** %9
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %34
33: ; preds = %16
store i32 0, i32* %5
br label %35
34: ; preds = %16
store i32 1, i32* %5
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i64, i64, i64, i64 }
define i32 @mk_result_date(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca %struct.tm
%6 = bitcast %struct.tm* %5 to i8*
%7 = icmp ugt i32 %0, 1900
%8 = add i32 %0, -1900
%9 = select i1 %7, i32 %8, i32 %0
%10 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
store i32 %9, i32* %10
%11 = add i32 %1, -1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
store i32 %2, i32* %13
%14 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%15 = bitcast i64* %14 to i8*
%16 = call i32 @mktime(%struct.tm* %5)
store i32 %16, i32* %3
%17 = icmp ne i32 %16, -1
%18 = zext i1 %17 to i32
ret i32 %18
}