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

/* Variables and functions */
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char const *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
char *szCat(char const *, char const *, char const *, char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void ERRORMESSAGE(char const *s1, char const *s2, char const *s3,
                  char const *s4) {
  time_t t = time(NULL);
  FILE *fp = fopen("errcmaes.err", "a");
  if (!fp) {
    printf("\nFATAL ERROR: %s\n", s2 ? szCat(s1, s2, s3, s4) : s1);
    printf("cmaes_t could not open file 'errcmaes.err'.");
    printf("\n *** CMA-ES ABORTED *** ");
    fflush(stdout);
    exit(1);
  }
  fprintf(fp, "\n -- %s %s\n", asctime(localtime(&t)),
          s2 ? szCat(s1, s2, s3, s4) : s1);
  fclose(fp);
}


x86 assembly (clang, -O0):
<ERRORMESSAGE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,-0x24(%rbp)
lea    0xe35(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    125d <ERRORMESSAGE+0xbd>
cmpq   $0x0,-0x10(%rbp)
je     120f <ERRORMESSAGE+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1070 <szCat@plt>
mov    %rax,-0x38(%rbp)
jmp    1217 <ERRORMESSAGE+0x77>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1050 <asctime@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12a2 <ERRORMESSAGE+0x102>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1070 <szCat@plt>
mov    %rax,-0x50(%rbp)
jmp    12aa <ERRORMESSAGE+0x10a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rcx
lea    0xdaa(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERRORMESSAGE>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,0x4(%rsp)
lea    0xe37(%rip),%rdi
lea    0xe3d(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1236 <ERRORMESSAGE+0x96>
mov    %rax,%rbx
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1050 <asctime@plt>
mov    %rax,%rbp
test   %r13,%r13
je     120a <ERRORMESSAGE+0x6a>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1070 <szCat@plt>
mov    %rax,%r12
lea    0xe56(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r13,%r13
je     124f <ERRORMESSAGE+0xaf>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1070 <szCat@plt>
mov    %rax,%r12
lea    0xdb9(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdba(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdd8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"errcmaes.err\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [18 x i8] c"\0AFATAL ERROR: %s\0A\00"
@.str.3 = [44 x i8] c"cmaes_t could not open file 'errcmaes.err'.\00"
@.str.4 = [26 x i8] c"\0A *** CMA-ES ABORTED *** \00"
@stdout = global i32 0
@.str.5 = [12 x i8] c"\0A -- %s %s\0A\00"
define void @ERRORMESSAGE(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = call i32 @time(i32* null)
store i32 %11, i32* %9
%12 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %10
%13 = load i32*, i32** %10
%14 = icmp ne i32* %13, null
br i1 %14, label %34, label %15
15: ; preds = %4
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = call i8* @szCat(i8* %19, i8* %20, i8* %21, i8* %22)
br label %26
24: ; preds = %15
%25 = load i8*, i8** %5
br label %26
26: ; preds = %24, %18
%27 = phi i8* [ %23, %18 ], [ %25, %24 ]
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = call i32 @fflush(i32 %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %4
%35 = load i32*, i32** %10
%36 = call i32 @localtime(i32* %9)
%37 = call i8* @asctime(i32 %36)
%38 = load i8*, i8** %6
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = load i8*, i8** %5
%42 = load i8*, i8** %6
%43 = load i8*, i8** %7
%44 = load i8*, i8** %8
%45 = call i8* @szCat(i8* %41, i8* %42, i8* %43, i8* %44)
br label %48
46: ; preds = %34
%47 = load i8*, i8** %5
br label %48
48: ; preds = %46, %40
%49 = phi i8* [ %45, %40 ], [ %47, %46 ]
%50 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %37, i8* %49)
%51 = load i32*, i32** %10
%52 = call i32 @fclose(i32* %51)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"errcmaes.err\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [18 x i8] c"\0AFATAL ERROR: %s\0A\00"
@.str.3 = [44 x i8] c"cmaes_t could not open file 'errcmaes.err'.\00"
@.str.4 = [26 x i8] c"\0A *** CMA-ES ABORTED *** \00"
@stdout = global i32 0
@.str.5 = [12 x i8] c"\0A -- %s %s\0A\00"
define void @ERRORMESSAGE(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %22
10: ; preds = %4
%11 = icmp eq i8* %1, null
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i8* @szCat(i8* %0, i8* %1, i8* %2, i8* %3)
br label %14
14: ; preds = %10, %12
%15 = phi i8* [ %13, %12 ], [ %0, %10 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32, i32* @stdout
%20 = tail call i32 @fflush(i32 %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %4
%23 = call i32 @localtime(i32* %5)
%24 = call i8* @asctime(i32 %23)
%25 = icmp eq i8* %1, null
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = call i8* @szCat(i8* %0, i8* %1, i8* %2, i8* %3)
br label %28
28: ; preds = %22, %26
%29 = phi i8* [ %27, %26 ], [ %0, %22 ]
%30 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %24, i8* %29)
%31 = call i32 @fclose(i32* %8)
ret void
}