#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 BUFSIZ;
int /*<<< orphan*/ EX_UNAVAILABLE;
int /*<<< orphan*/ ddb_main(int, char **);
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t strcspn(char *, char *);
size_t strlen(char *);
int strspn(char *, char *);
void ddb_readfile(char *filename) {
  char buf[BUFSIZ];
  FILE *f;
  if ((f = fopen(filename, "r")) == NULL)
    err(EX_UNAVAILABLE, "fopen: %s", filename);
  while (fgets(buf, BUFSIZ, f)) {
    int argc = 0;
    char *argv[2];
    size_t spn;
    spn = strlen(buf);
    if (buf[spn - 1] == '\n')
      buf[spn - 1] = '\0';
    spn = strspn(buf, " \t");
    argv[0] = buf + spn;
    if (*argv[0] == '#' || *argv[0] == '\0')
      continue;
    argc++;
    spn = strcspn(argv[0], " \t");
    argv[1] = argv[0] + spn + strspn(argv[0] + spn, " \t");
    argv[0][spn] = '\0';
    if (*argv[1] != '\0')
      argc++;
    ddb_main(argc, argv);
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<ddb_readfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11ef <ddb_readfile+0x6f>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe18(%rip),%rsi
call   1090 <err@plt>
jmp    11f4 <ddb_readfile+0x74>
mov    -0x50(%rbp),%rdi
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rdx
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1321 <ddb_readfile+0x1a1>
mov    -0x50(%rbp),%rdi
movl   $0x0,-0x24(%rbp)
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
mov    %rcx,-0x48(%rbp)
mov    -0x48(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1254 <ddb_readfile+0xd4>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x50(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1060 <strspn@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
mov    %rcx,-0x48(%rbp)
add    -0x48(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1299 <ddb_readfile+0x119>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    129e <ddb_readfile+0x11e>
jmp    11f4 <ddb_readfile+0x74>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xd5a(%rip),%rsi
call   1070 <strcspn@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rdi
add    -0x48(%rbp),%rdi
lea    0xd36(%rip),%rsi
call   1060 <strspn@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1310 <ddb_readfile+0x190>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1040 <ddb_main@plt>
jmp    11f4 <ddb_readfile+0x74>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ddb_readfile>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r15
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    0xe4b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11da <ddb_readfile+0x5a>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
mov    %r15,%rdx
call   1090 <err@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12b1 <ddb_readfile+0x131>
lea    0xe0e(%rip),%r14
mov    %r12,-0x30(%rbp)
jmp    122d <ddb_readfile+0xad>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2dc9(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12b1 <ddb_readfile+0x131>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmpb   $0xa,-0x1(%rax,%r13,1)
jne    1243 <ddb_readfile+0xc3>
movb   $0x0,-0x1(%r13,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <strspn@plt>
cltq
lea    (%rax,%r13,1),%rbx
mov    %rbx,-0x40(%rbp)
movzbl 0x0(%r13,%rax,1),%eax
test   %al,%al
je     1210 <ddb_readfile+0x90>
cmp    $0x23,%al
je     1210 <ddb_readfile+0x90>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcspn@plt>
mov    %rax,%r12
lea    (%rbx,%rax,1),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <strspn@plt>
cltq
lea    (%r15,%rax,1),%rcx
movb   $0x0,(%rbx,%r12,1)
mov    -0x30(%rbp),%r12
cmpb   $0x1,(%rax,%r15,1)
mov    %rcx,-0x38(%rbp)
mov    $0x2,%edi
sbb    $0x0,%edi
lea    -0x40(%rbp),%rsi
call   1040 <ddb_main@plt>
jmp    1210 <ddb_readfile+0x90>
mov    %r12,%rdi
call   1030 <fclose@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@EX_UNAVAILABLE = global i32 0
@.str.1 = [10 x i8] c"fopen: %s\00"
@.str.2 = [3 x i8] c" \09\00"
define void @ddb_readfile(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [2 x i8*]
%8 = alloca i64
store i8* %0, i8** %2
%9 = load i32, i32* @BUFSIZ
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i8, i64 %10
store i64 %10, i64* %4
%13 = load i8*, i8** %2
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %5
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = load i32, i32* @EX_UNAVAILABLE
%18 = load i8*, i8** %2
%19 = call i32 @err(i32 %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %1
br label %21
21: ; preds = %86, %55, %20
%22 = load i32, i32* @BUFSIZ
%23 = load i32*, i32** %5
%24 = call i64 @fgets(i8* %12, i32 %22, i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %90
26: ; preds = %21
store i32 0, i32* %6
%27 = call i64 @strlen(i8* %12)
store i64 %27, i64* %8
%28 = load i64, i64* %8
%29 = sub i64 %28, 1
%30 = getelementptr inbounds i8, i8* %12, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = load i64, i64* %8
%36 = sub i64 %35, 1
%37 = getelementptr inbounds i8, i8* %12, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %34, %26
%39 = call i32 @strspn(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = sext i32 %39 to i64
store i64 %40, i64* %8
%41 = load i64, i64* %8
%42 = getelementptr inbounds i8, i8* %12, i64 %41
%43 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
store i8* %42, i8** %43
%44 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%45 = load i8*, i8** %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 35
br i1 %48, label %55, label %49
49: ; preds = %38
%50 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%51 = load i8*, i8** %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %49, %38
br label %21
56: ; preds = %49
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
%59 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%60 = load i8*, i8** %59
%61 = call i64 @strcspn(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i64 %61, i64* %8
%62 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%63 = load i8*, i8** %62
%64 = load i64, i64* %8
%65 = getelementptr inbounds i8, i8* %63, i64 %64
%66 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%67 = load i8*, i8** %66
%68 = load i64, i64* %8
%69 = getelementptr inbounds i8, i8* %67, i64 %68
%70 = call i32 @strspn(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %65, i64 %71
%73 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 1
store i8* %72, i8** %73
%74 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%75 = load i8*, i8** %74
%76 = load i64, i64* %8
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8 0, i8* %77
%78 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 1
%79 = load i8*, i8** %78
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %56
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %86
86: ; preds = %83, %56
%87 = load i32, i32* %6
%88 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%89 = call i32 @ddb_main(i32 %87, i8** %88)
br label %21
90: ; preds = %21
%91 = load i32*, i32** %5
%92 = call i32 @fclose(i32* %91)
%93 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@EX_UNAVAILABLE = global i32 0
@.str.1 = [10 x i8] c"fopen: %s\00"
@.str.2 = [3 x i8] c" \09\00"
define void @ddb_readfile(i8* %0) {
%2 = alloca [2 x i8*]
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @EX_UNAVAILABLE
%10 = tail call i32 @err(i32 %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %8, %1
%12 = load i32, i32* @BUFSIZ
%13 = call i64 @fgets(i8* %5, i32 %12, i32* %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %45, label %15
15: ; preds = %11
%16 = bitcast [2 x i8*]* %2 to i8*
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%18 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 1
br label %19
19: ; preds = %15, %41
%20 = call i64 @strlen(i8* %5)
%21 = add i64 %20, -1
%22 = getelementptr inbounds i8, i8* %5, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %26
25: ; preds = %19
store i8 0, i8* %22
br label %26
26: ; preds = %25, %19
%27 = call i32 @strspn(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %5, i64 %28
store i8* %29, i8** %17
%30 = load i8, i8* %29
switch i8 %30, label %31 [
i8 35, label %41
i8 0, label %41
]
31: ; preds = %26
%32 = call i64 @strcspn(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = call i32 @strspn(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8* %36, i8** %18
store i8 0, i8* %33
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
%39 = select i1 %38, i32 1, i32 2
%40 = call i32 @ddb_main(i32 %39, i8** %17)
br label %41
41: ; preds = %26, %26, %31
%42 = load i32, i32* @BUFSIZ
%43 = call i64 @fgets(i8* %5, i32 %42, i32* %6)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %19
45: ; preds = %41, %11
%46 = call i32 @fclose(i32* %6)
ret void
}