#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*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
void pickColour(void) {
  char colourFlag;
  printf("\n Pick a colour by its first letter.  (E.g. black => b)\n");
  scanf("%c", &colourFlag);
  getchar();
  switch (colourFlag) {
  case 'y':
    printf(" Custard is yellow.  Best served hot with apple pie.\n");
    break;
  case 'g':
    printf(" Green blades of grass waving in the wind.\n");
    break;
  case 'b':
    printf(" As black as the nights sky on a cloudy winters night.\n");
    break;
  case 'r':
    printf(" Fast cars and hot metal.\n");
    break;
  default:
    printf(" That colour does not sound poetic.\n");
    break;
  }
}


x86 assembly (clang, -O0):
<pickColour>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xf21(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4e(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl -0x1(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x17,%eax
ja     11c9 <pickColour+0x99>
mov    -0x10(%rbp),%rax
lea    0xe84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf10(%rip),%rdi
call   1030 <printf@plt>
jmp    11d5 <pickColour+0xa5>
lea    0xf35(%rip),%rdi
call   1030 <printf@plt>
jmp    11d5 <pickColour+0xa5>
lea    0xf50(%rip),%rdi
call   1030 <printf@plt>
jmp    11d5 <pickColour+0xa5>
lea    0xf77(%rip),%rdi
call   1030 <printf@plt>
jmp    11d5 <pickColour+0xa5>
lea    0xf81(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pickColour>:
push   %rax
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1c(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffff9e,%eax
cmp    $0x17,%eax
ja     1182 <pickColour+0x52>
lea    0xfae(%rip),%rdi
lea    0xe90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf35(%rip),%rdi
jmp    119b <pickColour+0x6b>
lea    0xfc3(%rip),%rdi
jmp    119b <pickColour+0x6b>
lea    0xf5a(%rip),%rdi
jmp    119b <pickColour+0x6b>
lea    0xf00(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [57 x i8] c"\0A Pick a colour by its first letter. (E.g. black => b)\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [54 x i8] c" Custard is yellow. Best served hot with apple pie.\0A\00"
@.str.3 = [44 x i8] c" Green blades of grass waving in the wind.\0A\00"
@.str.4 = [56 x i8] c" As black as the nights sky on a cloudy winters night.\0A\00"
@.str.5 = [27 x i8] c" Fast cars and hot metal.\0A\00"
@.str.6 = [37 x i8] c" That colour does not sound poetic.\0A\00"
define void @pickColour() {
%1 = alloca i8
%2 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = call i32 (...) @getchar()
%5 = load i8, i8* %1
%6 = sext i8 %5 to i32
switch i32 %6, label %15 [
i32 121, label %7
i32 103, label %9
i32 98, label %11
i32 114, label %13
]
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %17
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
br label %17
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
br label %17
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %11, %9, %7
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@str = [56 x i8] c"\0A Pick a colour by its first letter. (E.g. black => b)\00"
@str.7 = [26 x i8] c" Fast cars and hot metal.\00"
@str.8 = [55 x i8] c" As black as the nights sky on a cloudy winters night.\00"
@str.9 = [43 x i8] c" Green blades of grass waving in the wind.\00"
@str.10 = [53 x i8] c" Custard is yellow. Best served hot with apple pie.\00"
@str.11 = [36 x i8] c" That colour does not sound poetic.\00"
define void @pickColour() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = call i32 (...) @getchar()
%5 = load i8, i8* %1
%6 = sext i8 %5 to i32
switch i32 %6, label %10 [
i32 121, label %11
i32 103, label %7
i32 98, label %8
i32 114, label %9
]
7: ; preds = %0
br label %11
8: ; preds = %0
br label %11
9: ; preds = %0
br label %11
10: ; preds = %0
br label %11
11: ; preds = %0, %10, %9, %8, %7
%12 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0), %10 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0), %9 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.8, i64 0, i64 0), %8 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0), %7 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @str.10, i64 0, i64 0), %0 ]
%13 = call i32 @puts(i8* dereferenceable(1) %12)
ret void
}