#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int, int,
                           long double);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int printToEndPtFile(char *FileName, int x, int y, int z, int ChargeId,
                     long double GlobalTime) {
  char buf[256];
  snprintf(buf, sizeof buf, "%s%s", FileName, ".endpt");
  FILE *EndPtOut;
  if ((EndPtOut = fopen(buf, "a")) == NULL) {
    printf("ERROR unable to open file!\n");
    exit(1);
  }
  fprintf(EndPtOut, "%d %d %d %d %Le\n", x, y, z, ChargeId, GlobalTime);
  fclose(EndPtOut);
  return 0;
}


x86 assembly (clang, -O0):
<printToEndPtFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
fldt   0x10(%rbp)
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
fstpt  -0x30(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x100,%esi
lea    0xe67(%rip),%rdx
lea    0xe65(%rip),%r8
call   1050 <snprintf@plt>
lea    -0x130(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x138(%rbp)
cmp    $0x0,%rax
jne    11df <printToEndPtFile+0x7f>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x138(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe27(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x138(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printToEndPtFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x120,%rsp
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,%rcx
fldt   0x150(%rsp)
fstpt  0x14(%rsp)
lea    0xe71(%rip),%rdx
lea    0xe6f(%rip),%r8
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <snprintf@plt>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     11fa <printToEndPtFile+0x9a>
mov    %rax,%rbx
fldt   0x14(%rsp)
fstpt  (%rsp)
lea    0xe41(%rip),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    %r14d,%r9d
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

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

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