#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char const *,
                           char *);
char *strerror(int);
int /*<<< orphan*/ strncpy(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void log_error(const char *msg, int error, FILE *log) {
  time_t ltime = time(NULL);
  char timestamp[26];
  bzero(timestamp, 26);
  strncpy(timestamp, ctime(&ltime), 24);
  fprintf(log, "%s\t%s : %s\n", timestamp, msg, strerror(error));
  fflush(log);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<log_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x1a,%esi
call   1080 <bzero@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
mov    $0x18,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0xc(%rbp),%edi
call   10a0 <strerror@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    %rax,%r8
lea    0xdfc(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fflush@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<log_error>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %rdi,%r14
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1a,%esi
call   1080 <bzero@plt>
lea    0xc(%rsp),%rdi
call   1040 <ctime@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    $0x18,%edx
call   1030 <strncpy@plt>
mov    %r15d,%edi
call   10a0 <strerror@plt>
lea    0xe28(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %rax,%r8
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <fflush@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%s\09%s : %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @log_error(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [26 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = call i32 @time(i32* null)
store i32 %9, i32* %7
%10 = getelementptr inbounds [26 x i8], [26 x i8]* %8, i64 0, i64 0
%11 = call i32 @bzero(i8* %10, i32 26)
%12 = getelementptr inbounds [26 x i8], [26 x i8]* %8, i64 0, i64 0
%13 = call i32 @ctime(i32* %7)
%14 = call i32 @strncpy(i8* %12, i32 %13, i32 24)
%15 = load i32*, i32** %6
%16 = getelementptr inbounds [26 x i8], [26 x i8]* %8, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = call i8* @strerror(i32 %18)
%20 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i8* %19)
%21 = load i32*, i32** %6
%22 = call i32 @fflush(i32* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s\09%s : %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @log_error(i8* %0, i32 %1, i32* nocapture %2) {
%4 = alloca i32
%5 = alloca [26 x i8]
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %4
%8 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%9 = call i32 @bzero(i8* %8, i32 26)
%10 = call i32 @ctime(i32* %4)
%11 = call i32 @strncpy(i8* %8, i32 %10, i32 24)
%12 = call i8* @strerror(i32 %1)
%13 = call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %0, i8* %12)
%14 = call i32 @fflush(i32* %2)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
}