#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 getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strchr(char *, int);
char pega(char *no, char *msg) {
  int p;
  printf("%s", msg);
  p = getchar();
  while (!strchr(no, p)) {
    printf("?");
    p = getchar();
  }
  return (char)p;
}


x86 assembly (clang, -O0):
<pega>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117d <pega+0x4d>
jmp    119a <pega+0x6a>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
jmp    115c <pega+0x2c>
mov    -0x14(%rbp),%eax
movsbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pega>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strchr@plt>
test   %eax,%eax
jne    1183 <pega+0x43>
mov    $0x3f,%edi
call   1030 <putchar@plt>
jmp    1160 <pega+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"?\00"
define signext i8 @pega(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i32 (...) @getchar()
store i32 %8, i32* %5
br label %9
9: ; preds = %15, %2
%10 = load i8*, i8** %3
%11 = load i32, i32* %5
%12 = call i32 @strchr(i8* %10, i32 %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (...) @getchar()
store i32 %17, i32* %5
br label %9
18: ; preds = %9
%19 = load i32, i32* %5
%20 = trunc i32 %19 to i8
ret i8 %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define signext i8 @pega(i8* %0, i8* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = tail call i32 (...) @getchar()
%5 = tail call i32 @strchr(i8* %0, i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2, %7
%8 = tail call i32 @putchar(i32 63)
%9 = tail call i32 (...) @getchar()
%10 = tail call i32 @strchr(i8* %0, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %7, label %12
12: ; preds = %7, %2
%13 = phi i32 [ %4, %2 ], [ %9, %7 ]
%14 = trunc i32 %13 to i8
ret i8 %14
}