#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 */
scalar_t__ floor(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ sqrt(long long);
int main(void) {
  int numHouse = 2;
  int numFound = 0;
  while (numFound < 10) {
    long long triangleNum = ((long long)numHouse * (numHouse + 1)) >> 1;
    long long squareRoot = (long long)floor(sqrt(triangleNum));
    if (squareRoot * squareRoot == triangleNum) {
      int houseId = squareRoot;
      printf("%10d%10d\n", houseId, numHouse);
      numFound++;
    }
    numHouse++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11c7 <main+0x97>
movslq -0x8(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
sar    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1050 <floor@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
imul   -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11b9 <main+0x89>
mov    -0x20(%rbp),%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r12d,%r12d
mov    $0x2,%r15d
lea    0xeb8(%rip),%r14
jmp    1159 <main+0x29>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%r15
cmp    $0xa,%r12d
jge    1195 <main+0x65>
lea    0x1(%r15),%rbp
mov    %rbp,%rbx
imul   %r15,%rbx
shr    %rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1050 <floor@plt>
mov    %rax,%rcx
imul   %rax,%rcx
cmp    %rbx,%rcx
jne    1150 <main+0x20>
mov    %r14,%rdi
mov    %eax,%esi
mov    %r15d,%edx
call   1030 <printf@plt>
add    $0x1,%r12d
jmp    1150 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%10d%10d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %34, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %37
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = mul nsw i64 %12, %15
%17 = ashr i64 %16, 1
store i64 %17, i64* %4
%18 = load i64, i64* %4
%19 = call i32 @sqrt(i64 %18)
%20 = call i64 @floor(i32 %19)
store i64 %20, i64* %5
%21 = load i64, i64* %5
%22 = load i64, i64* %5
%23 = mul nsw i64 %21, %22
%24 = load i64, i64* %4
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %10
%27 = load i64, i64* %5
%28 = trunc i64 %27 to i32
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = load i32, i32* %2
%31 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %30)
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %34
34: ; preds = %26, %10
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %7
37: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"%10d%10d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %16
%2 = phi i64 [ 2, %0 ], [ %4, %16 ]
%3 = phi i32 [ 0, %0 ], [ %17, %16 ]
%4 = add nuw nsw i64 %2, 1
%5 = mul nuw nsw i64 %4, %2
%6 = lshr i64 %5, 1
%7 = tail call i32 @sqrt(i64 %6)
%8 = tail call i64 @floor(i32 %7)
%9 = mul nsw i64 %8, %8
%10 = icmp eq i64 %9, %6
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = trunc i64 %8 to i32
%13 = trunc i64 %2 to i32
%14 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = add nsw i32 %3, 1
br label %16
16: ; preds = %11, %1
%17 = phi i32 [ %15, %11 ], [ %3, %1 ]
%18 = icmp slt i32 %17, 10
br i1 %18, label %1, label %19
19: ; preds = %16
ret i32 0
}