#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int play_again() {
  printf("Det var super kul...\nVill du spela igen?tryck r, vill du avsluta? "
         "tryck n\n");
  char c;
  scanf("%c", &c);
  if (c == 'r' || c == 'R') {
    return 1;
  } else if (c == 'n' || c == 'N') {
    return 0;
  } else {
    printf("Please enter r to replay or n to quit!\n");
    return play_again();
  }
  while (getchar() != '\n' && getchar() != EOF) {
    ;
  }
}


x86 assembly (clang, -O0):
<play_again>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x72,%eax
je     116e <play_again+0x3e>
movsbl -0x5(%rbp),%eax
cmp    $0x52,%eax
jne    117a <play_again+0x4a>
movl   $0x1,-0x4(%rbp)
jmp    11b4 <play_again+0x84>
movsbl -0x5(%rbp),%eax
cmp    $0x6e,%eax
je     1194 <play_again+0x64>
movsbl -0x5(%rbp),%eax
cmp    $0x4e,%eax
jne    11a0 <play_again+0x70>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <play_again+0x84>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
call   1040 <play_again@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_again>:
push   %rax
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x7(%rsp),%cl
and    $0xdf,%cl
cmp    $0x4e,%cl
je     1166 <play_again+0x36>
mov    $0x1,%eax
cmp    $0x52,%cl
jne    116a <play_again+0x3a>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
call   1040 <play_again@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [75 x i8] c"Det var super kul...\0AVill du spela igen?tryck r, vill du avsluta? tryck n\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [40 x i8] c"Please enter r to replay or n to quit!\0A\00"
@EOF = global i8 0
define i32 @play_again() {
%1 = alloca i32
%2 = alloca i8
%3 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 114
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 82
br i1 %11, label %12, label %13
12: ; preds = %8, %0
store i32 1, i32* %1
br label %25
13: ; preds = %8
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 110
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 78
br i1 %20, label %21, label %22
21: ; preds = %17, %13
store i32 0, i32* %1
br label %25
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @play_again()
store i32 %24, i32* %1
br label %25
25: ; preds = %22, %21, %12
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@EOF = global i8 0
@str = [74 x i8] c"Det var super kul...\0AVill du spela igen?tryck r, vill du avsluta? tryck n\00"
@str.3 = [39 x i8] c"Please enter r to replay or n to quit!\00"
define i32 @play_again() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = and i8 %4, -33
switch i8 %5, label %6 [
i8 82, label %10
i8 78, label %9
]
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.3, i64 0, i64 0))
%8 = call i32 @play_again()
br label %10
9: ; preds = %0
br label %10
10: ; preds = %0, %9, %6
%11 = phi i32 [ %8, %6 ], [ 1, %0 ], [ 0, %9 ]
ret i32 %11
}