#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i;
  printf("请输入一个数:");
  scanf("%d", &i);
  if (i > 0 && i <= 2) {
    printf("输入不合理\n");
  } else {
    for (int j = 2; j <= i; j++) {
      if (i % j == 0) {
        printf("不是质数\n");
        break;
      } else {
        printf("是质数\n");
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1170 <main+0x50>
cmpl   $0x2,-0x8(%rbp)
jg     1170 <main+0x50>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
jmp    11b5 <main+0x95>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b0 <main+0x90>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11a4 <main+0x84>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <main+0x90>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    11b5 <main+0x95>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x2,%ecx
jae    1163 <main+0x33>
lea    0xec3(%rip),%rdi
jmp    117c <main+0x4c>
cmp    $0x2,%eax
jl     1181 <main+0x51>
test   $0x1,%al
lea    0xea6(%rip),%rax
lea    0xea2(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E6\95\B0:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\E8\BE\93\E5\85\A5\E4\B8\8D\E5\90\88\E7\90\86\0A\00"
@.str.3 = [14 x i8] c"\E4\B8\8D\E6\98\AF\E8\B4\A8\E6\95\B0\0A\00"
@.str.4 = [11 x i8] c"\E6\98\AF\E8\B4\A8\E6\95\B0\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %31
13: ; preds = %8, %0
store i32 2, i32* %3
br label %14
14: ; preds = %27, %13
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %14
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = srem i32 %19, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %30
25: ; preds = %18
%26 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %30
27: ; No predecessors!
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %14
30: ; preds = %25, %23, %14
br label %31
31: ; preds = %30, %11
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [20 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E6\95\B0:\00"
@.str.1 = [3 x i8] c"%d\00"
@str = [10 x i8] c"\E6\98\AF\E8\B4\A8\E6\95\B0\00"
@str.5 = [13 x i8] c"\E4\B8\8D\E6\98\AF\E8\B4\A8\E6\95\B0\00"
@str.6 = [16 x i8] c"\E8\BE\93\E5\85\A5\E4\B8\8D\E5\90\88\E7\90\86\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 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 = add i32 %5, -1
%7 = icmp ult i32 %6, 2
br i1 %7, label %14, label %8
8: ; preds = %0
%9 = icmp sgt i32 %5, 1
br i1 %9, label %10, label %17
10: ; preds = %8
%11 = and i32 %5, 1
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0)
br label %14
14: ; preds = %10, %0
%15 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0), %0 ], [ %13, %10 ]
%16 = call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %14, %8
ret i32 0
}