#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 time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int timegm(struct tm *);
time_t euro_dst_end(int year) {
  struct tm tm;
  int dst_end_date;
  memset(&tm, 0, sizeof(struct tm));
  tm.tm_year = year - 1900;
  tm.tm_mon = 9;
  tm.tm_mday = (31 - (5 * year / 4 + 1) % 7);
  tm.tm_hour = 1;
  dst_end_date = timegm(&tm);
  return dst_end_date;
}


x86 assembly (clang, -O0):
<euro_dst_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    -0x4(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x18(%rbp)
movl   $0x9,-0x14(%rbp)
imul   $0x5,-0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    $0x1f,%eax
sub    %edx,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <timegm@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euro_dst_end>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
lea    -0x76c(%rbx),%eax
mov    %eax,0x8(%rsp)
lea    (%rbx,%rbx,4),%eax
lea    (%rbx,%rbx,4),%ecx
add    $0x3,%ecx
test   %eax,%eax
cmovns %eax,%ecx
movl   $0x9,0xc(%rsp)
sar    $0x2,%ecx
mov    %ecx,%eax
add    $0x1,%eax
cltq
imul   $0xffffffff92492493,%rax,%rdx
shr    $0x20,%rdx
add    %edx,%ecx
add    $0x1,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %ecx,%edx
sub    %eax,%edx
add    $0x1f,%edx
mov    %edx,0x10(%rsp)
movl   $0x1,0x14(%rsp)
mov    %r14,%rdi
call   1040 <timegm@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32 }
define i32 @euro_dst_end(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @memset(%struct.tm* %3, i32 0, i32 16)
%6 = load i32, i32* %2
%7 = sub nsw i32 %6, 1900
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
store i32 %7, i32* %8
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
store i32 9, i32* %9
%10 = load i32, i32* %2
%11 = mul nsw i32 5, %10
%12 = sdiv i32 %11, 4
%13 = add nsw i32 %12, 1
%14 = srem i32 %13, 7
%15 = sub nsw i32 31, %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 3
store i32 1, i32* %17
%18 = call i32 @timegm(%struct.tm* %3)
store i32 %18, i32* %4
%19 = load i32, i32* %4
ret i32 %19
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32 }
define i32 @euro_dst_end(i32 %0) {
%2 = alloca %struct.tm
%3 = bitcast %struct.tm* %2 to i8*
%4 = call i32 @memset(%struct.tm* %2, i32 0, i32 16)
%5 = add nsw i32 %0, -1900
%6 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
store i32 %5, i32* %6
%7 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
store i32 9, i32* %7
%8 = mul nsw i32 %0, 5
%9 = sdiv i32 %8, 4
%10 = add nsw i32 %9, 1
%11 = srem i32 %10, 7
%12 = sub nsw i32 31, %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
store i32 1, i32* %14
%15 = call i32 @timegm(%struct.tm* %2)
ret i32 %15
}