#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*/ bfs(int, int);
int /*<<< orphan*/ dfs(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char ch;
  int n, f;
  printf("b.BFS d.DFS q.Quit\n");
  while (ch != 'q') {
    scanf("%c", &ch);
    switch (ch) {
    case 'b':
      printf("Number of nodes: \n");
      scanf("%d%*c", &n);
      printf("Search after node: \n");
      scanf("%d%*c", &f);
      bfs(n, f);
      break;
    case 'd':
      printf("Number of nodes: \n");
      scanf("%d%*c", &n);
      printf("Search after node: \n");
      scanf("%d%*c", &f);
      dfs(n, f);
      break;
    case 'q':
      return 0;
      break;
    default:
      scanf("%*c");
      printf("Press a valid key (b, d, q).\n");
      break;
    }
    printf("b.BFS d.DFS q.Quit\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
je     1280 <main+0x140>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x62,%eax
je     11b1 <main+0x71>
jmp    118f <main+0x4f>
mov    -0x14(%rbp),%eax
sub    $0x64,%eax
je     11fd <main+0xbd>
jmp    11a0 <main+0x60>
mov    -0x14(%rbp),%eax
sub    $0x71,%eax
je     1249 <main+0x109>
jmp    1255 <main+0x115>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe48(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <bfs@plt>
jmp    126f <main+0x12f>
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
lea    0xe1a(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xdfc(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <dfs@plt>
jmp    126f <main+0x12f>
movl   $0x0,-0x4(%rbp)
jmp    1287 <main+0x147>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xddb(%rip),%rdi
call   1030 <printf@plt>
lea    0xd8a(%rip),%rdi
call   1030 <printf@plt>
jmp    115b <main+0x1b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb4(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%r14
lea    0xf(%rsp),%r13
lea    0xe93(%rip),%rbx
lea    0xeb7(%rip),%r12
lea    0x14(%rsp),%rbp
jmp    11d0 <main+0x90>
xchg   %ax,%ax
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1060 <dfs@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
cmpb   $0x71,0xf(%rsp)
je     1252 <main+0x112>
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%eax
cmp    $0x62,%eax
je     1210 <main+0xd0>
cmp    $0x64,%eax
je     1180 <main+0x40>
cmp    $0x71,%eax
je     1252 <main+0x112>
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
jmp    11bd <main+0x7d>
nopl   (%rax)
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1040 <bfs@plt>
jmp    11bd <main+0x7d>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"b.BFS d.DFS q.Quit\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [19 x i8] c"Number of nodes: \0A\00"
@.str.3 = [6 x i8] c"%d%*c\00"
@.str.4 = [21 x i8] c"Search after node: \0A\00"
@.str.5 = [4 x i8] c"%*c\00"
@.str.6 = [30 x i8] c"Press a valid key (b, d, q).\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %34, %0
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 113
br i1 %9, label %10, label %36
10: ; preds = %6
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
switch i32 %13, label %31 [
i32 98, label %14
i32 100, label %22
i32 113, label %30
]
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i32 @bfs(i32 %19, i32 %20)
br label %34
22: ; preds = %10
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 @dfs(i32 %27, i32 %28)
br label %34
30: ; preds = %10
store i32 0, i32* %1
br label %37
31: ; preds = %10
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %34
34: ; preds = %31, %22, %14
%35 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %6
36: ; preds = %6
store i32 0, i32* %1
br label %37
37: ; preds = %36, %30
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.3 = [6 x i8] c"%d%*c\00"
@.str.5 = [4 x i8] c"%*c\00"
@str.9 = [19 x i8] c"b.BFS d.DFS q.Quit\00"
@str.10 = [18 x i8] c"Number of nodes: \00"
@str.11 = [20 x i8] c"Search after node: \00"
@str.12 = [29 x i8] c"Press a valid key (b, d, q).\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0))
br label %7
7: ; preds = %0, %30
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
switch i32 %10, label %27 [
i32 98, label %11
i32 100, label %19
i32 113, label %34
]
11: ; preds = %7
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @bfs(i32 %16, i32 %17)
br label %30
19: ; preds = %7
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @dfs(i32 %24, i32 %25)
br label %30
27: ; preds = %7
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
br label %30
30: ; preds = %27, %19, %11
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0))
%32 = load i8, i8* %1
%33 = icmp eq i8 %32, 113
br i1 %33, label %34, label %7
34: ; preds = %7, %30
ret i32 0
}