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

/* Variables and functions */
int convert_line(char *);
int /*<<< orphan*/ errx(int, char *, int);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ flush_output();
int convert_from_fp(FILE *fp) {
  int lineno = 1, retcode;
  char line[64 * 1024];
  for (;;) {
    if (fgets(line, sizeof(line), fp) == NULL) {
      if (ferror(fp) != 0) {
        return -1;
      } else if (feof(fp) != 0) {
        break;
      }
    }
    retcode = convert_line(line);
    if (retcode != 0) {
      errx(100, "error converting line %d", lineno);
    }
    lineno++;
  }
  flush_output();
  return 0;
}


x86 assembly (clang, -O0):
<convert_from_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x10020(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x10000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11d6 <convert_from_fp+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11b4 <convert_from_fp+0x54>
movl   $0xffffffff,-0x4(%rbp)
jmp    121f <convert_from_fp+0xbf>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     11cc <convert_from_fp+0x6c>
jmp    1211 <convert_from_fp+0xb1>
jmp    11d1 <convert_from_fp+0x71>
jmp    11d6 <convert_from_fp+0x76>
lea    -0x10020(%rbp),%rdi
call   1050 <convert_line@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1203 <convert_from_fp+0xa3>
mov    -0x14(%rbp),%edx
mov    $0x64,%edi
lea    0xe02(%rip),%rsi
call   1040 <errx@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <convert_from_fp+0x16>
mov    $0x0,%al
call   1080 <flush_output@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_from_fp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x10008,%rsp
mov    %rdi,%rbx
mov    $0x1,%ebp
mov    %rsp,%r14
lea    0xe81(%rip),%r15
jmp    1193 <convert_from_fp+0x33>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r14,%rdi
mov    $0x10000,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11c2 <convert_from_fp+0x62>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    11df <convert_from_fp+0x7f>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    11e6 <convert_from_fp+0x86>
mov    %r14,%rdi
call   1050 <convert_line@plt>
test   %eax,%eax
je     1190 <convert_from_fp+0x30>
mov    $0x64,%edi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <errx@plt>
jmp    1190 <convert_from_fp+0x30>
mov    $0xffffffff,%ebx
jmp    11ef <convert_from_fp+0x8f>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <flush_output@plt>
mov    %ebx,%eax
add    $0x10008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"error converting line %d\00"
define i32 @convert_from_fp(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [65536 x i8]
store i32* %0, i32** %3
store i32 1, i32* %4
br label %7
7: ; preds = %32, %1
%8 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%9 = load i32*, i32** %3
%10 = call i32* @fgets(i8* %8, i32 65536, i32* %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = load i32*, i32** %3
%14 = call i64 @ferror(i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -1, i32* %2
br label %37
17: ; preds = %12
%18 = load i32*, i32** %3
%19 = call i64 @feof(i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
br label %35
22: ; preds = %17
br label %23
23: ; preds = %22
br label %24
24: ; preds = %23, %7
%25 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%26 = call i32 @convert_line(i8* %25)
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i32, i32* %4
%31 = call i32 @errx(i32 100, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %24
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %7
35: ; preds = %21
%36 = call i32 (...) @flush_output()
store i32 0, i32* %2
br label %37
37: ; preds = %35, %16
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [25 x i8] c"error converting line %d\00"
define i32 @convert_from_fp(i32* nocapture %0) {
%2 = alloca [65536 x i8]
%3 = getelementptr inbounds [65536 x i8], [65536 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %19, %1
%5 = phi i32 [ 1, %1 ], [ %20, %19 ]
%6 = call i32* @fgets(i8* %3, i32 65536, i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = call i64 @ferror(i32* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = call i64 @feof(i32* %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11, %4
%15 = call i32 @convert_line(i8* %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = call i32 @errx(i32 100, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %19
19: ; preds = %17, %14
%20 = add nuw nsw i32 %5, 1
br label %4
21: ; preds = %11
%22 = call i32 (...) @flush_output()
br label %23
23: ; preds = %8, %21
%24 = phi i32 [ 0, %21 ], [ -1, %8 ]
ret i32 %24
}