#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long double const, int,
                           int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int printFileDecay(int x, int y, int z, const long double time) {
  char buf[256];
  snprintf(buf, sizeof buf, "%s", "SiteDecay.txt");
  FILE *DecayOut;
  if ((DecayOut = fopen(buf, "a")) == NULL) {
    printf("ERROR! unable to open SiteDecay.txt file\n");
    return -1;
  } else {
    fprintf(DecayOut, "%Lg %d %d %d\n", time, x, y, z);
    fclose(DecayOut);
  }
  return 0;
}


x86 assembly (clang, -O0):
<printFileDecay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
fldt   0x10(%rbp)
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
fstpt  -0x20(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
lea    0xe83(%rip),%rdx
lea    0xe7f(%rip),%rcx
call   1050 <snprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    11c5 <printFileDecay+0x75>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <printFileDecay+0xad>
mov    -0x128(%rbp),%rdi
fldt   -0x20(%rbp)
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe58(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x128(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFileDecay>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x128,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebx
fldt   0x150(%rsp)
fstpt  0x14(%rsp)
lea    0xe89(%rip),%rdx
lea    0xe85(%rip),%rcx
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x100,%esi
call   1050 <snprintf@plt>
lea    0xe7a(%rip),%rsi
mov    %rbp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11d1 <printFileDecay+0x81>
mov    %rax,%rbp
fldt   0x14(%rsp)
fstpt  (%rsp)
lea    0xe5e(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1060 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11e2 <printFileDecay+0x92>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"SiteDecay.txt\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [42 x i8] c"ERROR! unable to open SiteDecay.txt file\0A\00"
@.str.4 = [14 x i8] c"%Lg %d %d %d\0A\00"
define i32 @printFileDecay(i32 %0, i32 %1, i32 %2, x86_fp80 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca x86_fp80
%10 = alloca [256 x i8]
%11 = alloca i32*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store x86_fp80 %3, x86_fp80* %9
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%13 = call i32 @snprintf(i8* %12, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %15, i32** %11
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %5
br label %29
19: ; preds = %4
%20 = load i32*, i32** %11
%21 = load x86_fp80, x86_fp80* %9
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), x86_fp80 %21, i32 %22, i32 %23, i32 %24)
%26 = load i32*, i32** %11
%27 = call i32 @fclose(i32* %26)
br label %28
28: ; preds = %19
store i32 0, i32* %5
br label %29
29: ; preds = %28, %17
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"SiteDecay.txt\00"
@.str.2 = [2 x i8] c"a\00"
@.str.4 = [14 x i8] c"%Lg %d %d %d\0A\00"
@str = [41 x i8] c"ERROR! unable to open SiteDecay.txt file\00"
define i32 @printFileDecay(i32 %0, i32 %1, i32 %2, x86_fp80 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call i32 @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %15
12: ; preds = %4
%13 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), x86_fp80 %3, i32 %0, i32 %1, i32 %2)
%14 = call i32 @fclose(i32* %8)
br label %15
15: ; preds = %12, %10
%16 = phi i32 [ -1, %10 ], [ 0, %12 ]
ret i32 %16
}