#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*/ outfile;
typedef int /*<<< orphan*/ buft;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ add_channel(char *);
int /*<<< orphan*/ create_filepath(char *, int, char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void print_out(char *channel, char *buf) {
  static char outfile[256], server[256], buft[20];
  FILE *out = NULL;
  time_t t = time(0);
  create_filepath(outfile, sizeof(outfile), channel, "out");
  if (!(out = fopen(outfile, "a")))
    return;
  if (channel && channel[0])
    add_channel(channel);
  strftime(buft, sizeof(buft), "%F %T", localtime(&t));
  fprintf(out, "%s %s\n", buft, buf);
  fclose(out);
}


x86 assembly (clang, -O0):
<print_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdx
lea    0x2ec3(%rip),%rdi
mov    $0x100,%esi
lea    0xe47(%rip),%rcx
call   1050 <create_filepath@plt>
lea    0x2eab(%rip),%rdi
lea    0xe38(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11e4 <print_out+0x64>
jmp    124f <print_out+0xcf>
cmpq   $0x0,-0x8(%rbp)
je     1208 <print_out+0x88>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1208 <print_out+0x88>
mov    -0x8(%rbp),%rdi
call   1080 <add_channel@plt>
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%ecx
lea    0x3056(%rip),%rdi
mov    $0x14,%esi
lea    0xde0(%rip),%rdx
call   1090 <strftime@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
lea    0xdd2(%rip),%rsi
lea    0x302f(%rip),%rdx
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_out>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0x2ecf(%rip),%r15
lea    0xe58(%rip),%rcx
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1050 <create_filepath@plt>
lea    0xe45(%rip),%rsi
mov    %r15,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1225 <print_out+0xa5>
mov    %rax,%r15
test   %rbx,%rbx
je     11e1 <print_out+0x61>
cmpb   $0x0,(%rbx)
je     11e1 <print_out+0x61>
mov    %rbx,%rdi
call   1080 <add_channel@plt>
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0x2f7e(%rip),%rbx
lea    0xe0d(%rip),%rdx
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   1090 <strftime@plt>
lea    0xdfd(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@print_out.outfile = internal global [256 x i8] zeroinitializer
@print_out.server = internal global [256 x i8] zeroinitializer
@print_out.buft = internal global [20 x i8] zeroinitializer
@.str = [4 x i8] c"out\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [6 x i8] c"%F %T\00"
@.str.3 = [7 x i8] c"%s %s\0A\00"
define void @print_out(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32* null, i32** %5
%7 = call i32 @time(i32 0)
store i32 %7, i32* %6
%8 = load i8*, i8** %3
%9 = call i32 @create_filepath(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.outfile, i64 0, i64 0), i32 256, i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = call i32* @fopen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.outfile, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %5
%11 = icmp ne i32* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
br label %33
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = call i32 @add_channel(i8* %23)
br label %25
25: ; preds = %22, %16, %13
%26 = call i32 @localtime(i32* %6)
%27 = call i32 @strftime(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @print_out.buft, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %5
%29 = load i8*, i8** %4
%30 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @print_out.buft, i64 0, i64 0), i8* %29)
%31 = load i32*, i32** %5
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %25, %12
ret void
}

LLVM IR (-O2):
@print_out.outfile = internal global [256 x i8] zeroinitializer
@print_out.buft = internal global [20 x i8] zeroinitializer
@.str = [4 x i8] c"out\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [6 x i8] c"%F %T\00"
@.str.3 = [7 x i8] c"%s %s\0A\00"
define void @print_out(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @time(i32 0)
store i32 %5, i32* %3
%6 = tail call i32 @create_filepath(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.outfile, i64 0, i64 0), i32 256, i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.outfile, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %21, label %9
9: ; preds = %2
%10 = icmp eq i8* %0, null
br i1 %10, label %16, label %11
11: ; preds = %9
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @add_channel(i8* %0)
br label %16
16: ; preds = %14, %11, %9
%17 = call i32 @localtime(i32* %3)
%18 = call i32 @strftime(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @print_out.buft, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @print_out.buft, i64 0, i64 0), i8* %1)
%20 = call i32 @fclose(i32* %7)
br label %21
21: ; preds = %2, %16
ret void
}