#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*/ find_three_squares(unsigned long);
int /*<<< orphan*/ find_two_squares(unsigned long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  unsigned long int number;
  unsigned long int quad1 = 0, quad2 = 0, quad3 = 0;
  unsigned long int i;
  int choice;
  short found_flag = 0;
  printf("Enter the number: ");
  scanf("%lu", &number);
  printf("How many square numbers? [2/3/4 = all]: ");
  scanf("%d", &choice);
  if (choice != 2 && choice != 3) {
    choice = 4;
  }
  switch (choice) {
  case 2:
    find_two_squares(number);
    break;
  case 3:
    find_three_squares(number);
    break;
  case 4:
    find_two_squares(number);
    find_three_squares(number);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movw   $0x0,-0x36(%rbp)
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x2,-0x34(%rbp)
je     11c4 <main+0x84>
cmpl   $0x3,-0x34(%rbp)
je     11c4 <main+0x84>
movl   $0x4,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x2,%eax
je     11fa <main+0xba>
jmp    11d8 <main+0x98>
mov    -0x3c(%rbp),%eax
sub    $0x3,%eax
je     1208 <main+0xc8>
jmp    11e9 <main+0xa9>
mov    -0x3c(%rbp),%eax
sub    $0x4,%eax
je     1216 <main+0xd6>
jmp    1228 <main+0xe8>
mov    -0x10(%rbp),%rdi
call   1050 <find_two_squares@plt>
jmp    1228 <main+0xe8>
mov    -0x10(%rbp),%rdi
call   1030 <find_three_squares@plt>
jmp    1228 <main+0xe8>
mov    -0x10(%rbp),%rdi
call   1050 <find_two_squares@plt>
mov    -0x10(%rbp),%rdi
call   1030 <find_three_squares@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
and    $0xfffffffe,%ecx
cmp    $0x2,%ecx
jne    11a6 <main+0x66>
cmp    $0x3,%eax
je     11b8 <main+0x78>
cmp    $0x2,%eax
jne    11c2 <main+0x82>
mov    0x10(%rsp),%rdi
call   1050 <find_two_squares@plt>
jmp    11c2 <main+0x82>
movl   $0x4,0xc(%rsp)
mov    0x10(%rsp),%rdi
call   1050 <find_two_squares@plt>
mov    0x10(%rsp),%rdi
call   1030 <find_three_squares@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter the number: \00"
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [41 x i8] c"How many square numbers? [2/3/4 = all]: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i16
store i32 0, i32* %1
store i64 0, i64* %3
store i64 0, i64* %4
store i64 0, i64* %5
store i16 0, i16* %8
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 4, i32* %7
br label %19
19: ; preds = %18, %15, %0
%20 = load i32, i32* %7
switch i32 %20, label %32 [
i32 2, label %21
i32 3, label %24
i32 4, label %27
]
21: ; preds = %19
%22 = load i64, i64* %2
%23 = call i32 @find_two_squares(i64 %22)
br label %32
24: ; preds = %19
%25 = load i64, i64* %2
%26 = call i32 @find_three_squares(i64 %25)
br label %32
27: ; preds = %19
%28 = load i64, i64* %2
%29 = call i32 @find_two_squares(i64 %28)
%30 = load i64, i64* %2
%31 = call i32 @find_three_squares(i64 %30)
br label %32
32: ; preds = %19, %27, %24, %21
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter the number: \00"
@.str.1 = [4 x i8] c"%lu\00"
@.str.2 = [41 x i8] c"How many square numbers? [2/3/4 = all]: \00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i32
%3 = bitcast i64* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = and i32 %9, -2
%11 = icmp eq i32 %10, 2
br i1 %11, label %17, label %12
12: ; preds = %0
store i32 4, i32* %2
%13 = load i64, i64* %1
%14 = call i32 @find_two_squares(i64 %13)
%15 = load i64, i64* %1
%16 = call i32 @find_three_squares(i64 %15)
br label %24
17: ; preds = %0
switch i32 %9, label %24 [
i32 2, label %18
i32 3, label %21
]
18: ; preds = %17
%19 = load i64, i64* %1
%20 = call i32 @find_two_squares(i64 %19)
br label %24
21: ; preds = %17
%22 = load i64, i64* %1
%23 = call i32 @find_three_squares(i64 %22)
br label %24
24: ; preds = %17, %12, %21, %18
ret i32 0
}