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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *, ...);
int read(int, char *, int);
void readline(int ifd, char *data, int line_length, char *command,
              char *filename, int line_number) {
  if (read(ifd, data, line_length) != line_length) {
    if (line_number)
      printf("%s ERROR: error reading line %d from %s\n", command, line_number,
             filename);
    else
      printf("%s ERROR: error reading header from %s\n", command, filename);
    exit(1);
  }
  return;
}


x86 assembly (clang, -O0):
<readline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <read@plt>
cmp    -0x14(%rbp),%eax
je     11ae <readline+0x7e>
cmpl   $0x0,-0x2c(%rbp)
je     118e <readline+0x5e>
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <readline+0x74>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9d,%ebp
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%ebx
call   1040 <read@plt>
cmp    %ebx,%eax
jne    1156 <readline+0x26>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
test   %ebp,%ebp
jne    1178 <readline+0x48>
lea    0xec8(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe81(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"%s ERROR: error reading line %d from %s\0A\00"
@.str.1 = [40 x i8] c"%s ERROR: error reading header from %s\0A\00"
define void @readline(i32 %0, i8* %1, i32 %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%13 = load i32, i32* %7
%14 = load i8*, i8** %8
%15 = load i32, i32* %9
%16 = call i32 @read(i32 %13, i8* %14, i32 %15)
%17 = load i32, i32* %9
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %6
%20 = load i32, i32* %12
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8*, i8** %10
%24 = load i32, i32* %12
%25 = load i8*, i8** %11
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %24, i8* %25)
br label %31
27: ; preds = %19
%28 = load i8*, i8** %10
%29 = load i8*, i8** %11
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29)
br label %31
31: ; preds = %27, %22
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"%s ERROR: error reading line %d from %s\0A\00"
@.str.1 = [40 x i8] c"%s ERROR: error reading header from %s\0A\00"
define void @readline(i32 %0, i8* nocapture %1, i32 %2, i8* %3, i8* %4, i32 %5) {
%7 = tail call i32 @read(i32 %0, i8* %1, i32 %2)
%8 = icmp eq i32 %7, %2
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = icmp eq i32 %5, 0
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %5, i8* %4)
br label %15
13: ; preds = %9
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
br label %15
15: ; preds = %13, %11
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %6
ret void
}