#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*/ server;
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*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
scalar_t__ strstr(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
void print_out(char *channel, char *buf) {
  static char outfile[256], server[256], buft[18];
  FILE *out = NULL;
  time_t t = time(0);
  if (channel)
    snprintf(server, sizeof(server), "-!- %s", channel);
  if (strstr(buf, server))
    channel = "";
  create_filepath(outfile, sizeof(outfile), channel, "out");
  if (!(out = fopen(outfile, "a")))
    return;
  if (channel && channel[0] != '\0')
    add_channel(channel);
  strftime(buft, sizeof(buft), "%F %R", 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   1080 <time@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11e9 <print_out+0x49>
mov    -0x8(%rbp),%rcx
lea    0x2fa8(%rip),%rdi
mov    $0x100,%esi
lea    0xe1c(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x2f8c(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     120e <print_out+0x6e>
lea    0xe0f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    0x2e67(%rip),%rdi
mov    $0x100,%esi
lea    0xde2(%rip),%rcx
call   1050 <create_filepath@plt>
lea    0x2e4f(%rip),%rdi
lea    0xdd3(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1250 <print_out+0xb0>
jmp    12bb <print_out+0x11b>
cmpq   $0x0,-0x8(%rbp)
je     1274 <print_out+0xd4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1274 <print_out+0xd4>
mov    -0x8(%rbp),%rdi
call   1090 <add_channel@plt>
lea    -0x1c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%ecx
lea    0x2ffa(%rip),%rdi
mov    $0x12,%esi
lea    0xd7b(%rip),%rdx
call   10a0 <strftime@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
lea    0xd6d(%rip),%rsi
lea    0x2fd3(%rip),%rdx
call   1070 <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,%r15
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
test   %r15,%r15
je     11da <print_out+0x3a>
lea    0x2fba(%rip),%rdi
lea    0xe33(%rip),%rdx
mov    $0x100,%esi
mov    %r15,%rcx
call   1060 <snprintf@plt>
lea    0x2f9f(%rip),%rsi
mov    %r14,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
lea    0xe26(%rip),%rbx
cmove  %r15,%rbx
lea    0x2e82(%rip),%r15
lea    0xe02(%rip),%rcx
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1050 <create_filepath@plt>
lea    0xdef(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1282 <print_out+0xe2>
mov    %rax,%r15
test   %rbx,%rbx
je     123e <print_out+0x9e>
cmpb   $0x0,(%rbx)
je     123e <print_out+0x9e>
mov    %rbx,%rdi
call   1090 <add_channel@plt>
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0x3031(%rip),%rbx
lea    0xdb7(%rip),%rdx
mov    %rbx,%rdi
mov    $0x12,%esi
mov    %eax,%ecx
call   10a0 <strftime@plt>
lea    0xda7(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1070 <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 [18 x i8] zeroinitializer
@.str = [7 x i8] c"-!- %s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"out\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [6 x i8] c"%F %R\00"
@.str.5 = [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 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.server, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %2
%14 = load i8*, i8** %4
%15 = call i64 @strstr(i8* %14, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.server, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %18
18: ; preds = %17, %13
%19 = load i8*, i8** %3
%20 = call i32 @create_filepath(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.outfile, i64 0, i64 0), i32 256, i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = 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.3, i64 0, i64 0))
store i32* %21, i32** %5
%22 = icmp ne i32* %21, null
br i1 %22, label %24, label %23
23: ; preds = %18
br label %44
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = call i32 @add_channel(i8* %34)
br label %36
36: ; preds = %33, %27, %24
%37 = call i32 @localtime(i32* %6)
%38 = call i32 @strftime(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @print_out.buft, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = load i32*, i32** %5
%40 = load i8*, i8** %4
%41 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @print_out.buft, i64 0, i64 0), i8* %40)
%42 = load i32*, i32** %5
%43 = call i32 @fclose(i32* %42)
br label %44
44: ; preds = %36, %23
ret void
}

LLVM IR (-O2):
@print_out.outfile = internal global [256 x i8] zeroinitializer
@print_out.server = internal global [256 x i8] zeroinitializer
@print_out.buft = internal global [18 x i8] zeroinitializer
@.str = [7 x i8] c"-!- %s\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"out\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [6 x i8] c"%F %R\00"
@.str.5 = [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 = icmp eq i8* %0, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.server, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %2
%10 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.server, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%13 = tail call i32 @create_filepath(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @print_out.outfile, i64 0, i64 0), i32 256, i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = 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.3, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %28, label %16
16: ; preds = %9
%17 = icmp eq i8* %12, null
br i1 %17, label %23, label %18
18: ; preds = %16
%19 = load i8, i8* %12
%20 = icmp eq i8 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @add_channel(i8* %12)
br label %23
23: ; preds = %21, %18, %16
%24 = call i32 @localtime(i32* %3)
%25 = call i32 @strftime(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @print_out.buft, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @print_out.buft, i64 0, i64 0), i8* %1)
%27 = call i32 @fclose(i32* %14)
br label %28
28: ; preds = %9, %23
ret void
}