#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int whichtoe(char foot) {
  char footname[5];
  char toe;
  short int whichtoe;
  if (foot == 'l') {
    strcpy(footname, "left");
    do {
      printf("\nwhich toenail?\n");
      printf("[a,b,c,d,e]: ");
      scanf(" %c", &toe);
      switch (toe) {
      case 'a':
        whichtoe = 1;
        break;
      case 'b':
        whichtoe = 2;
        break;
      case 'c':
        whichtoe = 3;
        break;
      case 'd':
        whichtoe = 4;
        break;
      case 'e':
        whichtoe = 5;
        break;
      default:
        whichtoe = 0;
        break;
      }
    } while ((whichtoe < 1) || (whichtoe > 5));
  }
  if (foot == 'r') {
    strcpy(footname, "right");
    do {
      printf("\nwhich toenail?\n");
      printf("[e,d,c,b,a]: ");
      scanf(" %c", &toe);
      switch (toe) {
      case 'e':
        whichtoe = 1;
        break;
      case 'd':
        whichtoe = 2;
        break;
      case 'c':
        whichtoe = 3;
        break;
      case 'b':
        whichtoe = 4;
        break;
      case 'a':
        whichtoe = 5;
        break;
      default:
        whichtoe = 0;
        break;
      }
    } while ((whichtoe < 1) || (whichtoe > 5));
  }
  return (whichtoe);
}


x86 assembly (clang, -O0):
<whichtoe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x6c,%eax
jne    121e <whichtoe+0xee>
lea    -0x6(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x7(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     11e4 <whichtoe+0xb4>
mov    -0x18(%rbp),%rax
lea    0xe5c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movw   $0x1,-0xa(%rbp)
jmp    11ea <whichtoe+0xba>
movw   $0x2,-0xa(%rbp)
jmp    11ea <whichtoe+0xba>
movw   $0x3,-0xa(%rbp)
jmp    11ea <whichtoe+0xba>
movw   $0x4,-0xa(%rbp)
jmp    11ea <whichtoe+0xba>
movw   $0x5,-0xa(%rbp)
jmp    11ea <whichtoe+0xba>
movw   $0x0,-0xa(%rbp)
jmp    11ef <whichtoe+0xbf>
movswl -0xa(%rbp),%ecx
mov    $0x1,%al
cmp    $0x1,%ecx
mov    %al,-0x19(%rbp)
jl     120e <whichtoe+0xde>
movswl -0xa(%rbp),%eax
cmp    $0x5,%eax
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    115b <whichtoe+0x2b>
jmp    121e <whichtoe+0xee>
movsbl -0x1(%rbp),%eax
cmp    $0x72,%eax
jne    12fe <whichtoe+0x1ce>
lea    -0x6(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xdeb(%rip),%rdi
call   1040 <printf@plt>
lea    0xe08(%rip),%rdi
call   1040 <printf@plt>
lea    0xdf2(%rip),%rdi
lea    -0x7(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x7(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     12c4 <whichtoe+0x194>
mov    -0x28(%rbp),%rax
lea    0xd90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movw   $0x1,-0xa(%rbp)
jmp    12ca <whichtoe+0x19a>
movw   $0x2,-0xa(%rbp)
jmp    12ca <whichtoe+0x19a>
movw   $0x3,-0xa(%rbp)
jmp    12ca <whichtoe+0x19a>
movw   $0x4,-0xa(%rbp)
jmp    12ca <whichtoe+0x19a>
movw   $0x5,-0xa(%rbp)
jmp    12ca <whichtoe+0x19a>
movw   $0x0,-0xa(%rbp)
jmp    12cf <whichtoe+0x19f>
movswl -0xa(%rbp),%ecx
mov    $0x1,%al
cmp    $0x1,%ecx
mov    %al,-0x29(%rbp)
jl     12ee <whichtoe+0x1be>
movswl -0xa(%rbp),%eax
cmp    $0x5,%eax
setg   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    123b <whichtoe+0x10b>
jmp    12fe <whichtoe+0x1ce>
movswl -0xa(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whichtoe>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
xor    %eax,%eax
cmp    $0x6c,%r14b
jne    11bb <whichtoe+0x7b>
lea    0xea2(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xebc(%rip),%r15
lea    0xe8f(%rip),%r12
lea    0xe96(%rip),%rbx
lea    0xa(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
movsbl 0xa(%rsp),%eax
lea    -0x61(%rax),%ecx
cmp    $0x4,%ecx
ja     1190 <whichtoe+0x50>
add    $0xffffffa0,%eax
cmp    $0x72,%r14b
jne    121f <whichtoe+0xdf>
lea    0xe4f(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe52(%rip),%r14
lea    0xe3d(%rip),%r15
lea    0xe2c(%rip),%rbx
lea    0xa(%rsp),%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
movsbl 0xa(%rsp),%ecx
lea    -0x61(%rcx),%eax
cmp    $0x4,%eax
ja     11f0 <whichtoe+0xb0>
mov    $0x66,%eax
sub    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"left\00"
@.str.1 = [17 x i8] c"\0Awhich toenail?\0A\00"
@.str.2 = [14 x i8] c"[a,b,c,d,e]: \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [6 x i8] c"right\00"
@.str.5 = [14 x i8] c"[e,d,c,b,a]: \00"
define i32 @whichtoe(i8 signext %0) {
%2 = alloca i8
%3 = alloca [5 x i8]
%4 = alloca i8
%5 = alloca i16
store i8 %0, i8* %2
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 108
br i1 %8, label %9, label %36
9: ; preds = %1
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %33, %9
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
switch i32 %17, label %23 [
i32 97, label %18
i32 98, label %19
i32 99, label %20
i32 100, label %21
i32 101, label %22
]
18: ; preds = %12
store i16 1, i16* %5
br label %24
19: ; preds = %12
store i16 2, i16* %5
br label %24
20: ; preds = %12
store i16 3, i16* %5
br label %24
21: ; preds = %12
store i16 4, i16* %5
br label %24
22: ; preds = %12
store i16 5, i16* %5
br label %24
23: ; preds = %12
store i16 0, i16* %5
br label %24
24: ; preds = %23, %22, %21, %20, %19, %18
br label %25
25: ; preds = %24
%26 = load i16, i16* %5
%27 = sext i16 %26 to i32
%28 = icmp slt i32 %27, 1
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i16, i16* %5
%31 = sext i16 %30 to i32
%32 = icmp sgt i32 %31, 5
br label %33
33: ; preds = %29, %25
%34 = phi i1 [ true, %25 ], [ %32, %29 ]
br i1 %34, label %12, label %35
35: ; preds = %33
br label %36
36: ; preds = %35, %1
%37 = load i8, i8* %2
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 114
br i1 %39, label %40, label %67
40: ; preds = %36
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %43
43: ; preds = %64, %40
%44 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%45 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%47 = load i8, i8* %4
%48 = sext i8 %47 to i32
switch i32 %48, label %54 [
i32 101, label %49
i32 100, label %50
i32 99, label %51
i32 98, label %52
i32 97, label %53
]
49: ; preds = %43
store i16 1, i16* %5
br label %55
50: ; preds = %43
store i16 2, i16* %5
br label %55
51: ; preds = %43
store i16 3, i16* %5
br label %55
52: ; preds = %43
store i16 4, i16* %5
br label %55
53: ; preds = %43
store i16 5, i16* %5
br label %55
54: ; preds = %43
store i16 0, i16* %5
br label %55
55: ; preds = %54, %53, %52, %51, %50, %49
br label %56
56: ; preds = %55
%57 = load i16, i16* %5
%58 = sext i16 %57 to i32
%59 = icmp slt i32 %58, 1
br i1 %59, label %64, label %60
60: ; preds = %56
%61 = load i16, i16* %5
%62 = sext i16 %61 to i32
%63 = icmp sgt i32 %62, 5
br label %64
64: ; preds = %60, %56
%65 = phi i1 [ true, %56 ], [ %63, %60 ]
br i1 %65, label %43, label %66
66: ; preds = %64
br label %67
67: ; preds = %66, %36
%68 = load i16, i16* %5
%69 = sext i16 %68 to i32
ret i32 %69
}

LLVM IR (-O2):
@.str = [5 x i8] c"left\00"
@.str.2 = [14 x i8] c"[a,b,c,d,e]: \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [6 x i8] c"right\00"
@.str.5 = [14 x i8] c"[e,d,c,b,a]: \00"
@str.6 = [16 x i8] c"\0Awhich toenail?\00"
define i32 @whichtoe(i8 signext %0) {
%2 = alloca [5 x i8]
%3 = alloca i8
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = icmp eq i8 %0, 108
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %8, %6
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = add nsw i32 %13, -97
%15 = icmp ult i32 %14, 5
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = sext i8 %12 to i32
%18 = add nsw i32 %17, -96
br label %19
19: ; preds = %16, %1
%20 = phi i32 [ 0, %1 ], [ %18, %16 ]
%21 = icmp eq i8 %0, 114
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %24, %22
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = add nsw i32 %29, -97
%31 = icmp ult i32 %30, 5
br i1 %31, label %32, label %24
32: ; preds = %24
%33 = sext i8 %28 to i32
%34 = sub nsw i32 102, %33
br label %35
35: ; preds = %32, %19
%36 = phi i32 [ %20, %19 ], [ %34, %32 ]
ret i32 %36
}