#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 atoi(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int printBasicOptions() {
  printf("Would you like to:\n1.) Host\n2.) Connect\n3.) List Nodes\n4.) "
         "Exit\n> ");
  char response[2];
  scanf("%1s", response);
  int resp = atoi(response);
  if (resp > 4 || resp < 1) {
    printf("Please choose one of the provided options.\n");
    return printBasicOptions();
  }
  return resp;
}


x86 assembly (clang, -O0):
<printBasicOptions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
lea    -0x6(%rbp),%rsi
lea    0xee4(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x6(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jg     1184 <printBasicOptions+0x44>
cmpl   $0x1,-0xc(%rbp)
jge    119d <printBasicOptions+0x5d>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
call   1040 <printBasicOptions@plt>
mov    %eax,-0x4(%rbp)
jmp    11a3 <printBasicOptions+0x63>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBasicOptions>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0xe(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
add    $0xfffffffb,%ecx
cmp    $0xfffffffb,%ecx
ja     1198 <printBasicOptions+0x48>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
call   1050 <printBasicOptions@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [67 x i8] c"Would you like to:\0A1.) Host\0A2.) Connect\0A3.) List Nodes\0A4.) Exit\0A> \00"
@.str.1 = [4 x i8] c"%1s\00"
@.str.2 = [44 x i8] c"Please choose one of the provided options.\0A\00"
define i32 @printBasicOptions() {
%1 = alloca i32
%2 = alloca [2 x i8]
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%8 = call i32 @atoi(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 4
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %11, %0
%15 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @printBasicOptions()
store i32 %16, i32* %1
br label %19
17: ; preds = %11
%18 = load i32, i32* %3
store i32 %18, i32* %1
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [67 x i8] c"Would you like to:\0A1.) Host\0A2.) Connect\0A3.) List Nodes\0A4.) Exit\0A> \00"
@.str.1 = [4 x i8] c"%1s\00"
@str = [43 x i8] c"Please choose one of the provided options.\00"
define i32 @printBasicOptions() {
%1 = alloca [2 x i8]
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%5 = call i32 @atoi(i8* %3)
%6 = add i32 %5, -5
%7 = icmp ult i32 %6, -4
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%10 = call i32 @printBasicOptions()
br label %11
11: ; preds = %0, %8
%12 = phi i32 [ %10, %8 ], [ %5, %0 ]
ret i32 %12
}