#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 scalar_t__ ssize_t;

/* Variables and functions */
scalar_t__ ab_getline(int const, char *const, int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *const);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
ssize_t irc_getline(int const fd, char *const buffer) {
  ssize_t ret;
  char ctime[20];
  time_t stime;
  ret = ab_getline(fd, buffer, 510);
  if (ret > 0 && buffer != NULL && buffer[0] != '\000') {
    stime = time(NULL);
    strftime(ctime, 20, "%Y/%m/%d %H:%M:%S", localtime(&stime));
    fputs(ctime, stdout);
    fputs(" > ", stdout);
    puts(buffer);
  }
  return (ret);
}


x86 assembly (clang, -O0):
<irc_getline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1fe,%edx
call   1060 <ab_getline@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    120e <irc_getline+0xae>
cmpq   $0x0,-0x10(%rbp)
je     120e <irc_getline+0xae>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120e <irc_getline+0xae>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x34(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%ecx
mov    $0x14,%esi
lea    0xe27(%rip),%rdx
call   1080 <strftime@plt>
lea    -0x30(%rbp),%rdi
mov    0x2df7(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
lea    0xe12(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irc_getline>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    $0x1fe,%edx
call   1060 <ab_getline@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     11e5 <irc_getline+0x85>
test   %r14,%r14
jle    11e5 <irc_getline+0x85>
cmpb   $0x0,(%rbx)
je     11e5 <irc_getline+0x85>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe5a(%rip),%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   1080 <strftime@plt>
mov    0x2e1f(%rip),%r12
mov    (%r12),%esi
mov    %r15,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
lea    0xe3a(%rip),%rdi
call   1050 <fputs@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@stdout = global i32 0
@.str.1 = [4 x i8] c" > \00"
define i64 @irc_getline(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [20 x i8]
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i32, i32* %3
%9 = load i8*, i8** %4
%10 = call i64 @ab_getline(i32 %8, i8* %9, i32 510)
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = load i8*, i8** %4
%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 %34
22: ; preds = %16
%23 = call i32 @time(i32* null)
store i32 %23, i32* %7
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%25 = call i32 @localtime(i32* %7)
%26 = call i32 @strftime(i8* %24, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%28 = load i32, i32* @stdout
%29 = call i32 @fputs(i8* %27, i32 %28)
%30 = load i32, i32* @stdout
%31 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i8*, i8** %4
%33 = call i32 @puts(i8* %32)
br label %34
34: ; preds = %22, %16, %13, %2
%35 = load i64, i64* %5
ret i64 %35
}

LLVM IR (-O2):
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@stdout = global i32 0
@.str.1 = [4 x i8] c" > \00"
define i64 @irc_getline(i32 %0, i8* %1) {
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = tail call i64 @ab_getline(i32 %0, i8* %1, i32 510)
%8 = icmp sgt i64 %7, 0
%9 = icmp ne i8* %1, null
%10 = and i1 %9, %8
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = load i8, i8* %1
%13 = icmp eq i8 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = tail call i32 @time(i32* null)
store i32 %15, i32* %4
%16 = call i32 @localtime(i32* %4)
%17 = call i32 @strftime(i8* %5, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @stdout
%19 = call i32 @fputs(i8* %5, i32 %18)
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @puts(i8* %1)
br label %23
23: ; preds = %14, %11, %2
ret i64 %7
}