#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 scalar_t__ time_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ time(int /*<<< orphan*/);
time_t ftbyage(int age, char aunit) {
  int deduct;
  time_t now, result;
  const double daysinyear = 365.25;
  const double secondsinday = 3600. * 24.;
  const double secondsinyear = daysinyear * secondsinday;
  const double secondsinmonth = secondsinyear / 12.;
  deduct = 0;
  now = time(0);
  switch (aunit) {
  case 'Y':
  case 'y':
    deduct = age * secondsinyear;
    break;
  case 'M':
  case 'm':
    deduct = age * secondsinmonth;
    break;
  case 'D':
  case 'd':
    deduct = age * secondsinday;
    break;
  }
  result = now - deduct;
  if (result > now) {
    fprintf(stderr, "You may not set a future time\n");
  }
  return result;
}


x86 assembly (clang, -O0):
<ftbyage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movabs $0x4076d40000000000,%rax
d4 76 40
mov    %rax,-0x28(%rbp)
movabs $0x40f5180000000000,%rax
18 f5 40
mov    %rax,-0x30(%rbp)
movabs $0x417e187e00000000,%rax
18 7e 41
mov    %rax,-0x38(%rbp)
movabs $0x4144105400000000,%rax
10 44 41
mov    %rax,-0x40(%rbp)
movl   $0x0,-0xc(%rbp)
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,-0x18(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x44(%rbp)
sub    $0x44,%eax
je     121f <ftbyage+0xff>
jmp    1190 <ftbyage+0x70>
mov    -0x44(%rbp),%eax
sub    $0x4d,%eax
je     1202 <ftbyage+0xe2>
jmp    11a1 <ftbyage+0x81>
mov    -0x44(%rbp),%eax
sub    $0x59,%eax
je     11e5 <ftbyage+0xc5>
jmp    11b2 <ftbyage+0x92>
mov    -0x44(%rbp),%eax
sub    $0x64,%eax
je     121f <ftbyage+0xff>
jmp    11c3 <ftbyage+0xa3>
mov    -0x44(%rbp),%eax
sub    $0x6d,%eax
je     1202 <ftbyage+0xe2>
jmp    11d4 <ftbyage+0xb4>
mov    -0x44(%rbp),%eax
sub    $0x79,%eax
jne    1237 <ftbyage+0x117>
jmp    11e5 <ftbyage+0xc5>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    1237 <ftbyage+0x117>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xdf9(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
jmp    1237 <ftbyage+0x117>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xdd4(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    1269 <ftbyage+0x149>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftbyage>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%r14d
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%r15
add    $0xffffffbc,%ebp
cmp    $0x35,%ebp
ja     11b2 <ftbyage+0x92>
movabs $0x100000001,%rax
bt     %rbp,%rax
jb     117a <ftbyage+0x5a>
movabs $0x20000000200,%rax
bt     %rbp,%rax
jb     1184 <ftbyage+0x64>
movabs $0x20000000200000,%rax
bt     %rbp,%rax
jae    11b2 <ftbyage+0x92>
movsd  0xe88(%rip),%xmm0
jmp    118c <ftbyage+0x6c>
movsd  0xe86(%rip),%xmm0
jmp    118c <ftbyage+0x6c>
movsd  0xe84(%rip),%xmm0
cvtsi2sd %r14d,%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebx
test   %ebx,%ebx
jns    11b2 <ftbyage+0x92>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1030 <fprintf@plt>
movslq %ebx,%rax
sub    %rax,%r15
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"You may not set a future time\0A\00"
define i64 @ftbyage(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %3
store i8 %1, i8* %4
store double 3.652500e+02, double* %8
store double 8.640000e+04, double* %9
store double 3.155760e+07, double* %10
store double 2.629800e+06, double* %11
store i32 0, i32* %5
%12 = call i64 @time(i32 0)
store i64 %12, i64* %6
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
switch i32 %14, label %30 [
i32 89, label %15
i32 121, label %15
i32 77, label %20
i32 109, label %20
i32 68, label %25
i32 100, label %25
]
15: ; preds = %2, %2
%16 = load i32, i32* %3
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 3.155760e+07
%19 = fptosi double %18 to i32
store i32 %19, i32* %5
br label %30
20: ; preds = %2, %2
%21 = load i32, i32* %3
%22 = sitofp i32 %21 to double
%23 = fmul double %22, 2.629800e+06
%24 = fptosi double %23 to i32
store i32 %24, i32* %5
br label %30
25: ; preds = %2, %2
%26 = load i32, i32* %3
%27 = sitofp i32 %26 to double
%28 = fmul double %27, 8.640000e+04
%29 = fptosi double %28 to i32
store i32 %29, i32* %5
br label %30
30: ; preds = %2, %25, %20, %15
%31 = load i64, i64* %6
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = sub nsw i64 %31, %33
store i64 %34, i64* %7
%35 = load i64, i64* %7
%36 = load i64, i64* %6
%37 = icmp sgt i64 %35, %36
br i1 %37, label %38, label %41
38: ; preds = %30
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %41
41: ; preds = %38, %30
%42 = load i64, i64* %7
ret i64 %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"You may not set a future time\0A\00"
define i64 @ftbyage(i32 %0, i8 signext %1) {
%3 = tail call i64 @time(i32 0)
%4 = sext i8 %1 to i32
switch i32 %4, label %16 [
i32 89, label %7
i32 121, label %7
i32 77, label %5
i32 109, label %5
i32 68, label %6
i32 100, label %6
]
5: ; preds = %2, %2
br label %7
6: ; preds = %2, %2
br label %7
7: ; preds = %2, %2, %6, %5
%8 = phi double [ 8.640000e+04, %6 ], [ 2.629800e+06, %5 ], [ 3.155760e+07, %2 ], [ 3.155760e+07, %2 ]
%9 = sitofp i32 %0 to double
%10 = fmul double %8, %9
%11 = fptosi double %10 to i32
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %2, %13, %7
%17 = phi i32 [ %11, %13 ], [ %11, %7 ], [ 0, %2 ]
%18 = sext i32 %17 to i64
%19 = sub nsw i64 %3, %18
ret i64 %19
}