#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*/ eat();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
char toupper(int /*<<< orphan*/);
void hunger(void) {
  puts("\n\tYou hungry ma man? Y/N");
  char ch = toupper(getchar());
  switch (ch) {
  case 'Y':
    puts("Really?\n\tThen eat!");
    eat();
    break;
  case 'N':
    printf("Good!\n\tFood's expensive... people are fat...");
    printf("\nYou're doing the right thing by not eating!\n\n");
    break;
  default:
    printf("\"Y\"es or \"N\"o?");
    printf("\nSo hungry you can't even type Y/N");
    printf("\nHere's some leftovers... They are free!");
    puts("\n\tThis time!");
    eat();
  }
}


x86 assembly (clang, -O0):
<hunger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%edi
call   1040 <toupper@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x4e,%eax
je     11b3 <hunger+0x63>
jmp    118a <hunger+0x3a>
mov    -0x8(%rbp),%eax
sub    $0x59,%eax
jne    11d0 <hunger+0x80>
jmp    119b <hunger+0x4b>
lea    0xe77(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1030 <eat@plt>
jmp    1207 <hunger+0xb7>
lea    0xe72(%rip),%rdi
call   1060 <printf@plt>
lea    0xe93(%rip),%rdi
call   1060 <printf@plt>
jmp    1207 <hunger+0xb7>
lea    0xeb1(%rip),%rdi
call   1060 <printf@plt>
lea    0xeb4(%rip),%rdi
call   1060 <printf@plt>
lea    0xecb(%rip),%rdi
call   1060 <printf@plt>
lea    0xee8(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1030 <eat@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hunger>:
push   %rax
lea    0xea8(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%edi
call   1040 <toupper@plt>
movsbl %al,%eax
cmp    $0x4e,%eax
je     1181 <hunger+0x31>
cmp    $0x59,%eax
jne    119a <hunger+0x4a>
lea    0xe9a(%rip),%rdi
jmp    11c5 <hunger+0x75>
lea    0xea4(%rip),%rdi
call   1060 <printf@plt>
lea    0xf2d(%rip),%rdi
pop    %rax
jmp    1050 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1060 <printf@plt>
lea    0xebb(%rip),%rdi
call   1060 <printf@plt>
lea    0xed2(%rip),%rdi
call   1060 <printf@plt>
lea    0xeef(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <eat@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"\0A\09You hungry ma man? Y/N\00"
@.str.1 = [19 x i8] c"Really?\0A\09Then eat!\00"
@.str.2 = [45 x i8] c"Good!\0A\09Food's expensive... people are fat...\00"
@.str.3 = [47 x i8] c"\0AYou're doing the right thing by not eating!\0A\0A\00"
@.str.4 = [15 x i8] c"\22Y\22es or \22N\22o?\00"
@.str.5 = [35 x i8] c"\0ASo hungry you can't even type Y/N\00"
@.str.6 = [41 x i8] c"\0AHere's some leftovers... They are free!\00"
@.str.7 = [13 x i8] c"\0A\09This time!\00"
define void @hunger() {
%1 = alloca i8
%2 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @getchar()
%4 = call signext i8 @toupper(i32 %3)
store i8 %4, i8* %1
%5 = load i8, i8* %1
%6 = sext i8 %5 to i32
switch i32 %6, label %13 [
i32 89, label %7
i32 78, label %10
]
7: ; preds = %0
%8 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (...) @eat()
br label %19
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
br label %19
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%18 = call i32 (...) @eat()
br label %19
19: ; preds = %13, %10, %7
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0A\09You hungry ma man? Y/N\00"
@.str.1 = [19 x i8] c"Really?\0A\09Then eat!\00"
@.str.2 = [45 x i8] c"Good!\0A\09Food's expensive... people are fat...\00"
@.str.4 = [15 x i8] c"\22Y\22es or \22N\22o?\00"
@.str.5 = [35 x i8] c"\0ASo hungry you can't even type Y/N\00"
@.str.6 = [41 x i8] c"\0AHere's some leftovers... They are free!\00"
@.str.7 = [13 x i8] c"\0A\09This time!\00"
@str = [46 x i8] c"\0AYou're doing the right thing by not eating!\0A\00"
define void @hunger() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = tail call signext i8 @toupper(i32 %2)
%4 = sext i8 %3 to i32
switch i32 %4, label %11 [
i32 89, label %5
i32 78, label %8
]
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (...) @eat()
br label %17
8: ; preds = %0
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %17
11: ; preds = %0
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%16 = tail call i32 (...) @eat()
br label %17
17: ; preds = %11, %8, %5
ret void
}