#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 */
unsigned int get_next_prime(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  unsigned int current_prime = 2;
  char user_input = 'Y';
  while (user_input != 'N' && user_input != 'n') {
    printf("Show the next prime? (Y/N):");
    scanf(" %c", &user_input);
    if (user_input == 'Y' || user_input == 'y') {
      printf("%s%d\n\n", "The next prime number is ", current_prime);
      current_prime = get_next_prime(current_prime);
    }
  }
  printf("Bye :) \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
movb   $0x59,-0x15(%rbp)
movsbl -0x15(%rbp),%ecx
xor    %eax,%eax
cmp    $0x4e,%ecx
mov    %al,-0x16(%rbp)
je     1170 <main+0x40>
movsbl -0x15(%rbp),%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
test   $0x1,%al
jne    1180 <main+0x50>
jmp    11e0 <main+0xb0>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x15(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x59,%eax
je     11b8 <main+0x88>
movsbl -0x15(%rbp),%eax
cmp    $0x79,%eax
jne    11db <main+0xab>
mov    -0x14(%rbp),%edx
lea    0xe5e(%rip),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <get_next_prime@plt>
mov    %eax,-0x14(%rbp)
jmp    1151 <main+0x21>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x59,0x7(%rsp)
mov    $0x2,%ebp
lea    0xea4(%rip),%r14
lea    0xeb9(%rip),%r15
lea    0x7(%rsp),%rbx
lea    0xeb1(%rip),%r12
lea    0xeb1(%rip),%r13
jmp    1186 <main+0x46>
nopl   0x0(%rax,%rax,1)
and    $0xdf,%al
cmp    $0x4e,%al
je     11c9 <main+0x89>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movzbl 0x7(%rsp),%eax
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x59,%cl
jne    1180 <main+0x40>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
call   1050 <get_next_prime@plt>
mov    %eax,%ebp
movzbl 0x7(%rsp),%eax
jmp    1180 <main+0x40>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Show the next prime? (Y/N):\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [7 x i8] c"%s%d\0A\0A\00"
@.str.3 = [26 x i8] c"The next prime number is \00"
@.str.4 = [9 x i8] c"Bye :) \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2, i32* %6
store i8 89, i8* %7
br label %8
8: ; preds = %33, %2
%9 = load i8, i8* %7
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 78
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8, i8* %7
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 110
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ false, %8 ], [ %15, %12 ]
br i1 %17, label %18, label %34
18: ; preds = %16
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%21 = load i8, i8* %7
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 89
br i1 %23, label %28, label %24
24: ; preds = %18
%25 = load i8, i8* %7
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 121
br i1 %27, label %28, label %33
28: ; preds = %24, %18
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %6
%32 = call i32 @get_next_prime(i32 %31)
store i32 %32, i32* %6
br label %33
33: ; preds = %28, %24
br label %8
34: ; preds = %16
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Show the next prime? (Y/N):\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [7 x i8] c"%s%d\0A\0A\00"
@.str.3 = [26 x i8] c"The next prime number is \00"
@str = [8 x i8] c"Bye :) \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
store i8 89, i8* %3
br label %4
4: ; preds = %2, %15
%5 = phi i32 [ %17, %15 ], [ 2, %2 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%8 = load i8, i8* %3
%9 = and i8 %8, -33
%10 = icmp eq i8 %9, 89
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %5)
%13 = call i32 @get_next_prime(i32 %5)
%14 = load i8, i8* %3
br label %15
15: ; preds = %4, %11
%16 = phi i8 [ %14, %11 ], [ %8, %4 ]
%17 = phi i32 [ %13, %11 ], [ %5, %4 ]
%18 = and i8 %16, -33
%19 = icmp eq i8 %18, 78
br i1 %19, label %20, label %4
20: ; preds = %15
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
ret i32 0
}