#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 *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, ...);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void __attribute__((constructor)) init(void) {
  do {
    time_t tt = time(NULL);
    FILE *ff = fopen("/tmp/hotpatchtest.log", "a");
    if (ff) {
      fprintf(ff, "Dll opened. %s\n", ctime(&tt));
      if (0 > 0)
        fprintf(ff, "Data: %s Len: %d\n", (char *)NULL, (size_t)0);
      fclose(ff);
    }
  } while (0);
}


x86 assembly (clang, -O0):
<init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x4(%rbp)
lea    0xe95(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b5 <init+0x65>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x4(%rbp),%rdi
call   1040 <ctime@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rdx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11ba <init+0x6a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xe99(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11a1 <init+0x51>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"/tmp/hotpatchtest.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [16 x i8] c"Dll opened. %s\0A\00"
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @init, i8* null }]
define void @init() {
%1 = alloca i32
%2 = alloca i32*
br label %3
3: ; preds = %0
%4 = call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = load i32*, i32** %2
%10 = call i8* @ctime(i32* %1)
%11 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = load i32*, i32** %2
%13 = call i32 @fclose(i32* %12)
br label %14
14: ; preds = %8, %3
br label %15
15: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"/tmp/hotpatchtest.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [16 x i8] c"Dll opened. %s\0A\00"
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @init, i8* null }]
define void @init() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = call i8* @ctime(i32* %1)
%8 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i32 @fclose(i32* %4)
br label %10
10: ; preds = %6, %0
ret void
}