#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 */
struct mls_evt {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int, char *,
                           char *);
int /*<<< orphan*/ mls_evt_deactivate(struct mls_evt *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ time(int /*<<< orphan*/ *);
void _callback_1(struct mls_evt *evt, void *tag) {
  char buf[128];
  fgets(buf, sizeof(buf), stdin);
  if (feof(stdin)) {
    mls_evt_deactivate(evt);
    return;
  }
  fprintf(stdout, "STDIN: %u %s: %s\n", (unsigned int)time(NULL), (char *)tag,
          buf);
}


x86 assembly (clang, -O0):
<_callback_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1030 <fgets@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11a3 <_callback_1+0x53>
mov    -0x8(%rbp),%rdi
call   1070 <mls_evt_deactivate@plt>
jmp    11da <_callback_1+0x8a>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    -0x94(%rbp),%edi
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
lea    -0x90(%rbp),%r8
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_callback_1>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e7f(%rip),%rbx
mov    (%rbx),%edx
mov    %rsp,%rdi
mov    $0x80,%esi
call   1030 <fgets@plt>
mov    (%rbx),%edi
call   1050 <feof@plt>
test   %rax,%rax
je     118e <_callback_1+0x3e>
mov    %r15,%rdi
call   1070 <mls_evt_deactivate@plt>
jmp    11b4 <_callback_1+0x64>
mov    0x2e43(%rip),%rax
mov    (%rax),%ebx
xor    %edi,%edi
call   1060 <time@plt>
lea    0xe5b(%rip),%rsi
mov    %rsp,%r8
mov    %ebx,%edi
mov    %eax,%edx
mov    %r14,%rcx
call   1040 <fprintf@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.mls_evt = type { i32 }
@stdin = global i32 0
@stdout = global i32 0
@.str = [18 x i8] c"STDIN: %u %s: %s\0A\00"
define void @_callback_1(%struct.mls_evt* %0, i8* %1) {
%3 = alloca %struct.mls_evt*
%4 = alloca i8*
%5 = alloca [128 x i8]
store %struct.mls_evt* %0, %struct.mls_evt** %3
store i8* %1, i8** %4
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 128, i32 %7)
%9 = load i32, i32* @stdin
%10 = call i64 @feof(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load %struct.mls_evt*, %struct.mls_evt** %3
%14 = call i32 @mls_evt_deactivate(%struct.mls_evt* %13)
br label %22
15: ; preds = %2
%16 = load i32, i32* @stdout
%17 = call i64 @time(i32* null)
%18 = trunc i64 %17 to i32
%19 = load i8*, i8** %4
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%21 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %19, i8* %20)
br label %22
22: ; preds = %15, %12
ret void
}

LLVM IR (-O2):
%struct.mls_evt = type { i32 }
@stdin = global i32 0
@stdout = global i32 0
@.str = [18 x i8] c"STDIN: %u %s: %s\0A\00"
define void @_callback_1(%struct.mls_evt* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 128, i32 %5)
%7 = load i32, i32* @stdin
%8 = call i64 @feof(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = call i32 @mls_evt_deactivate(%struct.mls_evt* %0)
br label %17
12: ; preds = %2
%13 = load i32, i32* @stdout
%14 = call i64 @time(i32* null)
%15 = trunc i64 %14 to i32
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %1, i8* %4)
br label %17
17: ; preds = %12, %10
ret void
}