#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 ft_sqrt(int);
int printf(char *, ...);
scalar_t__ sqrt(int);
int main(void) {
  int i;
  int result;
  int actual;
  i = -50;
  while (i < 500) {
    result = ft_sqrt(i);
    actual = (int)sqrt(i);
    if (actual * actual != i)
      actual = 0;
    printf("sqrt of %i; result: %i, actual: %i\n", i, result, actual);
    if (result != actual)
      return printf("FAKE AND GAY ✗\n");
    ++i;
  }
  return printf("GOES ✓\n");
  ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffce,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jge    11c7 <main+0x97>
mov    -0x8(%rbp),%edi
call   1030 <ft_sqrt@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1180 <main+0x50>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     11b9 <main+0x89>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0x4(%rbp)
jmp    11d8 <main+0xa8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffce,%ebp
lea    0xeb9(%rip),%r15
lea    0xed6(%rip),%r14
lea    0xee1(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1030 <ft_sqrt@plt>
mov    %eax,%r12d
mov    %ebp,%edi
call   1050 <sqrt@plt>
mov    %rax,%rbx
imul   %eax,%eax
cmp    %eax,%ebp
je     117d <main+0x4d>
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,%r12d
jne    11a1 <main+0x71>
add    $0x1,%ebp
cmp    $0x1f4,%ebp
jne    1160 <main+0x30>
mov    %r13,%r14
mov    %r14,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"sqrt of %i; result: %i, actual: %i\0A\00"
@.str.1 = [18 x i8] c"FAKE AND GAY \E2\9C\97\0A\00"
@.str.2 = [10 x i8] c"GOES \E2\9C\93\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 -50, i32* %2
br label %5
5: ; preds = %30, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 500
br i1 %7, label %8, label %33
8: ; preds = %5
%9 = load i32, i32* %2
%10 = call i32 @ft_sqrt(i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = call i64 @sqrt(i32 %11)
%13 = trunc i64 %12 to i32
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = load i32, i32* %4
%16 = mul nsw i32 %14, %15
%17 = load i32, i32* %2
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %8
store i32 0, i32* %4
br label %20
20: ; preds = %19, %8
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 %29, i32* %1
br label %35
30: ; preds = %20
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %5
33: ; preds = %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 %34, i32* %1
br label %35
35: ; preds = %33, %28
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [36 x i8] c"sqrt of %i; result: %i, actual: %i\0A\00"
@.str.1 = [18 x i8] c"FAKE AND GAY \E2\9C\97\0A\00"
@.str.2 = [10 x i8] c"GOES \E2\9C\93\0A\00"
define i32 @main() {
br label %4
1: ; preds = %4
%2 = add nsw i32 %5, 1
%3 = icmp eq i32 %2, 500
br i1 %3, label %14, label %4
4: ; preds = %0, %1
%5 = phi i32 [ -50, %0 ], [ %2, %1 ]
%6 = tail call i32 @ft_sqrt(i32 %5)
%7 = tail call i64 @sqrt(i32 %5)
%8 = trunc i64 %7 to i32
%9 = mul nsw i32 %8, %8
%10 = icmp eq i32 %9, %5
%11 = select i1 %10, i32 %8, i32 0
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6, i32 %11)
%13 = icmp eq i32 %6, %11
br i1 %13, label %1, label %14
14: ; preds = %1, %4
%15 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %1 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15)
ret i32 %16
}