#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 */
typedef int /*<<< orphan*/ answ;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int read(int /*<<< orphan*/, char **, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int think_positively(int def_answ) {
  char answ[512];
  int len;
  if ((len = read(0, &answ, sizeof(answ))) < 1) {
    fprintf(stderr, "\n\nERROR! Cannot read stdin\n");
    perror("stdin");
    printf("#undef CONFIGURE_SOUNDCARD\n");
    printf("#undef KERNEL_SOUNDCARD\n");
    exit(-1);
  }
  if (len < 2)
    return def_answ;
  answ[len - 1] = 0;
  if (!strcmp(answ, "y") || !strcmp(answ, "Y"))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<think_positively>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x210(%rbp),%rsi
xor    %edi,%edi
mov    $0x200,%edx
call   1040 <read@plt>
mov    %eax,-0x214(%rbp)
cmp    $0x1,%eax
jge    11d3 <think_positively+0x73>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1060 <fprintf@plt>
lea    0xe70(%rip),%rdi
call   1070 <perror@plt>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
cmpl   $0x2,-0x214(%rbp)
jge    11eb <think_positively+0x8b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1249 <think_positively+0xe9>
mov    -0x214(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x210(%rbp,%rax,1)
lea    -0x210(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     1236 <think_positively+0xd6>
lea    -0x210(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1242 <think_positively+0xe2>
movl   $0x1,-0x4(%rbp)
jmp    1249 <think_positively+0xe9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<think_positively>:
push   %rbx
sub    $0x200,%rsp
mov    %edi,%ebx
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x200,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    1194 <think_positively+0x44>
cmp    $0x1,%eax
je     1189 <think_positively+0x39>
add    $0xffffffff,%eax
movb   $0x0,(%rsp,%rax,1)
movzwl (%rsp),%eax
and    $0xffffffdf,%eax
xor    %ebx,%ebx
cmp    $0x59,%ax
sete   %bl
mov    %ebx,%eax
add    $0x200,%rsp
pop    %rbx
ret
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe6c(%rip),%rdi
call   1060 <perror@plt>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"\0A\0AERROR! Cannot read stdin\0A\00"
@.str.1 = [6 x i8] c"stdin\00"
@.str.2 = [28 x i8] c"#undef CONFIGURE_SOUNDCARD\0A\00"
@.str.3 = [25 x i8] c"#undef KERNEL_SOUNDCARD\0A\00"
@.str.4 = [2 x i8] c"y\00"
@.str.5 = [2 x i8] c"Y\00"
define i32 @think_positively(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [512 x i8]
%5 = alloca i32
store i32 %0, i32* %3
%6 = bitcast [512 x i8]* %4 to i8**
%7 = call i32 @read(i32 0, i8** %6, i32 512)
store i32 %7, i32* %5
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %1
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i32, i32* %3
store i32 %20, i32* %2
br label %35
21: ; preds = %16
%22 = load i32, i32* %5
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %21
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %29, %21
store i32 1, i32* %2
br label %35
34: ; preds = %29
store i32 0, i32* %2
br label %35
35: ; preds = %34, %33, %19
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"\0A\0AERROR! Cannot read stdin\0A\00"
@.str.1 = [6 x i8] c"stdin\00"
@str = [27 x i8] c"#undef CONFIGURE_SOUNDCARD\00"
@str.6 = [24 x i8] c"#undef KERNEL_SOUNDCARD\00"
define i32 @think_positively(i32 %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = bitcast [512 x i8]* %2 to i8**
%5 = call i32 @read(i32 0, i8** %4, i32 512)
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %1
%15 = icmp eq i32 %5, 1
br i1 %15, label %25, label %16
16: ; preds = %14
%17 = add nsw i32 %5, -1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
%20 = bitcast [512 x i8]* %2 to i16*
%21 = load i16, i16* %20
%22 = and i16 %21, -33
%23 = icmp eq i16 %22, 89
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %16, %14
%26 = phi i32 [ %0, %14 ], [ %24, %16 ]
ret i32 %26
}