#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sqrt(float);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int n;
  int i;
  if (argc < 2) {
    fprintf(stderr, "usage: genisqrt <range>\n");
    return 0;
  }
  n = strtol(argv[1], NULL, 0);
  printf("/* warning: do not edit this file.\n");
  printf(" * it has been automatically generated by genisqrt */\n\n");
  printf("#ifndef ISQRT_H\n");
  printf("#define ISQRT_H\n\n");
  printf("#define ISQRT_LEN %d\n", n);
  printf("static const int isqrt[%d] = {0", n);
  for (i = 1; i < n; i++)
    printf(",%d", (int)sqrt((float)i));
  printf("};\n");
  printf("#endif /* ISQRT_H */\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)
cmpl   $0x2,-0x8(%rbp)
jge    1181 <main+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124f <main+0x10f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122c <main+0xec>
cvtsi2ssl -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f8 <main+0xb8>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     1173 <main+0x23>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1227 <main+0xd7>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %eax,%ebx
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf10(%rip),%rdi
call   1030 <puts@plt>
lea    0xe60(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebx
jl     120f <main+0xbf>
mov    $0x1,%ebp
lea    0xe6c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
call   1070 <sqrt@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    11f0 <main+0xa0>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"usage: genisqrt <range>\0A\00"
@.str.1 = [36 x i8] c"/* warning: do not edit this file.\0A\00"
@.str.2 = [56 x i8] c" * it has been automatically generated by genisqrt */\0A\0A\00"
@.str.3 = [17 x i8] c"#ifndef ISQRT_H\0A\00"
@.str.4 = [18 x i8] c"#define ISQRT_H\0A\0A\00"
@.str.5 = [22 x i8] c"#define ISQRT_LEN %d\0A\00"
@.str.6 = [32 x i8] c"static const int isqrt[%d] = {0\00"
@.str.7 = [4 x i8] c",%d\00"
@.str.8 = [4 x i8] c"};\0A\00"
@.str.9 = [22 x i8] c"#endif /* ISQRT_H */\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %42
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strtol(i8* %16, i32* null, i32 0)
store i32 %17, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %24)
store i32 1, i32* %7
br label %26
26: ; preds = %36, %13
%27 = load i32, i32* %7
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = load i32, i32* %7
%32 = sitofp i32 %31 to float
%33 = call i64 @sqrt(float %32)
%34 = trunc i64 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %26
39: ; preds = %26
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %42
42: ; preds = %39, %10
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"usage: genisqrt <range>\0A\00"
@.str.5 = [22 x i8] c"#define ISQRT_LEN %d\0A\00"
@.str.6 = [32 x i8] c"static const int isqrt[%d] = {0\00"
@.str.7 = [4 x i8] c",%d\00"
@str = [35 x i8] c"/* warning: do not edit this file.\00"
@str.10 = [55 x i8] c" * it has been automatically generated by genisqrt */\0A\00"
@str.11 = [16 x i8] c"#ifndef ISQRT_H\00"
@str.12 = [17 x i8] c"#define ISQRT_H\0A\00"
@str.13 = [3 x i8] c"};\00"
@str.14 = [21 x i8] c"#endif /* ISQRT_H */\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %29
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strtol(i8* nocapture %9, i32* null, i32 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.10, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %10)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %10)
%17 = icmp sgt i32 %10, 1
br i1 %17, label %18, label %26
18: ; preds = %7, %18
%19 = phi i32 [ %24, %18 ], [ 1, %7 ]
%20 = sitofp i32 %19 to float
%21 = tail call i64 @sqrt(float %20)
%22 = trunc i64 %21 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i32 %19, 1
%25 = icmp eq i32 %24, %10
br i1 %25, label %26, label %18
26: ; preds = %18, %7
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.13, i64 0, i64 0))
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0))
br label %29
29: ; preds = %26, %4
ret i32 0
}