#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 */
scalar_t__ EOF;
scalar_t__ fflush(int /*<<< orphan*/ *);
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
scalar_t__ get_time(char *);
int log_append(FILE *fp, char *line) {
  char current_time[20];
  if (fp == NULL || line == NULL)
    return -1;
  if (get_time(current_time) < 0)
    return -1;
  if (fputs(current_time, fp) == EOF)
    return EOF;
  if (fputs(line, fp) == EOF)
    return EOF;
  if (fflush(fp) == EOF)
    return EOF;
  else
    return 0;
}


x86 assembly (clang, -O0):
<log_append>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1156 <log_append+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1162 <log_append+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <log_append+0xe1>
lea    -0x30(%rbp),%rdi
call   1040 <get_time@plt>
cmp    $0x0,%rax
jge    1181 <log_append+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <log_append+0xe1>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fputs@plt>
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%rax
jne    11b0 <log_append+0x80>
mov    0x2e43(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1211 <log_append+0xe1>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fputs@plt>
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%rax
jne    11df <log_append+0xaf>
mov    0x2e14(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1211 <log_append+0xe1>
mov    -0x10(%rbp),%rdi
call   1050 <fflush@plt>
mov    0x2df9(%rip),%rcx
cmp    (%rcx),%rax
jne    120a <log_append+0xda>
mov    0x2de9(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1211 <log_append+0xe1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_append>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     119f <log_append+0x6f>
mov    %rsi,%r15
test   %rsi,%rsi
je     119f <log_append+0x6f>
mov    %rdi,%r14
mov    %rsp,%rdi
call   1040 <get_time@plt>
test   %rax,%rax
js     119f <log_append+0x6f>
mov    %rsp,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
mov    0x2e79(%rip),%r12
cmp    (%r12),%rax
je     1186 <log_append+0x56>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <fputs@plt>
cmp    (%r12),%rax
jne    118b <log_append+0x5b>
mov    %rax,%rbx
jmp    119f <log_append+0x6f>
mov    %r14,%rdi
call   1050 <fflush@plt>
mov    (%r12),%rbx
xor    %ecx,%ecx
cmp    %rbx,%rax
cmovne %ecx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @log_append(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [20 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
%7 = load i32*, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store i32 -1, i32* %3
br label %45
13: ; preds = %9
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%15 = call i64 @get_time(i8* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 -1, i32* %3
br label %45
18: ; preds = %13
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%20 = load i32*, i32** %4
%21 = call i64 @fputs(i8* %19, i32* %20)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i64, i64* @EOF
%26 = trunc i64 %25 to i32
store i32 %26, i32* %3
br label %45
27: ; preds = %18
%28 = load i8*, i8** %5
%29 = load i32*, i32** %4
%30 = call i64 @fputs(i8* %28, i32* %29)
%31 = load i64, i64* @EOF
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i64, i64* @EOF
%35 = trunc i64 %34 to i32
store i32 %35, i32* %3
br label %45
36: ; preds = %27
%37 = load i32*, i32** %4
%38 = call i64 @fflush(i32* %37)
%39 = load i64, i64* @EOF
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = load i64, i64* @EOF
%43 = trunc i64 %42 to i32
store i32 %43, i32* %3
br label %45
44: ; preds = %36
store i32 0, i32* %3
br label %45
45: ; preds = %44, %41, %33, %24, %17, %12
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@EOF = global i64 0
define i32 @log_append(i32* %0, i8* %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32* %0, null
%6 = icmp eq i8* %1, null
%7 = or i1 %5, %6
br i1 %7, label %29, label %8
8: ; preds = %2
%9 = call i64 @get_time(i8* %4)
%10 = icmp slt i64 %9, 0
br i1 %10, label %29, label %11
11: ; preds = %8
%12 = call i64 @fputs(i8* %4, i32* %0)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = trunc i64 %12 to i32
br label %29
17: ; preds = %11
%18 = call i64 @fputs(i8* %1, i32* %0)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = trunc i64 %18 to i32
br label %29
23: ; preds = %17
%24 = call i64 @fflush(i32* %0)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
%27 = trunc i64 %25 to i32
%28 = select i1 %26, i32 %27, i32 0
br label %29
29: ; preds = %23, %8, %2, %21, %15
%30 = phi i32 [ %16, %15 ], [ %22, %21 ], [ -1, %2 ], [ -1, %8 ], [ %28, %23 ]
ret i32 %30
}