#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 *, ...);
void interface(void (*p_show_choices)(), int (*p_choice_validator)(int *),
               void (*p_server)(int *)) {
  int choice, right_choice;
  char want_to_continue;
  do {
    do {
      right_choice = 1;
      p_show_choices();
      scanf("%d", &choice);
      printf("\n");
      if (!p_choice_validator(&choice)) {
        printf("Invalid option.\n");
        right_choice = 0;
      }
    } while (!right_choice);
    p_server(&choice);
    printf("\nWould you like to continue? 'Y' for yes and any character for "
           "no.\n");
    getchar();
    scanf("%c", &want_to_continue);
  } while ('Y' == want_to_continue);
  printf("Thank you for using this program.");
}


x86 assembly (clang, -O0):
<interface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
jmp    1149 <interface+0x19>
movl   $0x1,-0x20(%rbp)
mov    $0x0,%al
call   *-0x8(%rbp)
lea    0xea4(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1c(%rbp),%rdi
call   *-0x10(%rbp)
cmp    $0x0,%eax
jne    1196 <interface+0x66>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    119b <interface+0x6b>
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1149 <interface+0x19>
lea    -0x1c(%rbp),%rdi
call   *-0x18(%rbp)
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xe8b(%rip),%rdi
lea    -0x21(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x21(%rbp),%ecx
mov    $0x59,%eax
cmp    %ecx,%eax
je     1144 <interface+0x14>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interface>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
lea    0xe95(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xeb1(%rip),%rbp
jmp    1188 <interface+0x38>
nopl   0x0(%rax)
mov    %rbp,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   *%r13
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   *%r15
test   %eax,%eax
je     1180 <interface+0x30>
mov    %rbx,%rdi
call   *%r14
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xe35(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmpb   $0x59,0x3(%rsp)
je     1188 <interface+0x38>
lea    0xe1e(%rip),%rdi
call   1050 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [17 x i8] c"Invalid option.\0A\00"
@.str.3 = [68 x i8] c"\0AWould you like to continue? 'Y' for yes and any character for no.\0A\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [34 x i8] c"Thank you for using this program.\00"
define void @interface(void (...)* %0, i32 (i32*)* %1, void (i32*)* %2) {
%4 = alloca void (...)*
%5 = alloca i32 (i32*)*
%6 = alloca void (i32*)*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store void (...)* %0, void (...)** %4
store i32 (i32*)* %1, i32 (i32*)** %5
store void (i32*)* %2, void (i32*)** %6
br label %10
10: ; preds = %30, %3
br label %11
11: ; preds = %21, %10
store i32 1, i32* %8
%12 = load void (...)*, void (...)** %4
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32 (i32*)*, i32 (i32*)** %5
%16 = call i32 %15(i32* %7)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %20
20: ; preds = %18, %11
br label %21
21: ; preds = %20
%22 = load i32, i32* %8
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %11, label %25
25: ; preds = %21
%26 = load void (i32*)*, void (i32*)** %6
%27 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 (...) @getchar()
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
br label %30
30: ; preds = %25
%31 = load i8, i8* %9
%32 = sext i8 %31 to i32
%33 = icmp eq i32 89, %32
br i1 %33, label %10, label %34
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [34 x i8] c"Thank you for using this program.\00"
@str = [16 x i8] c"Invalid option.\00"
@str.6 = [67 x i8] c"\0AWould you like to continue? 'Y' for yes and any character for no.\00"
define void @interface(void (...)* nocapture %0, i32 (i32*)* nocapture %1, void (i32*)* nocapture %2) {
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %4 to i8*
br label %7
7: ; preds = %18, %3
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%9 = call i32 @putchar(i32 10)
%10 = call i32 %1(i32* %4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7, %12
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = call i32 @putchar(i32 10)
%16 = call i32 %1(i32* %4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %12, label %18
18: ; preds = %12, %7
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.6, i64 0, i64 0))
%20 = call i32 (...) @getchar()
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%22 = load i8, i8* %5
%23 = icmp eq i8 %22, 89
br i1 %23, label %7, label %24
24: ; preds = %18
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
ret void
}