#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 double time_t;
struct tm {
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_sec;
};

/* Variables and functions */
int abs(int);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ exit(int);
double labs(double);
double mktime(struct tm *);
int /*<<< orphan*/ print_help(char *);
int /*<<< orphan*/ printf(char *, char *, long, char *, int, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
char strptime(char *, char *, struct tm *);
double time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  struct tm birthday = {
      .tm_sec = 0,
      .tm_min = 0,
      .tm_hour = 0,
  };
  time_t seconds;
  int years;
  bool secs_positive;
  if (argc != 2) {
    print_help(argv[0]);
    exit(argc > 2 ? argv[1][1] != 'h' : 1);
  }
  if (strptime(argv[1], "%Y-%m-%d", &birthday) == '\0') {
    print_help(argv[0]);
    putchar('\n');
    die("Your date is invalid!");
  }
  seconds = time(NULL) - mktime(&birthday);
  secs_positive = (seconds > 0);
  seconds = labs(seconds);
  years = abs((int)((seconds) / (365.25 * 24 * 60 * 60)));
  if (!seconds) {
    puts("You managed to be born this very second. Happy birthday!");
    exit(0);
  }
  printf("%s ca. %ld second%s, that is, %d year%s.\n",
         secs_positive ? "Your age is" : "You'll be born in", (long)seconds,
         (seconds - 1) ? "s" : "", years, (years - 1) ? "s" : "");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
cmpl   $0x2,-0x8(%rbp)
je     123a <main+0x7a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <print_help@plt>
cmpl   $0x2,-0x8(%rbp)
jle    1225 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x68,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x34(%rbp)
jmp    1232 <main+0x72>
mov    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1232 <main+0x72>
mov    -0x34(%rbp),%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc7(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   10e0 <strptime@plt>
movsbl %al,%eax
cmp    $0x0,%eax
jne    1280 <main+0xc0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <print_help@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd9e(%rip),%rdi
call   10b0 <die@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
movsd  %xmm0,-0x40(%rbp)
lea    -0x20(%rbp),%rdi
call   10a0 <mktime@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <labs@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xd25(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <abs@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1316 <main+0x156>
jp     1316 <main+0x156>
lea    0xd25(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x30(%rbp),%ecx
lea    0xd7e(%rip),%rsi
lea    0xd6b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
cvttsd2si -0x28(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
movsd  0xcc7(%rip),%xmm1
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
lea    0xd42(%rip),%rcx
lea    0xd46(%rip),%rax
ucomisd %xmm1,%xmm0
setp   %r8b
setne  %dil
or     %r8b,%dil
cmovne %rax,%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x2c(%rbp),%edi
sub    $0x1,%edi
lea    0xd17(%rip),%r9
lea    0xd1b(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%r9
lea    0xcd9(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movl   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jne    12b3 <main+0x113>
mov    0x8(%rbx),%rdi
lea    0xe42(%rip),%rsi
lea    0x8(%rsp),%rdx
call   10c0 <strptime@plt>
test   %al,%al
jne    11fa <main+0x5a>
mov    (%rbx),%rdi
call   10a0 <print_help@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe24(%rip),%rdi
call   1090 <die@plt>
xor    %edi,%edi
call   1070 <time@plt>
movsd  %xmm0,(%rsp)
lea    0x8(%rsp),%rdi
call   1080 <mktime@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1050 <labs@plt>
movapd %xmm0,%xmm1
divsd  0xdcd(%rip),%xmm1
cvttsd2si %xmm1,%eax
mov    %eax,%r8d
neg    %r8d
cmovs  %eax,%r8d
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1251 <main+0xb1>
jnp    12da <main+0x13a>
movsd  (%rsp),%xmm2
ucomisd %xmm1,%xmm2
lea    0xe31(%rip),%rax
lea    0xe36(%rip),%rsi
cmova  %rax,%rsi
cvttsd2si %xmm0,%rdx
addsd  0xd8f(%rip),%xmm0
ucomisd %xmm1,%xmm0
lea    0xe18(%rip),%rax
lea    0xe06(%rip),%r9
mov    %r9,%rcx
cmovne %rax,%rcx
cmovp  %rax,%rcx
cmp    $0x1,%r8d
cmovne %rax,%r9
lea    0xdc3(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    %edi,%ebp
mov    (%rbx),%rdi
call   10a0 <print_help@plt>
mov    $0x1,%edi
cmp    $0x3,%ebp
jl     12d5 <main+0x135>
mov    0x8(%rbx),%rax
xor    %edi,%edi
cmpb   $0x68,0x1(%rax)
setne  %dil
call   10b0 <exit@plt>
lea    0xd4e(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [9 x i8] c"%Y-%m-%d\00"
@.str.1 = [22 x i8] c"Your date is invalid!\00"
@.str.2 = [57 x i8] c"You managed to be born this very second. Happy birthday!\00"
@.str.3 = [42 x i8] c"%s ca. %ld second%s, that is, %d year%s.\0A\00"
@.str.4 = [12 x i8] c"Your age is\00"
@.str.5 = [18 x i8] c"You'll be born in\00"
@.str.6 = [2 x i8] c"s\00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.tm
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast %struct.tm* %6 to i8*
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %33
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @print_help(i8* %16)
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 104
%28 = zext i1 %27 to i32
br label %30
29: ; preds = %13
br label %30
30: ; preds = %29, %20
%31 = phi i32 [ %28, %20 ], [ 1, %29 ]
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call signext i8 @strptime(i8* %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %33
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @print_help(i8* %43)
%45 = call i32 @putchar(i8 signext 10)
%46 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %47
47: ; preds = %40, %33
%48 = call double @time(i32* null)
%49 = call double @mktime(%struct.tm* %6)
%50 = fsub double %48, %49
store double %50, double* %7
%51 = load double, double* %7
%52 = fcmp ogt double %51, 0.000000e+00
%53 = zext i1 %52 to i32
store i32 %53, i32* %9
%54 = load double, double* %7
%55 = call double @labs(double %54)
store double %55, double* %7
%56 = load double, double* %7
%57 = fdiv double %56, 3.155760e+07
%58 = fptosi double %57 to i32
%59 = call i32 @abs(i32 %58)
store i32 %59, i32* %8
%60 = load double, double* %7
%61 = fcmp une double %60, 0.000000e+00
br i1 %61, label %65, label %62
62: ; preds = %47
%63 = call i32 @puts(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%64 = call i32 @exit(i32 0)
unreachable
65: ; preds = %47
%66 = load i32, i32* %9
%67 = icmp ne i32 %66, 0
%68 = zext i1 %67 to i64
%69 = select i1 %67, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0)
%70 = load double, double* %7
%71 = fptosi double %70 to i64
%72 = load double, double* %7
%73 = fsub double %72, 1.000000e+00
%74 = fcmp une double %73, 0.000000e+00
%75 = zext i1 %74 to i64
%76 = select i1 %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%77 = load i32, i32* %8
%78 = load i32, i32* %8
%79 = sub nsw i32 %78, 1
%80 = icmp ne i32 %79, 0
%81 = zext i1 %80 to i64
%82 = select i1 %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%83 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %69, i64 %71, i8* %76, i32 %77, i8* %82)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [9 x i8] c"%Y-%m-%d\00"
@.str.1 = [22 x i8] c"Your date is invalid!\00"
@.str.2 = [57 x i8] c"You managed to be born this very second. Happy birthday!\00"
@.str.3 = [42 x i8] c"%s ca. %ld second%s, that is, %d year%s.\0A\00"
@.str.4 = [12 x i8] c"Your age is\00"
@.str.5 = [18 x i8] c"You'll be born in\00"
@.str.6 = [2 x i8] c"s\00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.tm
%4 = bitcast %struct.tm* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %20, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @print_help(i8* %7)
%9 = icmp sgt i32 %0, 2
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 104
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %6, %10
%18 = phi i32 [ %16, %10 ], [ 1, %6 ]
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call signext i8 @strptime(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.tm* %3)
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i8*, i8** %1
%27 = call i32 @print_help(i8* %26)
%28 = call i32 @putchar(i8 signext 10)
%29 = call i32 @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %25, %20
%31 = call double @time(i32* null)
%32 = call double @mktime(%struct.tm* %3)
%33 = fsub double %31, %32
%34 = call double @labs(double %33)
%35 = fdiv double %34, 3.155760e+07
%36 = fptosi double %35 to i32
%37 = call i32 @llvm.abs.i32(i32 %36, i1 true)
%38 = fcmp une double %34, 0.000000e+00
br i1 %38, label %42, label %39
39: ; preds = %30
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %30
%43 = fcmp ogt double %33, 0.000000e+00
%44 = select i1 %43, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0)
%45 = fptosi double %34 to i64
%46 = fadd double %34, -1.000000e+00
%47 = fcmp une double %46, 0.000000e+00
%48 = select i1 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
%49 = icmp eq i32 %37, 1
%50 = select i1 %49, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%51 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %44, i64 %45, i8* %48, i32 %37, i8* %50)
ret i32 0
}