#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 _glp_lib_jday(int, int, int);
int /*<<< orphan*/ glp_assert_(char *, char *, int);
int weekday(int);
int firstday(int year) {
  int j;
  j = _glp_lib_jday(1, 1, year) - _glp_lib_jday(1, 1, 1970);
  switch (weekday(j)) {
  case 1:
    j += 0;
    break;
  case 2:
    j -= 1;
    break;
  case 3:
    j -= 2;
    break;
  case 4:
    j -= 3;
    break;
  case 5:
    j += 3;
    break;
  case 6:
    j += 2;
    break;
  case 7:
    j += 1;
    break;
  default:
    ((void)((j != j) ||
            (glp_assert_(
                 "j != j",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/Erez-Buchnik/Bouma2/refs/"
                 "heads/master/dep/glpk/glpmpl05.c",
                 314),
             1)));
  }
  ((void)((weekday(j) == 1) ||
          (glp_assert_(
               "weekday(j) == 1",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/Erez-Buchnik/Bouma2/refs/"
               "heads/master/dep/glpk/glpmpl05.c",
               317),
           1)));
  return j;
}


x86 assembly (clang, -O0):
<firstday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x1,%esi
mov    %esi,-0x18(%rbp)
mov    %esi,%edi
call   1040 <_glp_lib_jday@plt>
mov    -0x18(%rbp),%esi
mov    %eax,-0x14(%rbp)
mov    $0x7b2,%edx
mov    %esi,%edi
call   1040 <_glp_lib_jday@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <weekday@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11f9 <firstday+0xc9>
mov    -0x10(%rbp),%rax
lea    0xe72(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0x8(%rbp)
jmp    122a <firstday+0xfa>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    122a <firstday+0xfa>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    122a <firstday+0xfa>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x8(%rbp)
jmp    122a <firstday+0xfa>
mov    -0x8(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x8(%rbp)
jmp    122a <firstday+0xfa>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    122a <firstday+0xfa>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    122a <firstday+0xfa>
mov    -0x8(%rbp),%ecx
mov    $0x1,%al
cmp    -0x8(%rbp),%ecx
mov    %al,-0x19(%rbp)
jne    1227 <firstday+0xf7>
lea    0xe0b(%rip),%rdi
lea    0xe0b(%rip),%rsi
mov    $0x13a,%edx
call   1050 <glp_assert_@plt>
mov    $0x1,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%edi
call   1030 <weekday@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x1,%ecx
mov    %al,-0x1a(%rbp)
je     125f <firstday+0x12f>
lea    0xe6e(%rip),%rdi
lea    0xdd3(%rip),%rsi
mov    $0x13d,%edx
call   1050 <glp_assert_@plt>
mov    $0x1,%al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<firstday>:
push   %rbx
mov    %edi,%edx
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <_glp_lib_jday@plt>
mov    %eax,%ebx
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x7b2,%edx
call   1040 <_glp_lib_jday@plt>
sub    %eax,%ebx
mov    %ebx,%edi
call   1030 <weekday@plt>
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     117e <firstday+0x4e>
lea    0xe90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0xffffffff,%ebx
jmp    11af <firstday+0x7f>
lea    0xe97(%rip),%rdi
lea    0xe97(%rip),%rsi
mov    $0x13a,%edx
call   1050 <glp_assert_@plt>
jmp    11af <firstday+0x7f>
add    $0xfffffffe,%ebx
jmp    11af <firstday+0x7f>
add    $0xfffffffd,%ebx
jmp    11af <firstday+0x7f>
add    $0x3,%ebx
jmp    11af <firstday+0x7f>
add    $0x2,%ebx
jmp    11af <firstday+0x7f>
add    $0x1,%ebx
mov    %ebx,%edi
call   1030 <weekday@plt>
cmp    $0x1,%eax
je     11d3 <firstday+0xa3>
lea    0xef5(%rip),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x13d,%edx
call   1050 <glp_assert_@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"j != j\00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Erez-Buchnik/Bouma2/refs/heads/master/dep/glpk/glpmpl05.c\00"
@.str.2 = [16 x i8] c"weekday(j) == 1\00"
define i32 @firstday(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @_glp_lib_jday(i32 1, i32 1, i32 %4)
%6 = call i32 @_glp_lib_jday(i32 1, i32 1, i32 1970)
%7 = sub nsw i32 %5, %6
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = call i32 @weekday(i32 %8)
switch i32 %9, label %31 [
i32 1, label %10
i32 2, label %13
i32 3, label %16
i32 4, label %19
i32 5, label %22
i32 6, label %25
i32 7, label %28
]
10: ; preds = %1
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 0
store i32 %12, i32* %3
br label %40
13: ; preds = %1
%14 = load i32, i32* %3
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %3
br label %40
16: ; preds = %1
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 2
store i32 %18, i32* %3
br label %40
19: ; preds = %1
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 3
store i32 %21, i32* %3
br label %40
22: ; preds = %1
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 3
store i32 %24, i32* %3
br label %40
25: ; preds = %1
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 2
store i32 %27, i32* %3
br label %40
28: ; preds = %1
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %40
31: ; preds = %1
%32 = load i32, i32* %3
%33 = load i32, i32* %3
%34 = icmp ne i32 %32, %33
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 @glp_assert_(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 314)
br label %37
37: ; preds = %35, %31
%38 = phi i1 [ true, %31 ], [ true, %35 ]
%39 = zext i1 %38 to i32
br label %40
40: ; preds = %37, %28, %25, %22, %19, %16, %13, %10
%41 = load i32, i32* %3
%42 = call i32 @weekday(i32 %41)
%43 = icmp eq i32 %42, 1
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = call i32 @glp_assert_(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 317)
br label %46
46: ; preds = %44, %40
%47 = phi i1 [ true, %40 ], [ true, %44 ]
%48 = zext i1 %47 to i32
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [7 x i8] c"j != j\00"
@.str.1 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Erez-Buchnik/Bouma2/refs/heads/master/dep/glpk/glpmpl05.c\00"
@.str.2 = [16 x i8] c"weekday(j) == 1\00"
define i32 @firstday(i32 %0) {
%2 = tail call i32 @_glp_lib_jday(i32 1, i32 1, i32 %0)
%3 = tail call i32 @_glp_lib_jday(i32 1, i32 1, i32 1970)
%4 = sub nsw i32 %2, %3
%5 = tail call i32 @weekday(i32 %4)
switch i32 %5, label %18 [
i32 1, label %20
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
i32 6, label %14
i32 7, label %16
]
6: ; preds = %1
%7 = add nsw i32 %4, -1
br label %20
8: ; preds = %1
%9 = add nsw i32 %4, -2
br label %20
10: ; preds = %1
%11 = add nsw i32 %4, -3
br label %20
12: ; preds = %1
%13 = add nsw i32 %4, 3
br label %20
14: ; preds = %1
%15 = add nsw i32 %4, 2
br label %20
16: ; preds = %1
%17 = add nsw i32 %4, 1
br label %20
18: ; preds = %1
%19 = tail call i32 @glp_assert_(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 314)
br label %20
20: ; preds = %1, %18, %16, %14, %12, %10, %8, %6
%21 = phi i32 [ %4, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %4, %1 ]
%22 = tail call i32 @weekday(i32 %21)
%23 = icmp eq i32 %22, 1
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = tail call i32 @glp_assert_(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.1, i64 0, i64 0), i32 317)
br label %26
26: ; preds = %24, %20
ret i32 %21
}