#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*/ fflush(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stdout;
int strlen(char const *);
bool askuser(const char *s) {
  printf("Type %s: ", s);
  fflush(stdout);
  char c;
  for (int i = 0; i < strlen(s); i++) {
    c = getchar();
    if (c != s[i])
      goto failed;
  }
  c = getchar();
  if (c != '\n')
    goto failed;
  return true;
failed:
  while (c != '\n')
    c = getchar();
  return false;
}


x86 assembly (clang, -O0):
<askuser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11c7 <askuser+0x87>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11b4 <askuser+0x74>
jmp    11ef <askuser+0xaf>
jmp    11b9 <askuser+0x79>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <askuser+0x31>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
je     11e3 <askuser+0xa3>
jmp    11ef <askuser+0xaf>
movl   $0x1,-0x4(%rbp)
jmp    1217 <askuser+0xd7>
jmp    11f4 <askuser+0xb4>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
je     1210 <askuser+0xd0>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x11(%rbp)
jmp    11f4 <askuser+0xb4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askuser>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a0 <askuser+0x60>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14,%rbx,1),%al
jne    11b2 <askuser+0x72>
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1180 <askuser+0x40>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x1,%ebx
cmp    $0xa,%al
jne    11b8 <askuser+0x78>
jmp    11cb <askuser+0x8b>
xor    %ebx,%ebx
cmp    $0xa,%al
je     11cb <askuser+0x8b>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11c0 <askuser+0x80>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Type %s: \00"
@stdout = global i32 0
define i32 @askuser(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
store i32 0, i32* %5
br label %10
10: ; preds = %28, %1
%11 = load i32, i32* %5
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %31
15: ; preds = %10
%16 = call signext i8 (...) @getchar()
store i8 %16, i8* %4
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %18, %24
br i1 %25, label %26, label %27
26: ; preds = %15
br label %38
27: ; preds = %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %10
31: ; preds = %10
%32 = call signext i8 (...) @getchar()
store i8 %32, i8* %4
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 10
br i1 %35, label %36, label %37
36: ; preds = %31
br label %38
37: ; preds = %31
store i32 1, i32* %2
br label %46
38: ; preds = %36, %26
br label %39
39: ; preds = %43, %38
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 10
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call signext i8 (...) @getchar()
store i8 %44, i8* %4
br label %39
45: ; preds = %39
store i32 0, i32* %2
br label %46
46: ; preds = %45, %37
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@.str = [10 x i8] c"Type %s: \00"
@stdout = global i32 0
define i32 @askuser(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = load i32, i32* @stdout
%4 = tail call i32 @fflush(i32 %3)
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %11, label %18
7: ; preds = %11
%8 = tail call i32 @strlen(i8* %0)
%9 = sext i32 %8 to i64
%10 = icmp slt i64 %17, %9
br i1 %10, label %11, label %18
11: ; preds = %1, %7
%12 = phi i64 [ %17, %7 ], [ 0, %1 ]
%13 = tail call signext i8 (...) @getchar()
%14 = getelementptr inbounds i8, i8* %0, i64 %12
%15 = load i8, i8* %14
%16 = icmp eq i8 %13, %15
%17 = add nuw nsw i64 %12, 1
br i1 %16, label %7, label %21
18: ; preds = %7, %1
%19 = tail call signext i8 (...) @getchar()
%20 = icmp eq i8 %19, 10
br i1 %20, label %27, label %23
21: ; preds = %11
%22 = icmp eq i8 %13, 10
br i1 %22, label %27, label %23
23: ; preds = %18, %21
br label %24
24: ; preds = %23, %24
%25 = tail call signext i8 (...) @getchar()
%26 = icmp eq i8 %25, 10
br i1 %26, label %27, label %24
27: ; preds = %24, %21, %18
%28 = phi i32 [ 1, %18 ], [ 0, %21 ], [ 0, %24 ]
ret i32 %28
}