#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 */
char EOF;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main(void) {
  int lim = 0;
  int square = 0;
  char c = '\0';
  while (1) {
    printf("Please enter a number, lower than which,"
           "you want all even squares listed: \n");
    if (scanf("%d", &lim) != 1) {
      fprintf(stderr, "Input invalid. Please try again.\n");
      while ((c = getchar()) != '\n' && c != EOF)
        continue;
      continue;
    }
    break;
  }
  while ((c = getchar()) != '\n' && c != EOF)
    continue;
  int i = 2;
  while (square < lim) {
    square = i * i;
    i += 2;
    printf("%d\n", square);
  }
  getchar();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     11e8 <main+0xa8>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x15(%rbp)
je     11ce <main+0x8e>
movsbl -0xd(%rbp),%eax
mov    0x2e25(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11de <main+0x9e>
jmp    11e3 <main+0xa3>
jmp    119d <main+0x5d>
jmp    1161 <main+0x21>
jmp    11ed <main+0xad>
jmp    11f2 <main+0xb2>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x16(%rbp)
je     1223 <main+0xe3>
movsbl -0xd(%rbp),%eax
mov    0x2dd0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
test   $0x1,%al
jne    1233 <main+0xf3>
jmp    1238 <main+0xf8>
jmp    11f2 <main+0xb2>
movl   $0x2,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1274 <main+0x134>
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <main+0xff>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11f9 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11a6 <main+0x56>
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%al
jne    1190 <main+0x40>
cmpl   $0x0,0x4(%rsp)
jle    11da <main+0x8a>
mov    $0x2,%ebp
lea    0xe6c(%rip),%r14
nopl   0x0(%rax)
mov    %ebp,%ebx
imul   %ebp,%ebx
add    $0x2,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0x4(%rsp),%ebx
jl     11c0 <main+0x70>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dd8(%rip),%r13
lea    0xdfc(%rip),%r14
mov    0x2dda(%rip),%rbp
lea    0xe14(%rip),%r15
lea    0xde4(%rip),%r12
lea    0x4(%rsp),%rbx
jmp    124c <main+0xfc>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1190 <main+0x40>
mov    0x0(%r13),%edi
mov    %r14,%rsi
call   1060 <fprintf@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1230 <main+0xe0>
cmp    0x0(%rbp),%al
jne    1260 <main+0x110>
jmp    1230 <main+0xe0>

LLVM IR (-O0):
@.str = [76 x i8] c"Please enter a number, lower than which,you want all even squares listed: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"Input invalid. Please try again.\0A\00"
@EOF = global i8 0
@.str.3 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i8 0, i8* %4
br label %6
6: ; preds = %0, %26
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %25, %10
%14 = call signext i8 (...) @getchar()
store i8 %14, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = load i8, i8* @EOF
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %19, %21
br label %23
23: ; preds = %17, %13
%24 = phi i1 [ false, %13 ], [ %22, %17 ]
br i1 %24, label %25, label %26
25: ; preds = %23
br label %13
26: ; preds = %23
br label %6
27: ; preds = %6
br label %28
28: ; preds = %27
br label %29
29: ; preds = %41, %28
%30 = call signext i8 (...) @getchar()
store i8 %30, i8* %4
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = load i8, i8* @EOF
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %35, %37
br label %39
39: ; preds = %33, %29
%40 = phi i1 [ false, %29 ], [ %38, %33 ]
br i1 %40, label %41, label %42
41: ; preds = %39
br label %29
42: ; preds = %39
store i32 2, i32* %5
br label %43
43: ; preds = %47, %42
%44 = load i32, i32* %3
%45 = load i32, i32* %2
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %55
47: ; preds = %43
%48 = load i32, i32* %5
%49 = load i32, i32* %5
%50 = mul nsw i32 %48, %49
store i32 %50, i32* %3
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 2
store i32 %52, i32* %5
%53 = load i32, i32* %3
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %53)
br label %43
55: ; preds = %43
%56 = call signext i8 (...) @getchar()
%57 = load i32, i32* @EXIT_SUCCESS
ret i32 %57
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"Input invalid. Please try again.\0A\00"
@EOF = global i8 0
@.str.3 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [75 x i8] c"Please enter a number, lower than which,you want all even squares listed: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 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 = icmp eq i32 %4, 1
br i1 %5, label %6, label %11
6: ; preds = %7, %0
br label %20
7: ; preds = %14
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %6, label %11
11: ; preds = %0, %7
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %14, %11
%15 = call signext i8 (...) @getchar()
%16 = icmp ne i8 %15, 10
%17 = load i8, i8* @EOF
%18 = icmp ne i8 %15, %17
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %14, label %7
20: ; preds = %6, %20
%21 = call signext i8 (...) @getchar()
%22 = icmp ne i8 %21, 10
%23 = load i8, i8* @EOF
%24 = icmp ne i8 %21, %23
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %20, label %26
26: ; preds = %20
%27 = load i32, i32* %1
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %26, %29
%30 = phi i32 [ %32, %29 ], [ 2, %26 ]
%31 = mul nsw i32 %30, %30
%32 = add nuw nsw i32 %30, 2
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%34 = load i32, i32* %1
%35 = icmp slt i32 %31, %34
br i1 %35, label %29, label %36
36: ; preds = %29, %26
%37 = call signext i8 (...) @getchar()
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}