#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, ...);
int /*<<< orphan*/ scanf(char *, int *);
int sqrt(int);
int main() {
  int i, k;
  printf("请输入一个小于%d的整数i：", 1000);
  scanf("%d", &i);
  while (i > 1000) {
    printf("输入的数不合法，请重新输入一个小于%d的整数i：", 1000);
    scanf("%d", &i);
  }
  k = sqrt(i);
  printf("%d的平方根的整数部分为%d", i, k);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3e8,-0x8(%rbp)
jle    1197 <main+0x67>
lea    0xeaf(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1162 <main+0x32>
mov    -0x8(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
mov    $0x3e8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf35(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%edi
cmp    $0x3e9,%edi
jl     11a6 <main+0x76>
lea    0xeb5(%rip),%r14
lea    0xf11(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x3e8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%edi
cmp    $0x3e8,%edi
jg     1180 <main+0x50>
call   1050 <sqrt@plt>
mov    0xc(%rsp),%esi
lea    0xeb2(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E5\B0\8F\E4\BA\8E%d\E7\9A\84\E6\95\B4\E6\95\B0i\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [67 x i8] c"\E8\BE\93\E5\85\A5\E7\9A\84\E6\95\B0\E4\B8\8D\E5\90\88\E6\B3\95\EF\BC\8C\E8\AF\B7\E9\87\8D\E6\96\B0\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E5\B0\8F\E4\BA\8E%d\E7\9A\84\E6\95\B4\E6\95\B0i\EF\BC\9A\00"
@.str.3 = [35 x i8] c"%d\E7\9A\84\E5\B9\B3\E6\96\B9\E6\A0\B9\E7\9A\84\E6\95\B4\E6\95\B0\E9\83\A8\E5\88\86\E4\B8\BA%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 1000)
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 1000
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.2, i64 0, i64 0), i32 1000)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %6
12: ; preds = %6
%13 = load i32, i32* %2
%14 = call i32 @sqrt(i32 %13)
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E5\B0\8F\E4\BA\8E%d\E7\9A\84\E6\95\B4\E6\95\B0i\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [67 x i8] c"\E8\BE\93\E5\85\A5\E7\9A\84\E6\95\B0\E4\B8\8D\E5\90\88\E6\B3\95\EF\BC\8C\E8\AF\B7\E9\87\8D\E6\96\B0\E8\BE\93\E5\85\A5\E4\B8\80\E4\B8\AA\E5\B0\8F\E4\BA\8E%d\E7\9A\84\E6\95\B4\E6\95\B0i\EF\BC\9A\00"
@.str.3 = [35 x i8] c"%d\E7\9A\84\E5\B9\B3\E6\96\B9\E6\A0\B9\E7\9A\84\E6\95\B4\E6\95\B0\E9\83\A8\E5\88\86\E4\B8\BA%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 1000)
%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 = icmp sgt i32 %5, 1000
br i1 %6, label %7, label %12
7: ; preds = %0, %7
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.2, i64 0, i64 0), i32 1000)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 1000
br i1 %11, label %7, label %12
12: ; preds = %7, %0
%13 = phi i32 [ %5, %0 ], [ %10, %7 ]
%14 = call i32 @sqrt(i32 %13)
%15 = load i32, i32* %1
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %14)
ret i32 0
}