#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 BUFSIZ;
int /*<<< orphan*/ assert(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
bool get_input_bool() {
  while (1) {
    fflush(stdout);
    char *input = malloc(sizeof(char) * BUFSIZ);
    assert(input);
    fgets(input, BUFSIZ, stdin);
    int i;
    for (i = 0; i < BUFSIZ; i++) {
      if (input[i] == '\n') {
        input[i] = '\0';
      }
    }
    if (strcmp(input, "y") == 0) {
      free(input);
      return true;
    } else if (strcmp(input, "n") == 0) {
      free(input);
      return false;
    } else {
      printf("  Invalid response. Please enter \"y\" or \"n\": ");
    }
  }
}


x86 assembly (clang, -O0):
<get_input_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
mov    0x2e4b(%rip),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
mov    0x2e2c(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e04(%rip),%rcx
cmp    (%rcx),%eax
jge    1210 <get_input_bool+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11fd <get_input_bool+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1202 <get_input_bool+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <get_input_bool+0x5a>
mov    -0x10(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    123f <get_input_bool+0xcf>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1284 <get_input_bool+0x114>
mov    -0x10(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    126e <get_input_bool+0xfe>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    1284 <get_input_bool+0x114>
lea    0xd8f(%rip),%rdi
call   1040 <printf@plt>
jmp    127f <get_input_bool+0x10f>
jmp    1178 <get_input_bool+0x8>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_input_bool>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e4e(%rip),%r13
mov    0x2e4f(%rip),%rbp
mov    0x2e58(%rip),%r15
lea    0xe89(%rip),%r12
lea    0xe84(%rip),%r14
xchg   %ax,%ax
mov    0x0(%r13),%edi
call   1090 <fflush@plt>
mov    0x0(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <assert@plt>
mov    0x0(%rbp),%esi
mov    (%r15),%edx
mov    %rbx,%rdi
call   1050 <fgets@plt>
mov    0x0(%rbp),%eax
test   %eax,%eax
jle    13c0 <get_input_bool+0x250>
cmp    $0x10,%eax
jae    11f0 <get_input_bool+0x80>
xor    %ecx,%ecx
jmp    1409 <get_input_bool+0x299>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ecx
and    $0xfffffff0,%ecx
xor    %edx,%edx
movdqa 0xe01(%rip),%xmm3
movdqa 0xe09(%rip),%xmm4
jmp    121d <get_input_bool+0xad>
nopl   0x0(%rax)
add    $0x10,%rdx
cmp    %rdx,%rcx
je     13b0 <get_input_bool+0x240>
movq   (%rbx,%rdx,1),%xmm1
movdqa %xmm1,%xmm0
pcmpeqb %xmm3,%xmm0
movd   %xmm0,%esi
test   $0x1,%sil
je     1238 <get_input_bool+0xc8>
movb   $0x0,(%rbx,%rdx,1)
movdqa %xmm0,%xmm2
pslld  $0x8,%xmm2
movd   %xmm2,%esi
shr    $0x10,%esi
test   $0x1,%sil
je     1253 <get_input_bool+0xe3>
movb   $0x0,0x1(%rbx,%rdx,1)
pshuflw $0x55,%xmm1,%xmm2
pcmpeqb %xmm3,%xmm2
pextrw $0x2,%xmm2,%esi
test   $0x1,%sil
je     126c <get_input_bool+0xfc>
movb   $0x0,0x2(%rbx,%rdx,1)
movdqa %xmm0,%xmm2
psllq  $0x18,%xmm2
pextrw $0x3,%xmm2,%esi
test   $0x1,%sil
je     1285 <get_input_bool+0x115>
movb   $0x0,0x3(%rbx,%rdx,1)
pshufd $0x55,%xmm1,%xmm1
pcmpeqb %xmm4,%xmm1
pextrw $0x4,%xmm1,%esi
test   $0x1,%sil
je     129e <get_input_bool+0x12e>
movb   $0x0,0x4(%rbx,%rdx,1)
movdqa %xmm0,%xmm1
pslldq $0x5,%xmm1
pextrw $0x5,%xmm1,%esi
test   $0x1,%sil
je     12b7 <get_input_bool+0x147>
movb   $0x0,0x5(%rbx,%rdx,1)
pextrw $0x3,%xmm0,%esi
test   $0x1,%sil
je     12c7 <get_input_bool+0x157>
movb   $0x0,0x6(%rbx,%rdx,1)
pslldq $0x7,%xmm0
pextrw $0x7,%xmm0,%esi
test   $0x1,%sil
je     12dc <get_input_bool+0x16c>
movb   $0x0,0x7(%rbx,%rdx,1)
movq   0x8(%rbx,%rdx,1),%xmm1
movdqa %xmm1,%xmm0
pcmpeqb %xmm3,%xmm0
movd   %xmm0,%esi
test   $0x1,%sil
je     12f9 <get_input_bool+0x189>
movb   $0x0,0x8(%rbx,%rdx,1)
movdqa %xmm0,%xmm2
pslld  $0x8,%xmm2
movd   %xmm2,%esi
shr    $0x10,%esi
test   $0x1,%sil
je     1314 <get_input_bool+0x1a4>
movb   $0x0,0x9(%rbx,%rdx,1)
pshuflw $0x55,%xmm1,%xmm2
pcmpeqb %xmm3,%xmm2
pextrw $0x2,%xmm2,%esi
test   $0x1,%sil
je     132d <get_input_bool+0x1bd>
movb   $0x0,0xa(%rbx,%rdx,1)
movdqa %xmm0,%xmm2
psllq  $0x18,%xmm2
pextrw $0x3,%xmm2,%esi
test   $0x1,%sil
je     1346 <get_input_bool+0x1d6>
movb   $0x0,0xb(%rbx,%rdx,1)
pshufd $0x55,%xmm1,%xmm1
pcmpeqb %xmm4,%xmm1
pextrw $0x4,%xmm1,%esi
test   $0x1,%sil
je     135f <get_input_bool+0x1ef>
movb   $0x0,0xc(%rbx,%rdx,1)
movdqa %xmm0,%xmm1
pslldq $0x5,%xmm1
pextrw $0x5,%xmm1,%esi
test   $0x1,%sil
je     1378 <get_input_bool+0x208>
movb   $0x0,0xd(%rbx,%rdx,1)
pextrw $0x3,%xmm0,%esi
test   $0x1,%sil
je     1388 <get_input_bool+0x218>
movb   $0x0,0xe(%rbx,%rdx,1)
pslldq $0x7,%xmm0
pextrw $0x7,%xmm0,%esi
test   $0x1,%sil
je     1210 <get_input_bool+0xa0>
movb   $0x0,0xf(%rbx,%rdx,1)
jmp    1210 <get_input_bool+0xa0>
cs nopw 0x0(%rax,%rax,1)
cmp    %rax,%rcx
jne    1409 <get_input_bool+0x299>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1415 <get_input_bool+0x2a5>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     141c <get_input_bool+0x2ac>
lea    0xc3d(%rip),%rdi
call   1040 <printf@plt>
jmp    11a0 <get_input_bool+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rcx,%rax
je     13c0 <get_input_bool+0x250>
cmpb   $0xa,(%rbx,%rcx,1)
jne    1400 <get_input_bool+0x290>
movb   $0x0,(%rbx,%rcx,1)
jmp    1400 <get_input_bool+0x290>
mov    $0x1,%ebp
jmp    141e <get_input_bool+0x2ae>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str = [2 x i8] c"y\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [46 x i8] c" Invalid response. Please enter \22y\22 or \22n\22: \00"
define i32 @get_input_bool() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
br label %4
4: ; preds = %0, %56
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = load i32, i32* @BUFSIZ
%8 = sext i32 %7 to i64
%9 = mul i64 1, %8
%10 = trunc i64 %9 to i32
%11 = call i8* @malloc(i32 %10)
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @assert(i8* %12)
%14 = load i8*, i8** %2
%15 = load i32, i32* @BUFSIZ
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %14, i32 %15, i32 %16)
store i32 0, i32* %3
br label %18
18: ; preds = %36, %4
%19 = load i32, i32* %3
%20 = load i32, i32* @BUFSIZ
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %35
30: ; preds = %22
%31 = load i8*, i8** %2
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 0, i8* %34
br label %35
35: ; preds = %30, %22
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %18
39: ; preds = %18
%40 = load i8*, i8** %2
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %2
%45 = call i32 @free(i8* %44)
store i32 1, i32* %1
br label %57
46: ; preds = %39
%47 = load i8*, i8** %2
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i8*, i8** %2
%52 = call i32 @free(i8* %51)
store i32 0, i32* %1
br label %57
53: ; preds = %46
%54 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %55
55: ; preds = %53
br label %56
56: ; preds = %55
br label %4
57: ; preds = %50, %43
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@stdout = global i32 0
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str = [2 x i8] c"y\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [46 x i8] c" Invalid response. Please enter \22y\22 or \22n\22: \00"
define i32 @get_input_bool() {
br label %1
1: ; preds = %127, %0
%2 = load i32, i32* @stdout
%3 = tail call i32 @fflush(i32 %2)
%4 = load i32, i32* @BUFSIZ
%5 = tail call i8* @malloc(i32 %4)
%6 = tail call i32 @assert(i8* %5)
%7 = load i32, i32* @BUFSIZ
%8 = load i32, i32* @stdin
%9 = tail call i32 @fgets(i8* %5, i32 %7, i32 %8)
%10 = load i32, i32* @BUFSIZ
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %121
12: ; preds = %1
%13 = zext i32 %10 to i64
%14 = icmp ult i32 %10, 16
br i1 %14, label %110, label %15
15: ; preds = %12
%16 = and i64 %13, 4294967280
br label %17
17: ; preds = %105, %15
%18 = phi i64 [ 0, %15 ], [ %106, %105 ]
%19 = or i64 %18, 8
%20 = getelementptr inbounds i8, i8* %5, i64 %18
%21 = bitcast i8* %20 to <8 x i8>*
%22 = load <8 x i8>, <8 x i8>* %21
%23 = getelementptr inbounds i8, i8* %20, i64 8
%24 = bitcast i8* %23 to <8 x i8>*
%25 = load <8 x i8>, <8 x i8>* %24
%26 = icmp eq <8 x i8> %22, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%27 = icmp eq <8 x i8> %25, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%28 = extractelement <8 x i1> %26, i64 0
br i1 %28, label %29, label %31
29: ; preds = %17
%30 = getelementptr inbounds i8, i8* %5, i64 %18
store i8 0, i8* %30
br label %31
31: ; preds = %29, %17
%32 = extractelement <8 x i1> %26, i64 1
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = or i64 %18, 1
%35 = getelementptr inbounds i8, i8* %5, i64 %34
store i8 0, i8* %35
br label %36
36: ; preds = %33, %31
%37 = extractelement <8 x i1> %26, i64 2
br i1 %37, label %38, label %41
38: ; preds = %36
%39 = or i64 %18, 2
%40 = getelementptr inbounds i8, i8* %5, i64 %39
store i8 0, i8* %40
br label %41
41: ; preds = %38, %36
%42 = extractelement <8 x i1> %26, i64 3
br i1 %42, label %43, label %46
43: ; preds = %41
%44 = or i64 %18, 3
%45 = getelementptr inbounds i8, i8* %5, i64 %44
store i8 0, i8* %45
br label %46
46: ; preds = %43, %41
%47 = extractelement <8 x i1> %26, i64 4
br i1 %47, label %48, label %51
48: ; preds = %46
%49 = or i64 %18, 4
%50 = getelementptr inbounds i8, i8* %5, i64 %49
store i8 0, i8* %50
br label %51
51: ; preds = %48, %46
%52 = extractelement <8 x i1> %26, i64 5
br i1 %52, label %53, label %56
53: ; preds = %51
%54 = or i64 %18, 5
%55 = getelementptr inbounds i8, i8* %5, i64 %54
store i8 0, i8* %55
br label %56
56: ; preds = %53, %51
%57 = extractelement <8 x i1> %26, i64 6
br i1 %57, label %58, label %61
58: ; preds = %56
%59 = or i64 %18, 6
%60 = getelementptr inbounds i8, i8* %5, i64 %59
store i8 0, i8* %60
br label %61
61: ; preds = %58, %56
%62 = extractelement <8 x i1> %26, i64 7
br i1 %62, label %63, label %66
63: ; preds = %61
%64 = or i64 %18, 7
%65 = getelementptr inbounds i8, i8* %5, i64 %64
store i8 0, i8* %65
br label %66
66: ; preds = %63, %61
%67 = extractelement <8 x i1> %27, i64 0
br i1 %67, label %68, label %70
68: ; preds = %66
%69 = getelementptr inbounds i8, i8* %5, i64 %19
store i8 0, i8* %69
br label %70
70: ; preds = %68, %66
%71 = extractelement <8 x i1> %27, i64 1
br i1 %71, label %72, label %75
72: ; preds = %70
%73 = or i64 %18, 9
%74 = getelementptr inbounds i8, i8* %5, i64 %73
store i8 0, i8* %74
br label %75
75: ; preds = %72, %70
%76 = extractelement <8 x i1> %27, i64 2
br i1 %76, label %77, label %80
77: ; preds = %75
%78 = or i64 %18, 10
%79 = getelementptr inbounds i8, i8* %5, i64 %78
store i8 0, i8* %79
br label %80
80: ; preds = %77, %75
%81 = extractelement <8 x i1> %27, i64 3
br i1 %81, label %82, label %85
82: ; preds = %80
%83 = or i64 %18, 11
%84 = getelementptr inbounds i8, i8* %5, i64 %83
store i8 0, i8* %84
br label %85
85: ; preds = %82, %80
%86 = extractelement <8 x i1> %27, i64 4
br i1 %86, label %87, label %90
87: ; preds = %85
%88 = or i64 %18, 12
%89 = getelementptr inbounds i8, i8* %5, i64 %88
store i8 0, i8* %89
br label %90
90: ; preds = %87, %85
%91 = extractelement <8 x i1> %27, i64 5
br i1 %91, label %92, label %95
92: ; preds = %90
%93 = or i64 %18, 13
%94 = getelementptr inbounds i8, i8* %5, i64 %93
store i8 0, i8* %94
br label %95
95: ; preds = %92, %90
%96 = extractelement <8 x i1> %27, i64 6
br i1 %96, label %97, label %100
97: ; preds = %95
%98 = or i64 %18, 14
%99 = getelementptr inbounds i8, i8* %5, i64 %98
store i8 0, i8* %99
br label %100
100: ; preds = %97, %95
%101 = extractelement <8 x i1> %27, i64 7
br i1 %101, label %102, label %105
102: ; preds = %100
%103 = or i64 %18, 15
%104 = getelementptr inbounds i8, i8* %5, i64 %103
store i8 0, i8* %104
br label %105
105: ; preds = %102, %100
%106 = add nuw i64 %18, 16
%107 = icmp eq i64 %106, %16
br i1 %107, label %108, label %17
108: ; preds = %105
%109 = icmp eq i64 %16, %13
br i1 %109, label %121, label %110
110: ; preds = %12, %108
%111 = phi i64 [ 0, %12 ], [ %16, %108 ]
br label %112
112: ; preds = %110, %118
%113 = phi i64 [ %119, %118 ], [ %111, %110 ]
%114 = getelementptr inbounds i8, i8* %5, i64 %113
%115 = load i8, i8* %114
%116 = icmp eq i8 %115, 10
br i1 %116, label %117, label %118
117: ; preds = %112
store i8 0, i8* %114
br label %118
118: ; preds = %112, %117
%119 = add nuw nsw i64 %113, 1
%120 = icmp eq i64 %119, %13
br i1 %120, label %121, label %112
121: ; preds = %118, %108, %1
%122 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%123 = icmp eq i64 %122, 0
br i1 %123, label %129, label %124
124: ; preds = %121
%125 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%126 = icmp eq i64 %125, 0
br i1 %126, label %129, label %127
127: ; preds = %124
%128 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %1
129: ; preds = %124, %121
%130 = phi i32 [ 1, %121 ], [ 0, %124 ]
%131 = tail call i32 @free(i8* %5)
ret i32 %130
}