#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 */

/* Variables and functions */
int dst_dayofweek(double);
double dst_encodedate(int, int, int);
int dst_correction(int year, int month, int day) {
  double d;
  int apr_s, oct_s;
  if ((month < 4) || (month > 9))
    return 0;
  if ((month > 4) && (month < 9))
    return 1;
  if (month == 4) {
    apr_s = 0;
    do {
      apr_s++;
      d = dst_encodedate(year, 4, apr_s);
    } while (dst_dayofweek(d) > 1);
    if (day >= apr_s)
      return 1;
    return 0;
  }
  if (month == 9) {
    oct_s = 32;
    do {
      oct_s--;
      d = dst_encodedate(year, 10, oct_s);
    } while (dst_dayofweek(d) > 1);
    if (day >= oct_s)
      return 0;
    return 1;
  }
}


x86 assembly (clang, -O0):
<dst_correction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x4,-0xc(%rbp)
jl     1145 <dst_correction+0x25>
cmpl   $0x9,-0xc(%rbp)
jle    1151 <dst_correction+0x31>
movl   $0x0,-0x4(%rbp)
jmp    1238 <dst_correction+0x118>
cmpl   $0x4,-0xc(%rbp)
jle    1171 <dst_correction+0x51>
cmpl   $0x9,-0xc(%rbp)
jge    1171 <dst_correction+0x51>
movl   $0x1,-0x4(%rbp)
jmp    1238 <dst_correction+0x118>
cmpl   $0x4,-0xc(%rbp)
jne    11d7 <dst_correction+0xb7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x1c(%rbp),%edx
mov    $0x4,%esi
call   1030 <dst_encodedate@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <dst_dayofweek@plt>
cmp    $0x1,%eax
jg     1182 <dst_correction+0x62>
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11cb <dst_correction+0xab>
movl   $0x1,-0x4(%rbp)
jmp    1238 <dst_correction+0x118>
movl   $0x0,-0x4(%rbp)
jmp    1238 <dst_correction+0x118>
cmpl   $0x9,-0xc(%rbp)
jne    1238 <dst_correction+0x118>
movl   $0x20,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%edx
mov    $0xa,%esi
call   1030 <dst_encodedate@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <dst_dayofweek@plt>
cmp    $0x1,%eax
jg     11e8 <dst_correction+0xc8>
mov    -0x10(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     1231 <dst_correction+0x111>
movl   $0x0,-0x4(%rbp)
jmp    1238 <dst_correction+0x118>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dst_correction>:
push   %rbp
push   %r14
push   %rbx
lea    -0xa(%rsi),%ecx
xor    %eax,%eax
cmp    $0xfffffffa,%ecx
jb     11a4 <dst_correction+0x84>
lea    -0x5(%rsi),%ecx
mov    $0x1,%eax
cmp    $0x4,%ecx
jb     11a4 <dst_correction+0x84>
mov    %edx,%r14d
mov    %edi,%ebp
cmp    $0x4,%esi
je     1175 <dst_correction+0x55>
cmp    $0x9,%esi
jne    11a4 <dst_correction+0x84>
mov    $0x20,%ebx
nop
add    $0xffffffff,%ebx
mov    %ebp,%edi
mov    $0xa,%esi
mov    %ebx,%edx
call   1030 <dst_encodedate@plt>
call   1040 <dst_dayofweek@plt>
cmp    $0x1,%eax
jg     1150 <dst_correction+0x30>
xor    %eax,%eax
cmp    %r14d,%ebx
setg   %al
jmp    11a4 <dst_correction+0x84>
mov    $0xffffffff,%ebx
nopw   0x0(%rax,%rax,1)
lea    0x2(%rbx),%edx
mov    %ebp,%edi
mov    $0x4,%esi
call   1030 <dst_encodedate@plt>
call   1040 <dst_dayofweek@plt>
add    $0x1,%ebx
cmp    $0x1,%eax
jg     1180 <dst_correction+0x60>
xor    %eax,%eax
cmp    %r14d,%ebx
setl   %al
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @dst_correction(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 4
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, 9
br i1 %15, label %16, label %17
16: ; preds = %13, %3
store i32 0, i32* %4
br label %64
17: ; preds = %13
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, 4
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 9
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 1, i32* %4
br label %64
24: ; preds = %20, %17
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 4
br i1 %26, label %27, label %44
27: ; preds = %24
store i32 0, i32* %9
br label %28
28: ; preds = %34, %27
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
store i32 %30, i32* %9
%31 = load i32, i32* %5
%32 = load i32, i32* %9
%33 = call double @dst_encodedate(i32 %31, i32 4, i32 %32)
store double %33, double* %8
br label %34
34: ; preds = %28
%35 = load double, double* %8
%36 = call i32 @dst_dayofweek(double %35)
%37 = icmp sgt i32 %36, 1
br i1 %37, label %28, label %38
38: ; preds = %34
%39 = load i32, i32* %7
%40 = load i32, i32* %9
%41 = icmp sge i32 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 1, i32* %4
br label %64
43: ; preds = %38
store i32 0, i32* %4
br label %64
44: ; preds = %24
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, 9
br i1 %46, label %47, label %64
47: ; preds = %44
store i32 32, i32* %10
br label %48
48: ; preds = %54, %47
%49 = load i32, i32* %10
%50 = add nsw i32 %49, -1
store i32 %50, i32* %10
%51 = load i32, i32* %5
%52 = load i32, i32* %10
%53 = call double @dst_encodedate(i32 %51, i32 10, i32 %52)
store double %53, double* %8
br label %54
54: ; preds = %48
%55 = load double, double* %8
%56 = call i32 @dst_dayofweek(double %55)
%57 = icmp sgt i32 %56, 1
br i1 %57, label %48, label %58
58: ; preds = %54
%59 = load i32, i32* %7
%60 = load i32, i32* %10
%61 = icmp sge i32 %59, %60
br i1 %61, label %62, label %63
62: ; preds = %58
store i32 0, i32* %4
br label %64
63: ; preds = %58
store i32 1, i32* %4
br label %64
64: ; preds = %16, %23, %42, %43, %62, %63, %44
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
define i32 @dst_correction(i32 %0, i32 %1, i32 %2) {
%4 = add i32 %1, -10
%5 = icmp ult i32 %4, -6
br i1 %5, label %28, label %6
6: ; preds = %3
%7 = add nsw i32 %1, -5
%8 = icmp ult i32 %7, 4
br i1 %8, label %28, label %9
9: ; preds = %6
switch i32 %1, label %28 [
i32 4, label %10
i32 9, label %19
]
10: ; preds = %9, %10
%11 = phi i32 [ %12, %10 ], [ 0, %9 ]
%12 = add nuw nsw i32 %11, 1
%13 = tail call double @dst_encodedate(i32 %0, i32 4, i32 %12)
%14 = tail call i32 @dst_dayofweek(double %13)
%15 = icmp sgt i32 %14, 1
br i1 %15, label %10, label %16
16: ; preds = %10
%17 = icmp slt i32 %11, %2
%18 = zext i1 %17 to i32
br label %28
19: ; preds = %9, %19
%20 = phi i32 [ %21, %19 ], [ 32, %9 ]
%21 = add nsw i32 %20, -1
%22 = tail call double @dst_encodedate(i32 %0, i32 10, i32 %21)
%23 = tail call i32 @dst_dayofweek(double %22)
%24 = icmp sgt i32 %23, 1
br i1 %24, label %19, label %25
25: ; preds = %19
%26 = icmp sgt i32 %21, %2
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %9, %25, %16, %6, %3
%29 = phi i32 [ 0, %3 ], [ 1, %6 ], [ %18, %16 ], [ %27, %25 ], [ undef, %9 ]
ret i32 %29
}