#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 isprime(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  printf("Please input the value of n:\n");
  scanf("%d", &n);
  switch (isprime(n)) {
  case 0:
    printf("not prime\n");
    break;
  case 1:
    printf("is prime\n");
    break;
  }
  return 0;
}


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    0xecc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <isprime@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
test   %eax,%eax
je     1186 <main+0x56>
jmp    1175 <main+0x45>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     1197 <main+0x67>
jmp    11a3 <main+0x73>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    11a3 <main+0x73>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
call   1040 <isprime@plt>
test   %eax,%eax
je     1169 <main+0x39>
cmp    $0x1,%eax
jne    1175 <main+0x45>
lea    0xeb9(%rip),%rdi
jmp    1170 <main+0x40>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Please input the value of n:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"not prime\0A\00"
@.str.3 = [10 x i8] c"is prime\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 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), i32* %2)
%5 = load i32, i32* %2
%6 = call i32 @isprime(i32 %5)
switch i32 %6, label %11 [
i32 0, label %7
i32 1, label %9
]
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %11
11: ; preds = %0, %9, %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [29 x i8] c"Please input the value of n:\00"
@str.4 = [9 x i8] c"is prime\00"
@str.5 = [10 x i8] c"not prime\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 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), i32* %1)
%5 = load i32, i32* %1
%6 = call i32 @isprime(i32 %5)
switch i32 %6, label %11 [
i32 0, label %8
i32 1, label %7
]
7: ; preds = %0
br label %8
8: ; preds = %0, %7
%9 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0), %0 ]
%10 = call i32 @puts(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %8, %0
ret i32 0
}