#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 */
scalar_t__ strcasecmp(char *, char *);
int day_number(char *day) {
  if (!day) {
    return -1;
  }
  if (strcasecmp(day, "sun") == 0) {
    return 0;
  }
  if (strcasecmp(day, "mon") == 0) {
    return 1;
  }
  if (strcasecmp(day, "tue") == 0) {
    return 2;
  }
  if (strcasecmp(day, "wed") == 0) {
    return 3;
  }
  if (strcasecmp(day, "thu") == 0) {
    return 4;
  }
  if (strcasecmp(day, "fri") == 0) {
    return 5;
  }
  if (strcasecmp(day, "sat") == 0) {
    return 6;
  }
  return -1;
}


x86 assembly (clang, -O0):
<day_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <day_number+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    1244 <day_number+0x134>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1159 <day_number+0x49>
movl   $0x0,-0x4(%rbp)
jmp    1244 <day_number+0x134>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    117f <day_number+0x6f>
movl   $0x1,-0x4(%rbp)
jmp    1244 <day_number+0x134>
mov    -0x10(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11a5 <day_number+0x95>
movl   $0x2,-0x4(%rbp)
jmp    1244 <day_number+0x134>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11cb <day_number+0xbb>
movl   $0x3,-0x4(%rbp)
jmp    1244 <day_number+0x134>
mov    -0x10(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11f1 <day_number+0xe1>
movl   $0x4,-0x4(%rbp)
jmp    1244 <day_number+0x134>
mov    -0x10(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1217 <day_number+0x107>
movl   $0x5,-0x4(%rbp)
jmp    1244 <day_number+0x134>
mov    -0x10(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    123d <day_number+0x12d>
movl   $0x6,-0x4(%rbp)
jmp    1244 <day_number+0x134>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<day_number>:
push   %rbx
test   %rdi,%rdi
je     11af <day_number+0x9f>
mov    %rdi,%rbx
lea    0xedc(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11b6 <day_number+0xa6>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ba <day_number+0xaa>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11c1 <day_number+0xb1>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11c8 <day_number+0xb8>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11cf <day_number+0xbf>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11d6 <day_number+0xc6>
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %rax
sbb    %eax,%eax
or     $0x6,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"sun\00"
@.str.1 = [4 x i8] c"mon\00"
@.str.2 = [4 x i8] c"tue\00"
@.str.3 = [4 x i8] c"wed\00"
@.str.4 = [4 x i8] c"thu\00"
@.str.5 = [4 x i8] c"fri\00"
@.str.6 = [4 x i8] c"sat\00"
define i32 @day_number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %1
store i32 -1, i32* %2
br label %43
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %2
br label %43
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 1, i32* %2
br label %43
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i64 @strcasecmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 2, i32* %2
br label %43
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 3, i32* %2
br label %43
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = call i64 @strcasecmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 4, i32* %2
br label %43
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = call i64 @strcasecmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 5, i32* %2
br label %43
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i64 @strcasecmp(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 6, i32* %2
br label %43
42: ; preds = %37
store i32 -1, i32* %2
br label %43
43: ; preds = %42, %41, %36, %31, %26, %21, %16, %11, %6
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@.str = [4 x i8] c"sun\00"
@.str.1 = [4 x i8] c"mon\00"
@.str.2 = [4 x i8] c"tue\00"
@.str.3 = [4 x i8] c"wed\00"
@.str.4 = [4 x i8] c"thu\00"
@.str.5 = [4 x i8] c"fri\00"
@.str.6 = [4 x i8] c"sat\00"
define i32 @day_number(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %25, label %3
3: ; preds = %1
%4 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %6
%10 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %9
%13 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %12
%16 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i32 6, i32 -1
br label %25
25: ; preds = %21, %18, %15, %12, %9, %6, %3, %1
%26 = phi i32 [ -1, %1 ], [ 0, %3 ], [ 1, %6 ], [ 2, %9 ], [ 3, %12 ], [ 4, %15 ], [ 5, %18 ], [ %24, %21 ]
ret i32 %26
}