#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 */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ isqrt(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int64_t p;
  int n;
  printf("Integer square root for numbers 0 to 65:\n");
  for (n = 0; n <= 65; n++) {
    printf("%lld ", isqrt(n));
  }
  printf("\n\n");
  printf("Integer square roots of odd powers of 7 from 1 to 21:\n");
  printf(" n |              7 ^ n | isqrt(7 ^ n)\n");
  p = 7;
  for (n = 1; n <= 21; n += 2, p *= 49) {
    printf("%2d | %18lld | %12lld\n", n, p, isqrt(p));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x41,-0xc(%rbp)
jg     1174 <main+0x54>
mov    -0xc(%rbp),%edi
call   1040 <isqrt@plt>
mov    %eax,%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1144 <main+0x24>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x7,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x15,-0xc(%rbp)
jg     11f5 <main+0xd5>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <isqrt@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    %eax,%ecx
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
imul   $0x31,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11ac <main+0x8c>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x42,%ebp
jne    1150 <main+0x20>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7,%edi
call   1050 <isqrt@plt>
lea    0xe66(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x7,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x157,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x157,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x41a7,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x41a7,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xc90f7,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0xc90f7,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x267bf47,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x267bf47,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x75db9c97,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
mov    $0x75db9c97,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x8f08f8e7,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
mov    $0x8f08f8e7,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x60b7a437,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
mov    $0x60b7a437,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x83266e87,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
mov    $0x83266e87,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1a5b27d7,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0x13,%esi
mov    $0x1a5b27d7,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xb72a027,%edi
call   1050 <isqrt@plt>
mov    %rbx,%rdi
mov    $0x15,%esi
mov    $0xb72a027,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Integer square root for numbers 0 to 65:\0A\00"
@.str.1 = [6 x i8] c"%lld \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [55 x i8] c"Integer square roots of odd powers of 7 from 1 to 21:\0A\00"
@.str.4 = [40 x i8] c" n | 7 ^ n | isqrt(7 ^ n)\0A\00"
@.str.5 = [23 x i8] c"%2d | %18lld | %12lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 65
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @isqrt(i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
store i32 7, i32* %2
store i32 1, i32* %3
br label %19
19: ; preds = %28, %15
%20 = load i32, i32* %3
%21 = icmp sle i32 %20, 21
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = load i32, i32* %2
%26 = call i32 @isqrt(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 %24, i32 %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 2
store i32 %30, i32* %3
%31 = load i32, i32* %2
%32 = mul nsw i32 %31, 49
store i32 %32, i32* %2
br label %19
33: ; preds = %19
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%lld \00"
@.str.5 = [23 x i8] c"%2d | %18lld | %12lld\0A\00"
@str = [41 x i8] c"Integer square root for numbers 0 to 65:\00"
@str.6 = [2 x i8] c"\0A\00"
@str.7 = [54 x i8] c"Integer square roots of odd powers of 7 from 1 to 21:\00"
@str.8 = [39 x i8] c" n | 7 ^ n | isqrt(7 ^ n)\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %6, %2 ]
%4 = tail call i32 @isqrt(i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = add nuw nsw i32 %3, 1
%7 = icmp eq i32 %6, 66
br i1 %7, label %8, label %2
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.7, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0))
%12 = tail call i32 @isqrt(i32 7)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 7, i32 %12)
%14 = tail call i32 @isqrt(i32 343)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 3, i32 343, i32 %14)
%16 = tail call i32 @isqrt(i32 16807)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 5, i32 16807, i32 %16)
%18 = tail call i32 @isqrt(i32 823543)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 7, i32 823543, i32 %18)
%20 = tail call i32 @isqrt(i32 40353607)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 9, i32 40353607, i32 %20)
%22 = tail call i32 @isqrt(i32 1977326743)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 11, i32 1977326743, i32 %22)
%24 = tail call i32 @isqrt(i32 -1895237401)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 13, i32 -1895237401, i32 %24)
%26 = tail call i32 @isqrt(i32 1622647863)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 15, i32 1622647863, i32 %26)
%28 = tail call i32 @isqrt(i32 -2094633337)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 17, i32 -2094633337, i32 %28)
%30 = tail call i32 @isqrt(i32 442181591)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 19, i32 442181591, i32 %30)
%32 = tail call i32 @isqrt(i32 192061479)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 21, i32 192061479, i32 %32)
ret i32 0
}