#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*/ *appaserver_error_open_append_file(char *);
int /*<<< orphan*/ date_get_utc_offset();
char *date_now_hhmmss(int /*<<< orphan*/);
char *date_now_yyyy_mm_dd(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *, char *,
                           ...);
void appaserver_output_error_message(char *application_name, char *message,
                                     char *login_name) {
  FILE *f;
  f = appaserver_error_open_append_file(application_name);
  if (login_name && *login_name) {
    fprintf(f, "%s %s %s: %s\n", date_now_yyyy_mm_dd(date_get_utc_offset()),
            date_now_hhmmss(date_get_utc_offset()), login_name, message);
  } else {
    fprintf(f, "%s %s: %s\n", date_now_yyyy_mm_dd(date_get_utc_offset()),
            date_now_hhmmss(date_get_utc_offset()), message);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<appaserver_output_error_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <appaserver_error_open_append_file@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ea <appaserver_output_error_message+0x8a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ea <appaserver_output_error_message+0x8a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1030 <date_now_yyyy_mm_dd@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1060 <date_now_hhmmss@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
mov    -0x18(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    122f <appaserver_output_error_message+0xcf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1030 <date_now_yyyy_mm_dd@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1060 <date_now_hhmmss@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
mov    -0x10(%rbp),%r8
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<appaserver_output_error_message>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
call   1080 <appaserver_error_open_append_file@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     11be <appaserver_output_error_message+0x5e>
cmpb   $0x0,(%rbx)
je     11be <appaserver_output_error_message+0x5e>
xor    %eax,%eax
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1030 <date_now_yyyy_mm_dd@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1060 <date_now_hhmmss@plt>
lea    0xe5a(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
mov    %rax,%rcx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    11f7 <appaserver_output_error_message+0x97>
xor    %eax,%eax
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1030 <date_now_yyyy_mm_dd@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1060 <date_now_hhmmss@plt>
lea    0xe1f(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %rax,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"%s %s %s: %s\0A\00"
@.str.1 = [11 x i8] c"%s %s: %s\0A\00"
define void @appaserver_output_error_message(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i32* @appaserver_error_open_append_file(i8* %8)
store i32* %9, i32** %7
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %26
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = load i32*, i32** %7
%19 = call i32 (...) @date_get_utc_offset()
%20 = call i8* @date_now_yyyy_mm_dd(i32 %19)
%21 = call i32 (...) @date_get_utc_offset()
%22 = call i8* @date_now_hhmmss(i32 %21)
%23 = load i8*, i8** %6
%24 = load i8*, i8** %5
%25 = call i32 (i32*, i8*, i8*, i8*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %22, i8* %23, i8* %24)
br label %34
26: ; preds = %12, %3
%27 = load i32*, i32** %7
%28 = call i32 (...) @date_get_utc_offset()
%29 = call i8* @date_now_yyyy_mm_dd(i32 %28)
%30 = call i32 (...) @date_get_utc_offset()
%31 = call i8* @date_now_hhmmss(i32 %30)
%32 = load i8*, i8** %5
%33 = call i32 (i32*, i8*, i8*, i8*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %31, i8* %32)
br label %34
34: ; preds = %26, %17
%35 = load i32*, i32** %7
%36 = call i32 @fclose(i32* %35)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s %s %s: %s\0A\00"
@.str.1 = [11 x i8] c"%s %s: %s\0A\00"
define void @appaserver_output_error_message(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32* @appaserver_error_open_append_file(i8* %0)
%5 = icmp eq i8* %2, null
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i32 (...) @date_get_utc_offset()
%11 = tail call i8* @date_now_yyyy_mm_dd(i32 %10)
%12 = tail call i32 (...) @date_get_utc_offset()
%13 = tail call i8* @date_now_hhmmss(i32 %12)
%14 = tail call i32 (i32*, i8*, i8*, i8*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13, i8* %2, i8* %1)
br label %21
15: ; preds = %6, %3
%16 = tail call i32 (...) @date_get_utc_offset()
%17 = tail call i8* @date_now_yyyy_mm_dd(i32 %16)
%18 = tail call i32 (...) @date_get_utc_offset()
%19 = tail call i8* @date_now_hhmmss(i32 %18)
%20 = tail call i32 (i32*, i8*, i8*, i8*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %19, i8* %1)
br label %21
21: ; preds = %15, %9
%22 = tail call i32 @fclose(i32* %4)
ret void
}