#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int const, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ *stdin;
void journal(FILE *in_f, FILE *out_f, FILE *jou_f, const char *message,
             char *data) {
  const int bdim = 400;
  char buff[bdim];
  fprintf(out_f, "\n%s", message);
  fflush(out_f);
  fprintf(jou_f, "%s\n", message);
  if (in_f != stdin) {
    do {
      fgets(buff, bdim, in_f);
    } while (buff[0] == '#');
  } else
    fgets(buff, bdim, in_f);
  sscanf(buff, "%s", data);
  fprintf(jou_f, "%s\n", data);
  if (in_f != stdin)
    fprintf(out_f, "%s", data);
  fflush(out_f);
}


x86 assembly (clang, -O0):
<journal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x190,-0x2c(%rbp)
mov    %rsp,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe84(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fflush@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe6b(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%rax
je     11e1 <journal+0xa1>
jmp    11b7 <journal+0x77>
mov    -0x8(%rbp),%rdx
lea    -0x1d0(%rbp),%rdi
mov    $0x190,%esi
call   1030 <fgets@plt>
movsbl -0x1d0(%rbp),%eax
cmp    $0x23,%eax
je     11b7 <journal+0x77>
jmp    11f6 <journal+0xb6>
mov    -0x8(%rbp),%rdx
lea    -0x1d0(%rbp),%rdi
mov    $0x190,%esi
call   1030 <fgets@plt>
mov    -0x28(%rbp),%rdx
lea    -0x1d0(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1060 <sscanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xde8(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x2dbc(%rip),%rcx
cmp    (%rcx),%rax
je     1249 <journal+0x109>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xdbd(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fflush@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<journal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r13
lea    0xe89(%rip),%rsi
mov    %r15,%rdi
mov    %rcx,%rdx
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1060 <fflush@plt>
lea    0xe73(%rip),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    0x2e45(%rip),%rbp
cmp    %r13,0x0(%rbp)
je     11c8 <journal+0x78>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x190,%esi
mov    %r13,%rdx
call   1040 <fgets@plt>
cmpb   $0x23,(%rsp)
je     11b0 <journal+0x60>
jmp    11d8 <journal+0x88>
mov    %rsp,%rdi
mov    $0x190,%esi
mov    %r13,%rdx
call   1040 <fgets@plt>
lea    0xe22(%rip),%rsi
mov    %rsp,%rdi
mov    %r14,%rdx
call   1070 <sscanf@plt>
lea    0xe13(%rip),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
call   1050 <fprintf@plt>
cmp    %r13,0x0(%rbp)
je     120d <journal+0xbd>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
mov    %r15,%rdi
call   1060 <fflush@plt>
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\0A%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stdin = global i32* null
@.str.2 = [3 x i8] c"%s\00"
define void @journal(i32* %0, i32* %1, i32* %2, i8* %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
store i32 400, i32* %11
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %12
%14 = alloca i8, i64 400
%15 = load i32*, i32** %7
%16 = load i8*, i8** %9
%17 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32*, i32** %7
%19 = call i32 @fflush(i32* %18)
%20 = load i32*, i32** %8
%21 = load i8*, i8** %9
%22 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32*, i32** %6
%24 = load i32*, i32** @stdin
%25 = icmp ne i32* %23, %24
br i1 %25, label %26, label %36
26: ; preds = %5
br label %27
27: ; preds = %30, %26
%28 = load i32*, i32** %6
%29 = call i32 @fgets(i8* %14, i32 400, i32* %28)
br label %30
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %14, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 35
br i1 %34, label %27, label %35
35: ; preds = %30
br label %39
36: ; preds = %5
%37 = load i32*, i32** %6
%38 = call i32 @fgets(i8* %14, i32 400, i32* %37)
br label %39
39: ; preds = %36, %35
%40 = load i8*, i8** %10
%41 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = load i32*, i32** %8
%43 = load i8*, i8** %10
%44 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = load i32*, i32** %6
%46 = load i32*, i32** @stdin
%47 = icmp ne i32* %45, %46
br i1 %47, label %48, label %52
48: ; preds = %39
%49 = load i32*, i32** %7
%50 = load i8*, i8** %10
%51 = call i32 @fprintf(i32* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %48, %39
%53 = load i32*, i32** %7
%54 = call i32 @fflush(i32* %53)
%55 = load i8*, i8** %12
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\0A%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stdin = global i32* null
@.str.2 = [3 x i8] c"%s\00"
define void @journal(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, i8* %3, i8* %4) {
%6 = alloca [400 x i8]
%7 = getelementptr inbounds [400 x i8], [400 x i8]* %6, i64 0, i64 0
%8 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%9 = tail call i32 @fflush(i32* %1)
%10 = tail call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%11 = load i32*, i32** @stdin
%12 = icmp eq i32* %11, %0
br i1 %12, label %17, label %13
13: ; preds = %5, %13
%14 = call i32 @fgets(i8* %7, i32 400, i32* %0)
%15 = load i8, i8* %7
%16 = icmp eq i8 %15, 35
br i1 %16, label %13, label %19
17: ; preds = %5
%18 = call i32 @fgets(i8* %7, i32 400, i32* %0)
br label %19
19: ; preds = %13, %17
%20 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%21 = call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%22 = load i32*, i32** @stdin
%23 = icmp eq i32* %22, %0
br i1 %23, label %26, label %24
24: ; preds = %19
%25 = call i32 @fputs(i8* %4, i32* %1)
br label %26
26: ; preds = %24, %19
%27 = call i32 @fflush(i32* %1)
ret void
}