#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 */
struct cdb_make {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ dofile_cdb(struct cdb_make *, int /*<<< orphan*/ *,
                              char const *, int);
int /*<<< orphan*/ dofile_ln(struct cdb_make *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int /*<<< orphan*/, char *);
scalar_t__ ferror(int /*<<< orphan*/ *);
void dofile(struct cdb_make *cdbmp, FILE *f, const char *fn, int flags) {
  if (flags & 0x1000)
    dofile_ln(cdbmp, f, flags);
  else
    dofile_cdb(cdbmp, f, fn, flags);
  if (ferror(f))
    error(errno, "read error");
}


x86 assembly (clang, -O0):
<dofile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     117d <dofile+0x3d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1060 <dofile_ln@plt>
jmp    1191 <dofile+0x51>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <dofile_cdb@plt>
mov    -0x10(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11b9 <dofile+0x79>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1050 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dofile>:
push   %rbx
mov    %rsi,%rbx
test   $0x1000,%ecx
jne    1153 <dofile+0x13>
call   1040 <dofile_cdb@plt>
jmp    115a <dofile+0x1a>
mov    %ecx,%edx
call   1060 <dofile_ln@plt>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
je     117d <dofile+0x3d>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
pop    %rbx
jmp    1050 <error@plt>
pop    %rbx
ret

LLVM IR (-O0):
%struct.cdb_make = type { i32 }
@errno = global i32 0
@.str = [11 x i8] c"read error\00"
define void @dofile(%struct.cdb_make* %0, i32* %1, i8* %2, i32 %3) {
%5 = alloca %struct.cdb_make*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store %struct.cdb_make* %0, %struct.cdb_make** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = and i32 %9, 4096
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load %struct.cdb_make*, %struct.cdb_make** %5
%14 = load i32*, i32** %6
%15 = load i32, i32* %8
%16 = call i32 @dofile_ln(%struct.cdb_make* %13, i32* %14, i32 %15)
br label %23
17: ; preds = %4
%18 = load %struct.cdb_make*, %struct.cdb_make** %5
%19 = load i32*, i32** %6
%20 = load i8*, i8** %7
%21 = load i32, i32* %8
%22 = call i32 @dofile_cdb(%struct.cdb_make* %18, i32* %19, i8* %20, i32 %21)
br label %23
23: ; preds = %17, %12
%24 = load i32*, i32** %6
%25 = call i64 @ferror(i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* @errno
%29 = call i32 @error(i32 %28, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %27, %23
ret void
}

LLVM IR (-O2):
%struct.cdb_make = type { i32 }
@errno = global i32 0
@.str = [11 x i8] c"read error\00"
define void @dofile(%struct.cdb_make* %0, i32* %1, i8* %2, i32 %3) {
%5 = and i32 %3, 4096
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @dofile_ln(%struct.cdb_make* %0, i32* %1, i32 %3)
br label %11
9: ; preds = %4
%10 = tail call i32 @dofile_cdb(%struct.cdb_make* %0, i32* %1, i8* %2, i32 %3)
br label %11
11: ; preds = %9, %7
%12 = tail call i64 @ferror(i32* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* @errno
%16 = tail call i32 @error(i32 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %11
ret void
}