#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__ malloc(int);
int sqrt(int);
int *constructRectangle(int area, int *returnSize) {
  int *ret = (int *)malloc(sizeof(int) * 2);
  int upper = sqrt(area);
  int i;
  *returnSize = 2;
  for (i = upper; i > 0; i--) {
    if (area % i == 0) {
      ret[0] = area / i;
      ret[1] = i;
      return ret;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<constructRectangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    11ab <constructRectangle+0x8b>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x28(%rbp)
cmp    $0x0,%edx
jne    1198 <constructRectangle+0x78>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x28(%rbp)
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <constructRectangle+0x93>
jmp    119d <constructRectangle+0x7d>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1158 <constructRectangle+0x38>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constructRectangle>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1040 <sqrt@plt>
movl   $0x2,(%rbx)
test   %eax,%eax
jle    116c <constructRectangle+0x4c>
mov    %eax,%ecx
nopl   0x0(%rax)
mov    %ebp,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1165 <constructRectangle+0x45>
lea    -0x1(%rcx),%eax
cmp    $0x1,%ecx
mov    %eax,%ecx
jg     1150 <constructRectangle+0x30>
jmp    116c <constructRectangle+0x4c>
mov    %eax,(%r14)
mov    %ecx,0x4(%r14)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32* @constructRectangle(i32 %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%9 = call i64 @malloc(i32 8)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %6
%11 = load i32, i32* %4
%12 = call i32 @sqrt(i32 %11)
store i32 %12, i32* %7
%13 = load i32*, i32** %5
store i32 2, i32* %13
%14 = load i32, i32* %7
store i32 %14, i32* %8
br label %15
15: ; preds = %34, %2
%16 = load i32, i32* %8
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %37
18: ; preds = %15
%19 = load i32, i32* %4
%20 = load i32, i32* %8
%21 = srem i32 %19, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %18
%24 = load i32, i32* %4
%25 = load i32, i32* %8
%26 = sdiv i32 %24, %25
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i64 0
store i32 %26, i32* %28
%29 = load i32, i32* %8
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 1
store i32 %29, i32* %31
%32 = load i32*, i32** %6
store i32* %32, i32** %3
br label %39
33: ; preds = %18
br label %34
34: ; preds = %33
%35 = load i32, i32* %8
%36 = add nsw i32 %35, -1
store i32 %36, i32* %8
br label %15
37: ; preds = %15
%38 = load i32*, i32** %6
store i32* %38, i32** %3
br label %39
39: ; preds = %37, %23
%40 = load i32*, i32** %3
ret i32* %40
}

LLVM IR (-O2):
define i32* @constructRectangle(i32 %0, i32* nocapture writeonly %1) {
%3 = tail call i64 @malloc(i32 8)
%4 = inttoptr i64 %3 to i32*
%5 = tail call i32 @sqrt(i32 %0)
store i32 2, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %2, %14
%8 = phi i32 [ %15, %14 ], [ %5, %2 ]
%9 = srem i32 %0, %8
%10 = sdiv i32 %0, %8
%11 = icmp eq i32 %9, 0
br i1 %11, label %12, label %14
12: ; preds = %7
store i32 %10, i32* %4
%13 = getelementptr inbounds i32, i32* %4, i64 1
store i32 %8, i32* %13
br label %17
14: ; preds = %7
%15 = add nsw i32 %8, -1
%16 = icmp sgt i32 %8, 1
br i1 %16, label %7, label %17
17: ; preds = %14, %2, %12
ret i32* %4
}