#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 EXIT_SUCCESS;
int /*<<< orphan*/ printPrimePairs(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, int *);
int main() {
  int input;
  printf("\nEnter a positive integer <= 100000 and the program");
  printf("\nwill print all prime pairs upto that value: ");
  while (scanf("%d", &input)) {
    if (input < 0 || input > 100000) {
      printf("\nThe integer must be positive and <= 100000\n");
      printf("Enter a positive integer <= 100000: ");
      continue;
    } else {
      printf("\n");
      printPrimePairs(input);
      printf("\n");
      break;
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     11c5 <main+0x95>
cmpl   $0x0,-0x8(%rbp)
jl     1188 <main+0x58>
cmpl   $0x186a0,-0x8(%rbp)
jle    11a5 <main+0x75>
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
jmp    1157 <main+0x27>
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <printPrimePairs@plt>
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
lea    0xec9(%rip),%rdi
call   1050 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
test   %rax,%rax
je     11e9 <main+0x99>
lea    0xefd(%rip),%r14
lea    0xed1(%rip),%r15
lea    0xec7(%rip),%r12
lea    0x4(%rsp),%rbx
cmpl   $0x186a1,0x4(%rsp)
jb     11cc <main+0x7c>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
jmp    11e9 <main+0x99>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%edi
call   1070 <printPrimePairs@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [52 x i8] c"\0AEnter a positive integer <= 100000 and the program\00"
@.str.1 = [46 x i8] c"\0Awill print all prime pairs upto that value: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [45 x i8] c"\0AThe integer must be positive and <= 100000\0A\00"
@.str.4 = [37 x i8] c"Enter a positive integer <= 100000: \00"
@.str.5 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %14, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 100000
br i1 %13, label %14, label %17
14: ; preds = %11, %8
%15 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %5
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call i32 @printPrimePairs(i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %17, %5
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}

LLVM IR (-O2):
@.str = [52 x i8] c"\0AEnter a positive integer <= 100000 and the program\00"
@.str.1 = [46 x i8] c"\0Awill print all prime pairs upto that value: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [37 x i8] c"Enter a positive integer <= 100000: \00"
@EXIT_SUCCESS = global i32 0
@str = [44 x i8] c"\0AThe integer must be positive and <= 100000\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %0, %10
%8 = load i32, i32* %1
%9 = icmp ugt i32 %8, 100000
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%13 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %20, label %7
15: ; preds = %7
%16 = call i32 @putchar(i32 10)
%17 = load i32, i32* %1
%18 = call i32 @printPrimePairs(i32 %17)
%19 = call i32 @putchar(i32 10)
br label %20
20: ; preds = %10, %0, %15
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}