#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 checkstatus();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ resetstatus();
int /*<<< orphan*/ scanf(char *, char *);
int close() {
  char close;
  do {
    if (checkstatus() == 1) {
      resetstatus();
    }
    printf("close now?\n");
    printf("[y/n]: ");
    scanf(" %c", &close);
  } while ((close != 'y') && (close != 'n'));
  if (close == 'y') {
    printf("\nbye-bye!\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <checkstatus@plt>
cmp    $0x1,%eax
jne    115f <close+0x1f>
mov    $0x0,%al
call   1060 <resetstatus@plt>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x6(%rbp)
je     11a6 <close+0x66>
movsbl -0x5(%rbp),%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    1148 <close+0x8>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
jne    11d6 <close+0x96>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dd <close+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xead(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0xe9b(%rip),%r12
lea    0x7(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <checkstatus@plt>
cmp    $0x1,%eax
jne    1193 <close+0x43>
xor    %eax,%eax
call   1070 <resetstatus@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movzbl 0x7(%rsp),%eax
cmp    $0x6e,%al
je     11ce <close+0x7e>
cmp    $0x79,%al
jne    1180 <close+0x30>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    11d0 <close+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"close now?\0A\00"
@.str.1 = [8 x i8] c"[y/n]: \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [11 x i8] c"\0Abye-bye!\0A\00"
define i32 @close() {
%1 = alloca i32
%2 = alloca i8
br label %3
3: ; preds = %20, %0
%4 = call i32 (...) @checkstatus()
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = call i32 (...) @resetstatus()
br label %8
8: ; preds = %6, %3
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %12
12: ; preds = %8
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 121
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 110
br label %20
20: ; preds = %16, %12
%21 = phi i1 [ false, %12 ], [ %19, %16 ]
br i1 %21, label %3, label %22
22: ; preds = %20
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 121
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %29
28: ; preds = %22
store i32 0, i32* %1
br label %29
29: ; preds = %28, %26
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"[y/n]: \00"
@.str.2 = [4 x i8] c" %c\00"
@str = [11 x i8] c"close now?\00"
@str.4 = [10 x i8] c"\0Abye-bye!\00"
define i32 @close() {
%1 = alloca i8
br label %2
2: ; preds = %7, %0
%3 = call i32 (...) @checkstatus()
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = call i32 (...) @resetstatus()
br label %7
7: ; preds = %5, %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%11 = load i8, i8* %1
switch i8 %11, label %2 [
i8 121, label %12
i8 110, label %14
]
12: ; preds = %7
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0))
br label %14
14: ; preds = %7, %12
%15 = phi i32 [ 1, %12 ], [ 0, %7 ]
ret i32 %15
}