#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;
  int tm_sec;
};

/* Variables and functions */
void *atoi(char *);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ stime(int /*<<< orphan*/ *);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ utc_mktime(struct tm *);
int setdate(void) {
  time_t systime;
  char *p, buf[5];
  struct tm tm;
  tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
  fputs("Enter year [2000]:\n", stdout);
  fgets(buf, 5, stdin);
  tm.tm_year = atoi(buf);
  fputs("Enter month [1-12]:\n", stdout);
  fgets(buf, 5, stdin);
  tm.tm_mon = atoi(buf);
  tm.tm_mon--;
  fputs("Enter day [1-31]:\n", stdout);
  fgets(buf, 5, stdin);
  tm.tm_mday = atoi(buf);
  fputs("Enter hour [0-23]:\n", stdout);
  fgets(buf, 5, stdin);
  tm.tm_hour = atoi(buf);
  fputs("Enter minute [0-59]:\n", stdout);
  fgets(buf, 5, stdin);
  tm.tm_min = atoi(buf);
  fputs("Enter seconds [0-59]:\n", stdout);
  fgets(buf, 5, stdin);
  tm.tm_sec = atoi(buf);
  if (tm.tm_year < 70)
    tm.tm_year += 2000;
  else if (tm.tm_year < 100)
    tm.tm_year += 1900;
  else if (tm.tm_year < 1970)
    usage();
  systime = utc_mktime(&tm);
  stime(&systime);
  fputs(ctime(&systime), stdout);
  exit(0);
}


x86 assembly (clang, -O0):
<setdate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x15(%rbp),%rdi
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1070 <fgets@plt>
lea    -0x15(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
lea    0xe1a(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x15(%rbp),%rdi
mov    0x2dde(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1070 <fgets@plt>
lea    -0x15(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
lea    0xdee(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x15(%rbp),%rdi
mov    0x2d9d(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1070 <fgets@plt>
lea    -0x15(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
lea    0xdc9(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x15(%rbp),%rdi
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1070 <fgets@plt>
lea    -0x15(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%esi
lea    0xda5(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x15(%rbp),%rdi
mov    0x2d2d(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1070 <fgets@plt>
lea    -0x15(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
lea    0xd83(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x15(%rbp),%rdi
mov    0x2cf5(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%esi
call   1070 <fgets@plt>
lea    -0x15(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x46,-0x30(%rbp)
jge    1325 <setdate+0x1a5>
mov    -0x30(%rbp),%eax
add    $0x7d0,%eax
mov    %eax,-0x30(%rbp)
jmp    135d <setdate+0x1dd>
cmpl   $0x64,-0x30(%rbp)
jge    133f <setdate+0x1bf>
mov    -0x30(%rbp),%eax
add    $0x76c,%eax
mov    %eax,-0x30(%rbp)
jmp    1358 <setdate+0x1d8>
cmpl   $0x7b2,-0x30(%rbp)
jge    1353 <setdate+0x1d3>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    1358 <setdate+0x1d8>
jmp    135d <setdate+0x1dd>
lea    -0x30(%rbp),%rdi
call   1040 <utc_mktime@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1060 <stime@plt>
lea    -0x4(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
mov    0x2c53(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<setdate>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e46(%rip),%r15
mov    (%r15),%esi
lea    0xe64(%rip),%rdi
call   1050 <fputs@plt>
mov    0x2e40(%rip),%r12
mov    (%r12),%edx
lea    0x23(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %rax,%r14
mov    %r14d,0x8(%rsp)
mov    (%r15),%esi
lea    0xe3c(%rip),%rdi
call   1050 <fputs@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
mov    (%r15),%esi
lea    0xe22(%rip),%rdi
call   1050 <fputs@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %eax,0x10(%rsp)
mov    (%r15),%esi
lea    0xe09(%rip),%rdi
call   1050 <fputs@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    (%r15),%esi
lea    0xdf1(%rip),%rdi
call   1050 <fputs@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %eax,0x18(%rsp)
mov    (%r15),%esi
lea    0xddb(%rip),%rdi
call   1050 <fputs@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %eax,0x1c(%rsp)
cmp    $0x45,%r14d
jg     12c1 <setdate+0x141>
add    $0x7d0,%r14d
mov    %r14d,0x8(%rsp)
jmp    12e5 <setdate+0x165>
cmp    $0x63,%r14d
ja     12d5 <setdate+0x155>
add    $0x76c,%r14d
mov    %r14d,0x8(%rsp)
jmp    12e5 <setdate+0x165>
cmp    $0x7b1,%r14d
ja     12e5 <setdate+0x165>
xor    %eax,%eax
call   1080 <usage@plt>
lea    0x8(%rsp),%rdi
call   1040 <utc_mktime@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <stime@plt>
mov    %rbx,%rdi
call   1030 <ctime@plt>
mov    (%r15),%esi
mov    %rax,%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [20 x i8] c"Enter year [2000]:\0A\00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [21 x i8] c"Enter month [1-12]:\0A\00"
@.str.2 = [19 x i8] c"Enter day [1-31]:\0A\00"
@.str.3 = [20 x i8] c"Enter hour [0-23]:\0A\00"
@.str.4 = [22 x i8] c"Enter minute [0-59]:\0A\00"
@.str.5 = [23 x i8] c"Enter seconds [0-59]:\0A\00"
define i32 @setdate() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [5 x i8]
%4 = alloca %struct.tm
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 5
store i32 0, i32* %5
%6 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 4
store i32 0, i32* %6
%7 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 3
store i32 0, i32* %7
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 2
store i32 0, i32* %8
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
store i32 0, i32* %9
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 0, i32* %10
%11 = load i32, i32* @stdout
%12 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 5, i32 %14)
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%17 = call i8* @atoi(i8* %16)
%18 = ptrtoint i8* %17 to i32
%19 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 %18, i32* %19
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i32 @fgets(i8* %22, i32 5, i32 %23)
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%26 = call i8* @atoi(i8* %25)
%27 = ptrtoint i8* %26 to i32
%28 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
store i32 %27, i32* %28
%29 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
%30 = load i32, i32* %29
%31 = add nsw i32 %30, -1
store i32 %31, i32* %29
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %34, i32 5, i32 %35)
%37 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%38 = call i8* @atoi(i8* %37)
%39 = ptrtoint i8* %38 to i32
%40 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 2
store i32 %39, i32* %40
%41 = load i32, i32* @stdout
%42 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%44 = load i32, i32* @stdin
%45 = call i32 @fgets(i8* %43, i32 5, i32 %44)
%46 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%47 = call i8* @atoi(i8* %46)
%48 = ptrtoint i8* %47 to i32
%49 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 3
store i32 %48, i32* %49
%50 = load i32, i32* @stdout
%51 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%53 = load i32, i32* @stdin
%54 = call i32 @fgets(i8* %52, i32 5, i32 %53)
%55 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%56 = call i8* @atoi(i8* %55)
%57 = ptrtoint i8* %56 to i32
%58 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 4
store i32 %57, i32* %58
%59 = load i32, i32* @stdout
%60 = call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%62 = load i32, i32* @stdin
%63 = call i32 @fgets(i8* %61, i32 5, i32 %62)
%64 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%65 = call i8* @atoi(i8* %64)
%66 = ptrtoint i8* %65 to i32
%67 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 5
store i32 %66, i32* %67
%68 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%69 = load i32, i32* %68
%70 = icmp slt i32 %69, 70
br i1 %70, label %71, label %75
71: ; preds = %0
%72 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%73 = load i32, i32* %72
%74 = add nsw i32 %73, 2000
store i32 %74, i32* %72
br label %91
75: ; preds = %0
%76 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%77 = load i32, i32* %76
%78 = icmp slt i32 %77, 100
br i1 %78, label %79, label %83
79: ; preds = %75
%80 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%81 = load i32, i32* %80
%82 = add nsw i32 %81, 1900
store i32 %82, i32* %80
br label %90
83: ; preds = %75
%84 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%85 = load i32, i32* %84
%86 = icmp slt i32 %85, 1970
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = call i32 (...) @usage()
br label %89
89: ; preds = %87, %83
br label %90
90: ; preds = %89, %79
br label %91
91: ; preds = %90, %71
%92 = call i32 @utc_mktime(%struct.tm* %4)
store i32 %92, i32* %1
%93 = call i32 @stime(i32* %1)
%94 = call i8* @ctime(i32* %1)
%95 = load i32, i32* @stdout
%96 = call i32 @fputs(i8* %94, i32 %95)
%97 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [20 x i8] c"Enter year [2000]:\0A\00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [21 x i8] c"Enter month [1-12]:\0A\00"
@.str.2 = [19 x i8] c"Enter day [1-31]:\0A\00"
@.str.3 = [20 x i8] c"Enter hour [0-23]:\0A\00"
@.str.4 = [22 x i8] c"Enter minute [0-59]:\0A\00"
@.str.5 = [23 x i8] c"Enter seconds [0-59]:\0A\00"
define i32 @setdate() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca %struct.tm
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = bitcast %struct.tm* %3 to i8*
%7 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
%10 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%11 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%13 = load i32, i32* @stdout
%14 = tail call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %5, i32 5, i32 %15)
%17 = call i8* @atoi(i8* %5)
%18 = ptrtoint i8* %17 to i64
%19 = trunc i64 %18 to i32
store i32 %19, i32* %12
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @stdin
%23 = call i32 @fgets(i8* %5, i32 5, i32 %22)
%24 = call i8* @atoi(i8* %5)
%25 = ptrtoint i8* %24 to i64
%26 = trunc i64 %25 to i32
%27 = add nsw i32 %26, -1
store i32 %27, i32* %11
%28 = load i32, i32* @stdout
%29 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @stdin
%31 = call i32 @fgets(i8* %5, i32 5, i32 %30)
%32 = call i8* @atoi(i8* %5)
%33 = ptrtoint i8* %32 to i64
%34 = trunc i64 %33 to i32
store i32 %34, i32* %10
%35 = load i32, i32* @stdout
%36 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @stdin
%38 = call i32 @fgets(i8* %5, i32 5, i32 %37)
%39 = call i8* @atoi(i8* %5)
%40 = ptrtoint i8* %39 to i64
%41 = trunc i64 %40 to i32
store i32 %41, i32* %9
%42 = load i32, i32* @stdout
%43 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @stdin
%45 = call i32 @fgets(i8* %5, i32 5, i32 %44)
%46 = call i8* @atoi(i8* %5)
%47 = ptrtoint i8* %46 to i64
%48 = trunc i64 %47 to i32
store i32 %48, i32* %8
%49 = load i32, i32* @stdout
%50 = call i32 @fputs(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = load i32, i32* @stdin
%52 = call i32 @fgets(i8* %5, i32 5, i32 %51)
%53 = call i8* @atoi(i8* %5)
%54 = ptrtoint i8* %53 to i64
%55 = trunc i64 %54 to i32
store i32 %55, i32* %7
%56 = icmp slt i32 %19, 70
br i1 %56, label %57, label %59
57: ; preds = %0
%58 = add nsw i32 %19, 2000
store i32 %58, i32* %12
br label %67
59: ; preds = %0
%60 = icmp ult i32 %19, 100
br i1 %60, label %61, label %63
61: ; preds = %59
%62 = add nuw nsw i32 %19, 1900
store i32 %62, i32* %12
br label %67
63: ; preds = %59
%64 = icmp ult i32 %19, 1970
br i1 %64, label %65, label %67
65: ; preds = %63
%66 = call i32 (...) @usage()
br label %67
67: ; preds = %61, %65, %63, %57
%68 = call i32 @utc_mktime(%struct.tm* %3)
store i32 %68, i32* %1
%69 = call i32 @stime(i32* %1)
%70 = call i8* @ctime(i32* %1)
%71 = load i32, i32* @stdout
%72 = call i32 @fputs(i8* %70, i32 %71)
%73 = call i32 @exit(i32 0)
unreachable
}