#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double pow(double, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  printf("Perfect squares up to 1000:\n");
  double current_number = 1;
  double current_square = 1;
  do {
    printf("%.0f\n", current_square);
    current_square = pow(++current_number, 2);
  } while (current_square < 1000);
  printf("\n");
  exit(EXIT_SUCCESS);
}


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)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xeb3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe77(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe5e(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     116e <main+0x3e>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeba(%rip),%rdi
call   1040 <puts@plt>
movsd  0xe97(%rip),%xmm0
lea    0xea0(%rip),%rbx
movsd  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe68(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1060 <pow@plt>
movsd  0xe58(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1180 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Perfect squares up to 1000:\0A\00"
@.str.1 = [6 x i8] c"%.0f\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store double 1.000000e+00, double* %6
store double 1.000000e+00, double* %7
br label %9
9: ; preds = %15, %2
%10 = load double, double* %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %10)
%12 = load double, double* %6
%13 = fadd double %12, 1.000000e+00
store double %13, double* %6
%14 = call double @pow(double %13, i32 2)
store double %14, double* %7
br label %15
15: ; preds = %9
%16 = load double, double* %7
%17 = fcmp olt double %16, 1.000000e+03
br i1 %17, label %9, label %18
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_SUCCESS
%21 = call i32 @exit(i32 %20)
unreachable
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%.0f\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [28 x i8] c"Perfect squares up to 1000:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %4, %2
%5 = phi double [ 1.000000e+00, %2 ], [ %8, %4 ]
%6 = phi double [ 1.000000e+00, %2 ], [ %9, %4 ]
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %6)
%8 = fadd double %5, 1.000000e+00
%9 = tail call double @pow(double %8, i32 2)
%10 = fcmp olt double %9, 1.000000e+03
br i1 %10, label %4, label %11
11: ; preds = %4
%12 = tail call i32 @putchar(i32 10)
%13 = load i32, i32* @EXIT_SUCCESS
%14 = tail call i32 @exit(i32 %13)
unreachable
}