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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
time_t cutofftimebyage(int age, char aunit) {
  time_t fileage;
  struct tm *fatm;
  fileage = time(NULL);
  fatm = localtime(&fileage);
  switch (aunit) {
  case 'Y':
    fatm->tm_year -= age;
    break;
  case 'M':
    fatm->tm_mon -= age;
    break;
  case 'D':
    fatm->tm_mday -= age;
    break;
  }
  return mktime(fatm);
}


x86 assembly (clang, -O0):
<cutofftimebyage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x44,%eax
je     11b7 <cutofftimebyage+0x87>
jmp    116f <cutofftimebyage+0x3f>
mov    -0x1c(%rbp),%eax
sub    $0x4d,%eax
je     11a3 <cutofftimebyage+0x73>
jmp    1180 <cutofftimebyage+0x50>
mov    -0x1c(%rbp),%eax
sub    $0x59,%eax
jne    11c6 <cutofftimebyage+0x96>
jmp    1191 <cutofftimebyage+0x61>
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
jmp    11c6 <cutofftimebyage+0x96>
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0x4(%rax)
jmp    11c6 <cutofftimebyage+0x96>
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%ecx
sub    %edx,%ecx
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rdi
call   1050 <mktime@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cutofftimebyage>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
cmp    $0x44,%ebp
je     1160 <cutofftimebyage+0x30>
cmp    $0x4d,%ebp
je     1169 <cutofftimebyage+0x39>
cmp    $0x59,%ebp
jne    1172 <cutofftimebyage+0x42>
mov    %rax,%rcx
jmp    1170 <cutofftimebyage+0x40>
mov    %rax,%rcx
add    $0x8,%rcx
jmp    1170 <cutofftimebyage+0x40>
mov    %rax,%rcx
add    $0x4,%rcx
sub    %ebx,(%rcx)
mov    %rax,%rdi
call   1050 <mktime@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
define i32 @cutofftimebyage(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca %struct.tm*
store i32 %0, i32* %3
store i8 %1, i8* %4
%7 = call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %8, %struct.tm** %6
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
switch i32 %10, label %29 [
i32 89, label %11
i32 77, label %17
i32 68, label %23
]
11: ; preds = %2
%12 = load i32, i32* %3
%13 = load %struct.tm*, %struct.tm** %6
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = sub nsw i32 %15, %12
store i32 %16, i32* %14
br label %29
17: ; preds = %2
%18 = load i32, i32* %3
%19 = load %struct.tm*, %struct.tm** %6
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = sub nsw i32 %21, %18
store i32 %22, i32* %20
br label %29
23: ; preds = %2
%24 = load i32, i32* %3
%25 = load %struct.tm*, %struct.tm** %6
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 2
%27 = load i32, i32* %26
%28 = sub nsw i32 %27, %24
store i32 %28, i32* %26
br label %29
29: ; preds = %2, %23, %17, %11
%30 = load %struct.tm*, %struct.tm** %6
%31 = call i32 @mktime(%struct.tm* %30)
ret i32 %31
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
define i32 @cutofftimebyage(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = call %struct.tm* @localtime(i32* %3)
%7 = sext i8 %1 to i32
switch i32 %7, label %18 [
i32 89, label %8
i32 77, label %10
i32 68, label %12
]
8: ; preds = %2
%9 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
br label %14
10: ; preds = %2
%11 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
br label %14
12: ; preds = %2
%13 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 2
br label %14
14: ; preds = %8, %10, %12
%15 = phi i32* [ %13, %12 ], [ %11, %10 ], [ %9, %8 ]
%16 = load i32, i32* %15
%17 = sub nsw i32 %16, %0
store i32 %17, i32* %15
br label %18
18: ; preds = %14, %2
%19 = call i32 @mktime(%struct.tm* %6)
ret i32 %19
}