#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 jours_mois(int, int);
char *nom_jour(int an, int mois, int jour) {
  int jours_an = (an - 1901) * 365 + (an - 1901) / 4;
  int indice = (jours_an + jours_mois(mois, an) + jour - 1) % 7;
  switch (indice) {
  case 0:
    return "mardi";
  case 1:
    return "mercredi";
  case 2:
    return "jeudi";
  case 3:
    return "vendredi";
  case 4:
    return "samedi";
  case 5:
    return "dimanche";
  default:
    return "lundi";
  }
}


x86 assembly (clang, -O0):
<nom_jour>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%edx
mov    %edx,%ecx
add    $0xfffff893,%ecx
imul   $0x16d,%ecx,%eax
add    $0xfffff896,%edx
test   %ecx,%ecx
cmovs  %edx,%ecx
sar    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <jours_mois@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    -0x14(%rbp),%esi
mov    %eax,%edx
add    %esi,%edx
mov    %eax,%ecx
mov    %esi,%eax
lea    -0x1(%rax,%rcx,1),%eax
cltq
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
mov    %eax,%ecx
mov    %ecx,%eax
mov    %edx,%ecx
lea    -0x1(%rax,%rcx,1),%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x2,%edx
add    %eax,%edx
mov    %edx,%eax
shl    $0x3,%eax
sub    %eax,%edx
mov    %edx,%eax
lea    -0x1(%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x5,%rax
ja     1222 <nom_jour+0x112>
mov    -0x28(%rbp),%rax
lea    0xe47(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <nom_jour+0x11d>
lea    0xe45(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <nom_jour+0x11d>
lea    0xe3e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <nom_jour+0x11d>
lea    0xe34(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <nom_jour+0x11d>
lea    0xe2d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <nom_jour+0x11d>
lea    0xe24(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <nom_jour+0x11d>
lea    0xe1d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nom_jour>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %edi,%eax
lea    -0x76d(%rax),%ecx
imul   $0x16d,%ecx,%edx
lea    -0x76a(%rax),%ebx
test   %ecx,%ecx
cmovns %ecx,%ebx
sar    $0x2,%ebx
add    %edx,%ebx
mov    %esi,%edi
mov    %eax,%esi
call   1030 <jours_mois@plt>
add    %ebp,%ebx
mov    %ebx,%ecx
add    %eax,%ecx
add    %ebx,%eax
add    $0xffffffff,%eax
cltq
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
add    %ecx,%eax
add    $0xffffffff,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x2,%eax
add    %edx,%eax
lea    0x0(,%rax,8),%edx
sub    %edx,%eax
add    %ecx,%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     1188 <nom_jour+0x78>
cltq
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    118f <nom_jour+0x7f>
lea    0xe9f(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"mardi\00"
@.str.1 = [9 x i8] c"mercredi\00"
@.str.2 = [6 x i8] c"jeudi\00"
@.str.3 = [9 x i8] c"vendredi\00"
@.str.4 = [7 x i8] c"samedi\00"
@.str.5 = [9 x i8] c"dimanche\00"
@.str.6 = [6 x i8] c"lundi\00"
define i8* @nom_jour(i32 %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 1901
%12 = mul nsw i32 %11, 365
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, 1901
%15 = sdiv i32 %14, 4
%16 = add nsw i32 %12, %15
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = call i32 @jours_mois(i32 %18, i32 %19)
%21 = add nsw i32 %17, %20
%22 = load i32, i32* %7
%23 = add nsw i32 %21, %22
%24 = sub nsw i32 %23, 1
%25 = srem i32 %24, 7
store i32 %25, i32* %9
%26 = load i32, i32* %9
switch i32 %26, label %33 [
i32 0, label %27
i32 1, label %28
i32 2, label %29
i32 3, label %30
i32 4, label %31
i32 5, label %32
]
27: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
br label %34
28: ; preds = %3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %34
29: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %34
30: ; preds = %3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %34
31: ; preds = %3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %4
br label %34
32: ; preds = %3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %4
br label %34
33: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8** %4
br label %34
34: ; preds = %33, %32, %31, %30, %29, %28, %27
%35 = load i8*, i8** %4
ret i8* %35
}

LLVM IR (-O2):
@.str = [6 x i8] c"mardi\00"
@.str.1 = [9 x i8] c"mercredi\00"
@.str.2 = [6 x i8] c"jeudi\00"
@.str.3 = [9 x i8] c"vendredi\00"
@.str.4 = [7 x i8] c"samedi\00"
@.str.5 = [9 x i8] c"dimanche\00"
@.str.6 = [6 x i8] c"lundi\00"
@reltable.nom_jour = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.nom_jour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.nom_jour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.nom_jour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.nom_jour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.nom_jour to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.nom_jour to i64)) to i32)]
define i8* @nom_jour(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %0, -1901
%5 = mul nsw i32 %4, 365
%6 = sdiv i32 %4, 4
%7 = tail call i32 @jours_mois(i32 %1, i32 %0)
%8 = add nsw i32 %6, -1
%9 = add i32 %8, %5
%10 = add i32 %9, %2
%11 = add i32 %10, %7
%12 = srem i32 %11, 7
%13 = icmp ult i32 %12, 6
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = sext i32 %12 to i64
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.nom_jour to i8*), i64 %16)
br label %18
18: ; preds = %3, %14
%19 = phi i8* [ %17, %14 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %3 ]
ret i8* %19
}