#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 */
typedef int uint64_t;

/* Variables and functions */
int arc4random();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recover_hi(int);
int recover_lo(int, int /*<<< orphan*/);
int main() {
  uint64_t secret_key = (((uint64_t)arc4random()) << 32) ^ arc4random();
  uint64_t kk1 = recover_lo(secret_key, recover_hi(secret_key));
  uint64_t kk2 = kk1 ^ 0x8000000000000000ULL;
  printf(
      "The real key is %016llx, the key candidates are %016llx, %016llx     ",
      secret_key, kk1, kk2);
  if ((kk1 == secret_key) || (kk2 == secret_key))
    printf("SUCCESS!\n");
  else
    printf("FAILURE!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <arc4random@plt>
mov    $0x20,%ecx
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <arc4random@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
xor    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <recover_hi@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1050 <recover_lo@plt>
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11cf <main+0x8f>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11e2 <main+0xa2>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f0 <main+0xb0>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <arc4random@plt>
xor    %eax,%eax
call   1040 <arc4random@plt>
call   1070 <recover_hi@plt>
mov    %eax,%esi
call   1060 <recover_lo@plt>
lea    0xe8e(%rip),%rdi
mov    %eax,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [70 x i8] c"The real key is %016llx, the key candidates are %016llx, %016llx \00"
@.str.1 = [10 x i8] c"SUCCESS!\0A\00"
@.str.2 = [10 x i8] c"FAILURE!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @arc4random()
%6 = shl i32 %5, 32
%7 = call i32 (...) @arc4random()
%8 = xor i32 %6, %7
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = load i32, i32* %2
%11 = call i32 @recover_hi(i32 %10)
%12 = call i32 @recover_lo(i32 %9, i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = xor i64 %14, -9223372036854775808
%16 = trunc i64 %15 to i32
store i32 %16, i32* %4
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = icmp eq i32 %21, %22
br i1 %23, label %28, label %24
24: ; preds = %0
%25 = load i32, i32* %4
%26 = load i32, i32* %2
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24, %0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [70 x i8] c"The real key is %016llx, the key candidates are %016llx, %016llx \00"
@str = [9 x i8] c"FAILURE!\00"
define i32 @main() {
%1 = tail call i32 (...) @arc4random()
%2 = tail call i32 (...) @arc4random()
%3 = tail call i32 @recover_hi(i32 poison)
%4 = tail call i32 @recover_lo(i32 poison, i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i32 poison, i32 %4, i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}