int main(int argc, char **argv) {
  int i, np;
  char *sieve;
  int *primes;
  np = prime_sieve(sqrt(600851475143LL), &sieve, &primes);
  for (i = np - 1; i > 0; i--) {
    if (600851475143LL % primes[i] == 0) {
      printf("%d\n", primes[i]);
      break;
    }
  }
  free(sieve);
  free(primes);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xea2(%rip),%xmm0
call   1060 <sqrt@plt>
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x1,%al
call   1050 <prime_sieve@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11de <main+0x9e>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
movslq (%rax,%rcx,4),%rcx
movabs $0x8be589eac7,%rax
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11cb <main+0x8b>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11de <main+0x9e>
jmp    11d0 <main+0x90>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <main+0x3e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movsd  0xec4(%rip),%xmm0
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x1,%al
call   1050 <prime_sieve@plt>
mov    0x8(%rsp),%rdi
mov    %eax,%ecx
movabs $0x8be589eac7,%r8
xchg   %ax,%ax
cmp    $0x2,%ecx
jl     1189 <main+0x59>
movslq -0x4(%rdi,%rcx,4),%rsi
mov    %r8,%rax
xor    %edx,%edx
idiv   %rsi
add    $0xffffffffffffffff,%rcx
test   %rdx,%rdx
jne    1160 <main+0x30>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = bitcast i8** %3 to i8*
%6 = bitcast i32** %4 to i8*
%7 = call i32 (double, i8**, i32**, ...) bitcast (i32 (...)* @prime_sieve to i32 (double, i8**, i32**, ...)*)(double 0x4127A7D432CD8EA3, i8** %3, i32** %4)
%8 = load i32*, i32** %4
%9 = zext i32 %7 to i64
br label %10
10: ; preds = %15, %2
%11 = phi i64 [ %12, %15 ], [ %9, %2 ]
%12 = add nsw i64 %11, -1
%13 = trunc i64 %11 to i32
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = getelementptr inbounds i32, i32* %8, i64 %12
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = srem i64 600851475143, %18
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %10
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %23
23: ; preds = %10, %21
%24 = load i8*, i8** %3
%25 = bitcast i32** %4 to i8**
%26 = load i8*, i8** %25
ret i32 0
}