#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 /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ assert(int);
long open(char *, int /*<<< orphan*/);
int write(long, void *, int);
void fake_out_optimizations(double *x, long bytes) {
  static long fd = -1;
  if (fd == -1)
    assert(fd = open("/dev/null", O_WRONLY));
  assert(write(fd, (void *)x,
               bytes > sizeof(double) ? sizeof(double) : bytes) != -1);
}


x86 assembly (clang, -O0):
<fake_out_optimizations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0xffffffffffffffff,0x2ef0(%rip)
ff
jne    1171 <fake_out_optimizations+0x41>
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
call   1050 <open@plt>
mov    %rax,0x2ece(%rip)
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x2ec0(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x8,-0x10(%rbp)
jbe    119d <fake_out_optimizations+0x6d>
mov    $0x8,%eax
mov    %rax,-0x28(%rbp)
jmp    11a5 <fake_out_optimizations+0x75>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fake_out_optimizations>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2ef7(%rip),%rdi
cmp    $0xffffffffffffffff,%rdi
jne    1171 <fake_out_optimizations+0x41>
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    0xea9(%rip),%rdi
call   1050 <open@plt>
mov    %rax,0x2ed5(%rip)
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x2ec7(%rip),%rdi
cmp    $0x8,%rbx
mov    $0x8,%edx
cmovb  %ebx,%edx
mov    %r14,%rsi
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <assert@plt>

LLVM IR (-O0):
@fake_out_optimizations.fd = internal global i64 -1
@.str = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
define void @fake_out_optimizations(double* %0, i64 %1) {
%3 = alloca double*
%4 = alloca i64
store double* %0, double** %3
store i64 %1, i64* %4
%5 = load i64, i64* @fake_out_optimizations.fd
%6 = icmp eq i64 %5, -1
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* @O_WRONLY
%9 = call i64 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %8)
store i64 %9, i64* @fake_out_optimizations.fd
%10 = trunc i64 %9 to i32
%11 = call i32 @assert(i32 %10)
br label %12
12: ; preds = %7, %2
%13 = load i64, i64* @fake_out_optimizations.fd
%14 = load double*, double** %3
%15 = bitcast double* %14 to i8*
%16 = load i64, i64* %4
%17 = icmp ugt i64 %16, 8
br i1 %17, label %18, label %19
18: ; preds = %12
br label %21
19: ; preds = %12
%20 = load i64, i64* %4
br label %21
21: ; preds = %19, %18
%22 = phi i64 [ 8, %18 ], [ %20, %19 ]
%23 = trunc i64 %22 to i32
%24 = call i32 @write(i64 %13, i8* %15, i32 %23)
%25 = icmp ne i32 %24, -1
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
ret void
}

LLVM IR (-O2):
@fake_out_optimizations.fd = internal unnamed_addr global i64 -1
@.str = [10 x i8] c"/dev/null\00"
@O_WRONLY = global i32 0
define void @fake_out_optimizations(double* nocapture %0, i64 %1) {
%3 = load i64, i64* @fake_out_optimizations.fd
%4 = icmp eq i64 %3, -1
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @O_WRONLY
%7 = tail call i64 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %6)
store i64 %7, i64* @fake_out_optimizations.fd
%8 = trunc i64 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = load i64, i64* @fake_out_optimizations.fd
br label %11
11: ; preds = %5, %2
%12 = phi i64 [ %10, %5 ], [ %3, %2 ]
%13 = bitcast double* %0 to i8*
%14 = icmp ult i64 %1, 8
%15 = select i1 %14, i64 %1, i64 8
%16 = trunc i64 %15 to i32
%17 = tail call i32 @write(i64 %12, i8* %13, i32 %16)
%18 = icmp ne i32 %17, -1
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
ret void
}