#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*/ SEEK_SET;
int /*<<< orphan*/ cleartoeol();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ newln(int);
int /*<<< orphan*/ printline(char *);
int /*<<< orphan*/ setcurs(int, int);
void read_print_message(FILE *fp, int x, int y) {
  char line[80];
  if (fp) {
    fseek(fp, 0, SEEK_SET);
    if (fgets(line, 80, fp)) {
      setcurs(x, y);
      printline(line);
      cleartoeol();
    }
    if (fgets(line, 80, fp)) {
      newln(x);
      printline(line);
    }
    fclose(fp);
  }
}


x86 assembly (clang, -O0):
<read_print_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     120e <read_print_message+0x9e>
mov    -0x8(%rbp),%rdi
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11d8 <read_print_message+0x68>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <setcurs@plt>
lea    -0x60(%rbp),%rdi
call   1080 <printline@plt>
mov    $0x0,%al
call   1070 <cleartoeol@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1205 <read_print_message+0x95>
mov    -0xc(%rbp),%edi
call   1040 <newln@plt>
lea    -0x60(%rbp),%rdi
call   1080 <printline@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_print_message>:
test   %rdi,%rdi
je     11fc <read_print_message+0x8c>
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11c7 <read_print_message+0x57>
mov    %r14d,%edi
mov    %ebp,%esi
call   1060 <setcurs@plt>
mov    %rsp,%rdi
call   1080 <printline@plt>
xor    %eax,%eax
call   1070 <cleartoeol@plt>
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11ec <read_print_message+0x7c>
mov    %r14d,%edi
call   1040 <newln@plt>
mov    %rsp,%rdi
call   1080 <printline@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define void @read_print_message(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [80 x i8]
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %38
10: ; preds = %3
%11 = load i32*, i32** %4
%12 = load i32, i32* @SEEK_SET
%13 = call i32 @fseek(i32* %11, i32 0, i32 %12)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i64 @fgets(i8* %14, i32 80, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @setcurs(i32 %19, i32 %20)
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%23 = call i32 @printline(i8* %22)
%24 = call i32 (...) @cleartoeol()
br label %25
25: ; preds = %18, %10
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%27 = load i32*, i32** %4
%28 = call i64 @fgets(i8* %26, i32 80, i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i32, i32* %5
%32 = call i32 @newln(i32 %31)
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%34 = call i32 @printline(i8* %33)
br label %35
35: ; preds = %30, %25
%36 = load i32*, i32** %4
%37 = call i32 @fclose(i32* %36)
br label %38
38: ; preds = %35, %3
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define void @read_print_message(i32* %0, i32 %1, i32 %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = icmp eq i32* %0, null
br i1 %6, label %24, label %7
7: ; preds = %3
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %0, i32 0, i32 %8)
%10 = call i64 @fgets(i8* %5, i32 80, i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = call i32 @setcurs(i32 %1, i32 %2)
%14 = call i32 @printline(i8* %5)
%15 = call i32 (...) @cleartoeol()
br label %16
16: ; preds = %12, %7
%17 = call i64 @fgets(i8* %5, i32 80, i32* %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = call i32 @newln(i32 %1)
%21 = call i32 @printline(i8* %5)
br label %22
22: ; preds = %19, %16
%23 = call i32 @fclose(i32* %0)
br label %24
24: ; preds = %22, %3
ret void
}