#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 */
long Jul(long);
int /*<<< orphan*/ strcpy(char *, char *);
char *Dyofwk(long d, char *s) {
  int i;
  char *p;
  if (d <= 0L)
    if (s) {
      *s = '\0';
      return (s);
    } else
      return ("");
  i = Jul(d) % 7L;
  switch (i) {
  case 0:
    p = "Sunday";
    break;
  case 1:
    p = "Monday";
    break;
  case 2:
    p = "Tuesday";
    break;
  case 3:
    p = "Wednesday";
    break;
  case 4:
    p = "Thursday";
    break;
  case 5:
    p = "Friday";
    break;
  case 6:
    p = "Saturday";
    break;
  default:
    p = "";
    break;
  }
  if (s) {
    strcpy(s, p);
    return (s);
  } else
    return (p);
}


x86 assembly (clang, -O0):
<Dyofwk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jg     116a <Dyofwk+0x4a>
cmpq   $0x0,-0x18(%rbp)
je     115a <Dyofwk+0x3a>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <Dyofwk+0x150>
lea    0xeea(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <Dyofwk+0x150>
mov    -0x10(%rbp),%rdi
call   1030 <Jul@plt>
mov    %rax,-0x38(%rbp)
movabs $0x4924924924924925,%rcx
92 24 49
imul   %rcx
mov    -0x38(%rbp),%rax
mov    %rdx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    %rcx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x3,%edx
sub    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x6,%rax
ja     1238 <Dyofwk+0x118>
mov    -0x30(%rbp),%rax
lea    0xe41(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe4d(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <Dyofwk+0x123>
lea    0xe44(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <Dyofwk+0x123>
lea    0xe3b(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <Dyofwk+0x123>
lea    0xe33(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <Dyofwk+0x123>
lea    0xe2d(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <Dyofwk+0x123>
lea    0xe26(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <Dyofwk+0x123>
lea    0xe1d(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1243 <Dyofwk+0x123>
lea    0xe0c(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1268 <Dyofwk+0x148>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <Dyofwk+0x150>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Dyofwk>:
push   %rbx
mov    %rsi,%rbx
test   %rdi,%rdi
jle    117b <Dyofwk+0x5b>
call   1030 <Jul@plt>
mov    %rax,%rcx
movabs $0x4924924924924925,%rdx
92 24 49
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    %rdx
add    %rax,%rdx
lea    0x0(,%rdx,8),%rax
sub    %rax,%rdx
add    %rcx,%rdx
cmp    $0x6,%edx
ja     1185 <Dyofwk+0x65>
lea    0xed7(%rip),%rax
movslq (%rax,%rdx,4),%rsi
add    %rax,%rsi
test   %rbx,%rbx
je     1191 <Dyofwk+0x71>
mov    %rbx,%rdi
call   1040 <strcpy@plt>
jmp    119d <Dyofwk+0x7d>
test   %rbx,%rbx
je     1196 <Dyofwk+0x76>
movb   $0x0,(%rbx)
jmp    119d <Dyofwk+0x7d>
lea    0xea3(%rip),%rsi
test   %rbx,%rbx
jne    1171 <Dyofwk+0x51>
mov    %rsi,%rbx
jmp    119d <Dyofwk+0x7d>
lea    0xe92(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"Sunday\00"
@.str.2 = [7 x i8] c"Monday\00"
@.str.3 = [8 x i8] c"Tuesday\00"
@.str.4 = [10 x i8] c"Wednesday\00"
@.str.5 = [9 x i8] c"Thursday\00"
@.str.6 = [7 x i8] c"Friday\00"
@.str.7 = [9 x i8] c"Saturday\00"
define i8* @Dyofwk(i64 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i64 %0, i64* %4
store i8* %1, i8** %5
%8 = load i64, i64* %4
%9 = icmp sle i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i8*, i8** %5
store i8 0, i8* %14
%15 = load i8*, i8** %5
store i8* %15, i8** %3
br label %41
16: ; preds = %10
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %41
17: ; preds = %2
%18 = load i64, i64* %4
%19 = call i64 @Jul(i64 %18)
%20 = srem i64 %19, 7
%21 = trunc i64 %20 to i32
store i32 %21, i32* %6
%22 = load i32, i32* %6
switch i32 %22, label %30 [
i32 0, label %23
i32 1, label %24
i32 2, label %25
i32 3, label %26
i32 4, label %27
i32 5, label %28
i32 6, label %29
]
23: ; preds = %17
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %31
24: ; preds = %17
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %31
25: ; preds = %17
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %31
26: ; preds = %17
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %31
27: ; preds = %17
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %31
28: ; preds = %17
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %31
29: ; preds = %17
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %31
30: ; preds = %17
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
br label %31
31: ; preds = %30, %29, %28, %27, %26, %25, %24, %23
%32 = load i8*, i8** %5
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i8*, i8** %5
%36 = load i8*, i8** %7
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = load i8*, i8** %5
store i8* %38, i8** %3
br label %41
39: ; preds = %31
%40 = load i8*, i8** %7
store i8* %40, i8** %3
br label %41
41: ; preds = %39, %34, %16, %13
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"Sunday\00"
@.str.2 = [7 x i8] c"Monday\00"
@.str.3 = [8 x i8] c"Tuesday\00"
@.str.4 = [10 x i8] c"Wednesday\00"
@.str.5 = [9 x i8] c"Thursday\00"
@.str.6 = [7 x i8] c"Friday\00"
@.str.7 = [9 x i8] c"Saturday\00"
@reltable.Dyofwk = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.Dyofwk to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.Dyofwk to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.Dyofwk to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.Dyofwk to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.Dyofwk to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.Dyofwk to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.7 to i64), i64 ptrtoint ([7 x i32]* @reltable.Dyofwk to i64)) to i32)]
define i8* @Dyofwk(i64 %0, i8* %1) {
%3 = icmp slt i64 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = icmp eq i8* %1, null
br i1 %5, label %20, label %6
6: ; preds = %4
store i8 0, i8* %1
br label %20
7: ; preds = %2
%8 = tail call i64 @Jul(i64 %0)
%9 = srem i64 %8, 7
%10 = trunc i64 %9 to i32
%11 = icmp ult i32 %10, 7
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = shl i64 %9, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.Dyofwk to i8*), i64 %13)
br label %15
15: ; preds = %7, %12
%16 = phi i8* [ %14, %12 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %7 ]
%17 = icmp eq i8* %1, null
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @strcpy(i8* %1, i8* %16)
br label %20
20: ; preds = %15, %4, %18, %6
%21 = phi i8* [ %1, %6 ], [ %1, %18 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %4 ], [ %16, %15 ]
ret i8* %21
}