#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*/ fgets(char *, int, int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
size_t strcspn(char *, char *);
char ask_what2search(char *ptr2name, int *ptr2val) {
  char choice;
  char name[10];
  int value;
  printf("\nShould it be a name or a digit? [N] / [D]\n\t\t\t-> ");
  choice = getchar();
  while (getchar() != '\n')
    continue;
  if (choice > 'a' && choice < 'z')
    choice += 'A' - 'a';
  switch (choice) {
  case 'N':
    printf("What name would you want to search?\n\t\t\t-> ");
    fgets(name, 10, stdin);
    name[strcspn(name, "\n")] = '\0';
    strcpy(ptr2name, name);
    break;
  case 'D':
    printf("What value would you search for?:\n\t\t\t-> ");
    scanf("%d", &value);
    while (getchar() != '\n')
      continue;
    *ptr2val = value;
    break;
  default:
    printf("And \"%c\" stands for a name or a digit ?!\n", choice);
    puts("\t\t:-|");
    puts("But I understand you man...");
    puts("It's not your fault, it's your parents!\n");
    break;
  }
  return choice;
}


x86 assembly (clang, -O0):
<ask_what2search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x11(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11b0 <ask_what2search+0x40>
jmp    1198 <ask_what2search+0x28>
movsbl -0x11(%rbp),%eax
cmp    $0x61,%eax
jle    11d4 <ask_what2search+0x64>
movsbl -0x11(%rbp),%eax
cmp    $0x7a,%eax
jge    11d4 <ask_what2search+0x64>
movsbl -0x11(%rbp),%eax
add    $0xffffffe0,%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x44,%eax
je     1246 <ask_what2search+0xd6>
jmp    11e9 <ask_what2search+0x79>
mov    -0x24(%rbp),%eax
sub    $0x4e,%eax
jne    128a <ask_what2search+0x11a>
jmp    11fa <ask_what2search+0x8a>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1b(%rbp),%rdi
mov    0x2dd5(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1070 <fgets@plt>
lea    -0x1b(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1060 <strcspn@plt>
movb   $0x0,-0x1b(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x1b(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    12c0 <ask_what2search+0x150>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2b(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <scanf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     127c <ask_what2search+0x10c>
jmp    1264 <ask_what2search+0xf4>
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    12c0 <ask_what2search+0x150>
movsbl -0x11(%rbp),%esi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe10(%rip),%rdi
call   1040 <puts@plt>
lea    0xe0a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
movsbl -0x11(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_what2search>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%al
jne    11a0 <ask_what2search+0x30>
lea    -0x62(%rbx),%eax
lea    -0x20(%rbx),%ecx
cmp    $0x18,%al
movzbl %bl,%eax
movzbl %cl,%ebx
cmovae %eax,%ebx
movsbl %bl,%esi
cmp    $0x44,%esi
je     1213 <ask_what2search+0xa3>
cmp    $0x4e,%esi
jne    1243 <ask_what2search+0xd3>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
lea    0x6(%rsp),%r15
mov    %r15,%rdi
mov    $0xa,%esi
call   1070 <fgets@plt>
lea    0xeb8(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcspn@plt>
movb   $0x0,0x6(%rsp,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
jmp    1275 <ask_what2search+0x105>
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5e(%rip),%rdi
mov    %rsp,%rsi
call   1090 <scanf@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%al
jne    1230 <ask_what2search+0xc0>
mov    (%rsp),%eax
mov    %eax,(%r15)
jmp    1275 <ask_what2search+0x105>
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe55(%rip),%rdi
call   1040 <puts@plt>
lea    0xe65(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [50 x i8] c"\0AShould it be a name or a digit? [N] / [D]\0A\09\09\09-> \00"
@.str.1 = [43 x i8] c"What name would you want to search?\0A\09\09\09-> \00"
@stdin = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [41 x i8] c"What value would you search for?:\0A\09\09\09-> \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [42 x i8] c"And \22%c\22 stands for a name or a digit ?!\0A\00"
@.str.6 = [6 x i8] c"\09\09:-|\00"
@.str.7 = [28 x i8] c"But I understand you man...\00"
@.str.8 = [41 x i8] c"It's not your fault, it's your parents!\0A\00"
define signext i8 @ask_what2search(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8
%6 = alloca [10 x i8]
%7 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %5
br label %10
10: ; preds = %14, %2
%11 = call signext i8 (...) @getchar()
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %10
br label %10
15: ; preds = %10
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
%18 = icmp sgt i32 %17, 97
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = icmp slt i32 %21, 122
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %5
%25 = sext i8 %24 to i32
%26 = add nsw i32 %25, -32
%27 = trunc i32 %26 to i8
store i8 %27, i8* %5
br label %28
28: ; preds = %23, %19, %15
%29 = load i8, i8* %5
%30 = sext i8 %29 to i32
switch i32 %30, label %53 [
i32 78, label %31
i32 68, label %42
]
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%34 = load i32, i32* @stdin
%35 = call i32 @fgets(i8* %33, i32 10, i32 %34)
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%37 = call i64 @strcspn(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %37
store i8 0, i8* %38
%39 = load i8*, i8** %3
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%41 = call i32 @strcpy(i8* %39, i8* %40)
br label %60
42: ; preds = %28
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
br label %45
45: ; preds = %49, %42
%46 = call signext i8 (...) @getchar()
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 10
br i1 %48, label %49, label %50
49: ; preds = %45
br label %45
50: ; preds = %45
%51 = load i32, i32* %7
%52 = load i32*, i32** %4
store i32 %51, i32* %52
br label %60
53: ; preds = %28
%54 = load i8, i8* %5
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %55)
%57 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%58 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%59 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
br label %60
60: ; preds = %53, %50, %31
%61 = load i8, i8* %5
ret i8 %61
}

LLVM IR (-O2):
@.str = [50 x i8] c"\0AShould it be a name or a digit? [N] / [D]\0A\09\09\09-> \00"
@.str.1 = [43 x i8] c"What name would you want to search?\0A\09\09\09-> \00"
@stdin = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [41 x i8] c"What value would you search for?:\0A\09\09\09-> \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [42 x i8] c"And \22%c\22 stands for a name or a digit ?!\0A\00"
@.str.6 = [6 x i8] c"\09\09:-|\00"
@.str.7 = [28 x i8] c"But I understand you man...\00"
@.str.8 = [41 x i8] c"It's not your fault, it's your parents!\0A\00"
define signext i8 @ask_what2search(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%8 = tail call signext i8 (...) @getchar()
br label %9
9: ; preds = %9, %2
%10 = tail call signext i8 (...) @getchar()
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %9
12: ; preds = %9
%13 = add i8 %8, -98
%14 = icmp ult i8 %13, 24
%15 = add i8 %8, -32
%16 = select i1 %14, i8 %15, i8 %8
%17 = sext i8 %16 to i32
switch i32 %17, label %33 [
i32 78, label %18
i32 68, label %25
]
18: ; preds = %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %5, i32 10, i32 %20)
%22 = call i64 @strcspn(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @strcpy(i8* %0, i8* %5)
br label %38
25: ; preds = %12
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
br label %28
28: ; preds = %28, %25
%29 = call signext i8 (...) @getchar()
%30 = icmp eq i8 %29, 10
br i1 %30, label %31, label %28
31: ; preds = %28
%32 = load i32, i32* %4
store i32 %32, i32* %1
br label %38
33: ; preds = %12
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
br label %38
38: ; preds = %33, %31, %18
ret i8 %16
}