#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 */
char EOF;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void write_to_database(FILE *fp, FILE *database) {
  char c;
  (void)rewind(fp);
  while ((c = fgetc(fp)) != EOF) {
    if (c != '*') {
      (void)fputc(c, database);
    }
  }
}


x86 assembly (clang, -O0):
<write_to_database>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e89(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     118b <write_to_database+0x5b>
movsbl -0x11(%rbp),%eax
cmp    $0x2a,%eax
je     1186 <write_to_database+0x56>
mov    -0x11(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    1149 <write_to_database+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_to_database>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <rewind@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    0x2e99(%rip),%r15
jmp    1168 <write_to_database+0x38>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    (%r15),%al
je     117e <write_to_database+0x4e>
cmp    $0x2a,%al
je     1160 <write_to_database+0x30>
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    1160 <write_to_database+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
define void @write_to_database(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = call i32 @rewind(i32* %6)
br label %8
8: ; preds = %23, %2
%9 = load i32*, i32** %3
%10 = call signext i8 @fgetc(i32* %9)
store i8 %10, i8* %5
%11 = sext i8 %10 to i32
%12 = load i8, i8* @EOF
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %11, %13
br i1 %14, label %15, label %24
15: ; preds = %8
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 42
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i8, i8* %5
%21 = load i32*, i32** %4
%22 = call i32 @fputc(i8 signext %20, i32* %21)
br label %23
23: ; preds = %19, %15
br label %8
24: ; preds = %8
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
define void @write_to_database(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @rewind(i32* %0)
%4 = tail call signext i8 @fgetc(i32* %0)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %16, label %7
7: ; preds = %2, %12
%8 = phi i8 [ %13, %12 ], [ %4, %2 ]
%9 = icmp eq i8 %8, 42
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @fputc(i8 signext %8, i32* %1)
br label %12
12: ; preds = %10, %7
%13 = tail call signext i8 @fgetc(i32* %0)
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %13, %14
br i1 %15, label %16, label %7
16: ; preds = %12, %2
ret void
}