#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 */
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ errno;
int tm_getisoyear(struct tm);
scalar_t__ tm_getrepresentation(struct tm);
int tm_diffisoyears(struct tm debut, struct tm fin) {
  if (tm_getrepresentation(debut) != tm_getrepresentation(fin)) {
    errno = EINVAL;
    return 0;
  }
  return tm_getisoyear(fin) - tm_getisoyear(debut);
}


x86 assembly (clang, -O0):
<tm_diffisoyears>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <tm_getrepresentation@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <tm_getrepresentation@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
je     1170 <tm_diffisoyears+0x50>
mov    0x2e7f(%rip),%rax
mov    (%rax),%ecx
mov    0x2e7e(%rip),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    118d <tm_diffisoyears+0x6d>
mov    -0x10(%rbp),%edi
call   1040 <tm_getisoyear@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <tm_getisoyear@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tm_diffisoyears>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
call   1030 <tm_getrepresentation@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1030 <tm_getrepresentation@plt>
cmp    %rax,%rbx
jne    1152 <tm_diffisoyears+0x32>
mov    %ebp,%edi
call   1040 <tm_getisoyear@plt>
mov    %eax,%ebp
mov    %r14d,%edi
call   1040 <tm_getisoyear@plt>
sub    %eax,%ebp
jmp    1166 <tm_diffisoyears+0x46>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    0x2e7e(%rip),%rcx
mov    %eax,(%rcx)
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@EINVAL = global i32 0
@errno = global i32 0
define i32 @tm_diffisoyears(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.tm
%5 = alloca %struct.tm
%6 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 %0, i32* %6
%7 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
store i32 %1, i32* %7
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i64 @tm_getrepresentation(i32 %9)
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i64 @tm_getrepresentation(i32 %12)
%14 = icmp ne i64 %10, %13
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* @EINVAL
store i32 %16, i32* @errno
store i32 0, i32* %3
br label %25
17: ; preds = %2
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @tm_getisoyear(i32 %19)
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
%22 = load i32, i32* %21
%23 = call i32 @tm_getisoyear(i32 %22)
%24 = sub nsw i32 %20, %23
store i32 %24, i32* %3
br label %25
25: ; preds = %17, %15
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
define i32 @tm_diffisoyears(i32 %0, i32 %1) {
%3 = tail call i64 @tm_getrepresentation(i32 %0)
%4 = tail call i64 @tm_getrepresentation(i32 %1)
%5 = icmp eq i64 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = load i32, i32* @EINVAL
store i32 %7, i32* @errno
br label %12
8: ; preds = %2
%9 = tail call i32 @tm_getisoyear(i32 %1)
%10 = tail call i32 @tm_getisoyear(i32 %0)
%11 = sub nsw i32 %9, %10
br label %12
12: ; preds = %8, %6
%13 = phi i32 [ 0, %6 ], [ %11, %8 ]
ret i32 %13
}