#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*/ linebuf;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ prompt_error_msg(char const *, char *);
int /*<<< orphan*/ show_error_msg(char const *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void show_errors_from_file(FILE *ef, const char title[]) {
  char linebuf[160];
  char buf[sizeof(linebuf) * 5];
  if (ef == NULL)
    return;
  buf[0] = '\0';
  while (fgets(linebuf, sizeof(linebuf), ef) == linebuf) {
    if (linebuf[0] == '\n')
      continue;
    if (strlen(buf) + strlen(linebuf) + 1 >= sizeof(buf)) {
      int skip = (prompt_error_msg(title, buf) != 0);
      buf[0] = '\0';
      if (skip)
        break;
    }
    strcat(buf, linebuf);
  }
  if (buf[0] != '\0') {
    show_error_msg(title, buf);
  }
  fclose(ef);
}


x86 assembly (clang, -O0):
<show_errors_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3e0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1183 <show_errors_from_file+0x23>
jmp    127e <show_errors_from_file+0x11e>
movb   $0x0,-0x3d0(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0xa0,%esi
call   1060 <fgets@plt>
lea    -0xb0(%rbp),%rcx
cmp    %rcx,%rax
jne    1255 <show_errors_from_file+0xf5>
movsbl -0xb0(%rbp),%eax
cmp    $0xa,%eax
jne    11c4 <show_errors_from_file+0x64>
jmp    118a <show_errors_from_file+0x2a>
lea    -0x3d0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3d8(%rbp)
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x3d8(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
cmp    $0x320,%rax
jb     123d <show_errors_from_file+0xdd>
mov    -0x10(%rbp),%rdi
lea    -0x3d0(%rbp),%rsi
call   1080 <prompt_error_msg@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x3d4(%rbp)
movb   $0x0,-0x3d0(%rbp)
cmpl   $0x0,-0x3d4(%rbp)
je     1238 <show_errors_from_file+0xd8>
jmp    1255 <show_errors_from_file+0xf5>
jmp    123d <show_errors_from_file+0xdd>
lea    -0x3d0(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1070 <strcat@plt>
jmp    118a <show_errors_from_file+0x2a>
movsbl -0x3d0(%rbp),%eax
cmp    $0x0,%eax
je     1275 <show_errors_from_file+0x115>
mov    -0x10(%rbp),%rdi
lea    -0x3d0(%rbp),%rsi
call   1050 <show_error_msg@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x3e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_errors_from_file>:
test   %rdi,%rdi
je     1242 <show_errors_from_file+0xe2>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3c0,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,0xa0(%rsp)
mov    %rsp,%r13
mov    %r13,%rdi
mov    $0xa0,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
cmp    %r13,%rax
jne    122a <show_errors_from_file+0xca>
lea    0xa0(%rsp),%r12
jmp    11d0 <show_errors_from_file+0x70>
nopl   (%rax)
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <strcat@plt>
mov    %r13,%rdi
mov    $0xa0,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
cmp    %r13,%rax
jne    1210 <show_errors_from_file+0xb0>
cmpb   $0xa,(%rsp)
je     11bb <show_errors_from_file+0x5b>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1040 <strlen@plt>
add    %ebx,%eax
add    $0xfffffce1,%eax
cmp    $0xfffffcdf,%eax
ja     11b0 <show_errors_from_file+0x50>
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <prompt_error_msg@plt>
movb   $0x0,0xa0(%rsp)
test   %rax,%rax
je     11b0 <show_errors_from_file+0x50>
jmp    122a <show_errors_from_file+0xca>
cmpb   $0x0,0xa0(%rsp)
je     122a <show_errors_from_file+0xca>
lea    0xa0(%rsp),%rsi
mov    %r14,%rdi
call   1050 <show_error_msg@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x3c0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @show_errors_from_file(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [160 x i8]
%6 = alloca [800 x i8]
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i32*, i32** %3
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
br label %61
11: ; preds = %2
%12 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
store i8 0, i8* %12
br label %13
13: ; preds = %45, %24, %11
%14 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = call i8* @fgets(i8* %14, i32 160, i32* %15)
%17 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %49
19: ; preds = %13
%20 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %19
br label %13
25: ; preds = %19
%26 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
%28 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = add nsw i32 %27, %29
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = icmp uge i64 %32, 800
br i1 %33, label %34, label %45
34: ; preds = %25
%35 = load i8*, i8** %4
%36 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
%37 = call i64 @prompt_error_msg(i8* %35, i8* %36)
%38 = icmp ne i64 %37, 0
%39 = zext i1 %38 to i32
store i32 %39, i32* %7
%40 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
store i8 0, i8* %40
%41 = load i32, i32* %7
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %34
br label %49
44: ; preds = %34
br label %45
45: ; preds = %44, %25
%46 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
%47 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%48 = call i32 @strcat(i8* %46, i8* %47)
br label %13
49: ; preds = %43, %13
%50 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = load i8*, i8** %4
%56 = getelementptr inbounds [800 x i8], [800 x i8]* %6, i64 0, i64 0
%57 = call i32 @show_error_msg(i8* %55, i8* %56)
br label %58
58: ; preds = %54, %49
%59 = load i32*, i32** %3
%60 = call i32 @fclose(i32* %59)
br label %61
61: ; preds = %58, %10
ret void
}

LLVM IR (-O2):
define void @show_errors_from_file(i32* %0, i8* %1) {
%3 = alloca [160 x i8]
%4 = alloca [800 x i8]
%5 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [800 x i8], [800 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32* %0, null
br i1 %7, label %35, label %8
8: ; preds = %2
store i8 0, i8* %6
%9 = call i8* @fgets(i8* %5, i32 160, i32* %0)
%10 = icmp eq i8* %9, %5
br i1 %10, label %11, label %33
11: ; preds = %8, %25
%12 = load i8, i8* %5
%13 = icmp eq i8 %12, 10
br i1 %13, label %25, label %14
14: ; preds = %11
%15 = call i32 @strlen(i8* %6)
%16 = call i32 @strlen(i8* %5)
%17 = add i32 %15, -799
%18 = add i32 %17, %16
%19 = icmp ult i32 %18, -800
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i64 @prompt_error_msg(i8* %1, i8* %6)
%22 = icmp eq i64 %21, 0
store i8 0, i8* %6
br i1 %22, label %23, label %33
23: ; preds = %20, %14
%24 = call i32 @strcat(i8* %6, i8* %5)
br label %25
25: ; preds = %23, %11
%26 = call i8* @fgets(i8* %5, i32 160, i32* %0)
%27 = icmp eq i8* %26, %5
br i1 %27, label %11, label %28
28: ; preds = %25
%29 = load i8, i8* %6
%30 = icmp eq i8 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @show_error_msg(i8* %1, i8* %6)
br label %33
33: ; preds = %20, %8, %31, %28
%34 = call i32 @fclose(i32* %0)
br label %35
35: ; preds = %2, %33
ret void
}