#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*/ appaserver_error_starting_argv_append_file(int, char **,
                                                              char *);
char *date_get_now_hhmm(int /*<<< orphan*/);
char *date_get_now_yyyy_mm_dd(int /*<<< orphan*/);
int /*<<< orphan*/ date_get_utc_offset();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void appaserver_error_login_name_append_file(int argc, char **argv,
                                             char *application_name,
                                             char *login_name) {
  FILE *f;
  if (!login_name || !*login_name) {
    appaserver_error_starting_argv_append_file(argc, argv, application_name);
    return;
  }
  f = appaserver_error_open_append_file(application_name);
  fprintf(f, "%s %s %s: %s", date_get_now_yyyy_mm_dd(date_get_utc_offset()),
          date_get_now_hhmm(date_get_utc_offset()), login_name, argv[0]);
  while (--argc)
    fprintf(f, " %s", *++argv);
  fprintf(f, "\n");
  fclose(f);
}


x86 assembly (clang, -O0):
<appaserver_error_login_name_append_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119f <appaserver_error_login_name_append_file+0x2f>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11b4 <appaserver_error_login_name_append_file+0x44>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1080 <appaserver_error_starting_argv_append_file@plt>
jmp    1264 <appaserver_error_login_name_append_file+0xf4>
mov    -0x18(%rbp),%rdi
call   1070 <appaserver_error_open_append_file@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1030 <date_get_now_yyyy_mm_dd@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1090 <date_get_now_hhmm@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
mov    -0x20(%rbp),%r8
mov    -0x10(%rbp),%rax
mov    (%rax),%r9
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
je     1249 <appaserver_error_login_name_append_file+0xd9>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    120d <appaserver_error_login_name_append_file+0x9d>
mov    -0x28(%rbp),%rdi
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<appaserver_error_login_name_append_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
test   %rcx,%rcx
je     124c <appaserver_error_login_name_append_file+0xcc>
mov    %rcx,%rbp
cmpb   $0x0,(%rcx)
je     124c <appaserver_error_login_name_append_file+0xcc>
mov    %rdx,%rdi
call   1080 <appaserver_error_open_append_file@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   1030 <date_get_now_yyyy_mm_dd@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1050 <date_get_utc_offset@plt>
mov    %eax,%edi
call   10a0 <date_get_now_hhmm@plt>
mov    (%r14),%r9
lea    0xe26(%rip),%rsi
mov    %r13,%rdi
mov    %r12,%rdx
mov    %rax,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    $0x1,%r15d
je     1229 <appaserver_error_login_name_append_file+0xa9>
mov    %r15d,%ebp
mov    $0x1,%ebx
lea    0xe07(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdx
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1210 <appaserver_error_login_name_append_file+0x90>
mov    $0xa,%edi
mov    %r13,%rsi
call   1060 <fputc@plt>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
mov    %r15d,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <appaserver_error_starting_argv_append_file@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%s %s %s: %s\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @appaserver_error_login_name_append_file(i32 %0, i8** %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i8*, i8** %8
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = load i8*, i8** %8
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %12, %4
%17 = load i32, i32* %5
%18 = load i8**, i8*** %6
%19 = load i8*, i8** %7
%20 = call i32 @appaserver_error_starting_argv_append_file(i32 %17, i8** %18, i8* %19)
br label %49
21: ; preds = %12
%22 = load i8*, i8** %7
%23 = call i32* @appaserver_error_open_append_file(i8* %22)
store i32* %23, i32** %9
%24 = load i32*, i32** %9
%25 = call i32 (...) @date_get_utc_offset()
%26 = call i8* @date_get_now_yyyy_mm_dd(i32 %25)
%27 = call i32 (...) @date_get_utc_offset()
%28 = call i8* @date_get_now_hhmm(i32 %27)
%29 = load i8*, i8** %8
%30 = load i8**, i8*** %6
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %28, i8* %29, i8* %32)
br label %34
34: ; preds = %38, %21
%35 = load i32, i32* %5
%36 = add nsw i32 %35, -1
store i32 %36, i32* %5
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %34
%39 = load i32*, i32** %9
%40 = load i8**, i8*** %6
%41 = getelementptr inbounds i8*, i8** %40, i32 1
store i8** %41, i8*** %6
%42 = load i8*, i8** %41
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %34
44: ; preds = %34
%45 = load i32*, i32** %9
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32*, i32** %9
%48 = call i32 @fclose(i32* %47)
br label %49
49: ; preds = %44, %16
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s %s %s: %s\00"
@.str.1 = [4 x i8] c" %s\00"
define void @appaserver_error_login_name_append_file(i32 %0, i8** %1, i8* %2, i8* %3) {
%5 = icmp eq i8* %3, null
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6, %4
%10 = tail call i32 @appaserver_error_starting_argv_append_file(i32 %0, i8** %1, i8* %2)
br label %32
11: ; preds = %6
%12 = tail call i32* @appaserver_error_open_append_file(i8* %2)
%13 = tail call i32 (...) @date_get_utc_offset()
%14 = tail call i8* @date_get_now_yyyy_mm_dd(i32 %13)
%15 = tail call i32 (...) @date_get_utc_offset()
%16 = tail call i8* @date_get_now_hhmm(i32 %15)
%17 = load i8*, i8** %1
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %16, i8* %3, i8* %17)
%19 = add nsw i32 %0, -1
%20 = icmp eq i32 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %11, %21
%22 = phi i32 [ %27, %21 ], [ %19, %11 ]
%23 = phi i8** [ %24, %21 ], [ %1, %11 ]
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = add nsw i32 %22, -1
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %21
29: ; preds = %21, %11
%30 = tail call i32 @fputc(i32 10, i32* %12)
%31 = tail call i32 @fclose(i32* %12)
br label %32
32: ; preds = %29, %9
ret void
}