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

/* Variables and functions */
int /*<<< orphan*/ addzone(char *);
int /*<<< orphan*/ ecalloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
char *memcpy(int /*<<< orphan*/, char *, int);
int addzonefile(const char *fname) {
  FILE *f = fopen(fname, "r");
  char linebuf[2048];
  if (!f)
    return 0;
  while (fgets(linebuf, sizeof(linebuf), f)) {
    char *p = linebuf, *e;
    while (*p == ' ' || *p == '\t')
      ++p;
    if (*p == '#' || *p == '\n')
      continue;
    e = p;
    while (*e && *e != ' ' && *e != '\t' && *e != '\n')
      ++e;
    *e++ = '\0';
    p = memcpy(ecalloc(e - p, 1), p, e - p);
    addzone(p);
  }
  fclose(f);
  return 1;
}


x86 assembly (clang, -O0):
<addzonefile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119a <addzonefile+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    136f <addzonefile+0x20f>
jmp    119f <addzonefile+0x3f>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x800,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     135f <addzonefile+0x1ff>
lea    -0x820(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x831(%rbp)
je     11fd <addzonefile+0x9d>
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x831(%rbp)
mov    -0x831(%rbp),%al
test   $0x1,%al
jne    1210 <addzonefile+0xb0>
jmp    1227 <addzonefile+0xc7>
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    11cc <addzonefile+0x6c>
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     124d <addzonefile+0xed>
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1252 <addzonefile+0xf2>
jmp    119f <addzonefile+0x3f>
mov    -0x828(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x832(%rbp)
je     12c7 <addzonefile+0x167>
mov    -0x830(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x832(%rbp)
je     12c7 <addzonefile+0x167>
mov    -0x830(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x832(%rbp)
je     12c7 <addzonefile+0x167>
mov    -0x830(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x832(%rbp)
mov    -0x832(%rbp),%al
test   $0x1,%al
jne    12da <addzonefile+0x17a>
jmp    12f1 <addzonefile+0x191>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    1260 <addzonefile+0x100>
mov    -0x830(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x830(%rbp)
movb   $0x0,(%rax)
mov    -0x830(%rbp),%rax
mov    -0x828(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edi
mov    $0x1,%esi
call   1030 <ecalloc@plt>
mov    %eax,%edi
mov    -0x828(%rbp),%rsi
mov    -0x830(%rbp),%rax
mov    -0x828(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rdi
call   1070 <addzone@plt>
jmp    119f <addzonefile+0x3f>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addzonefile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
lea    0xef4(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1260 <addzonefile+0x100>
mov    %rax,%r15
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x800,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1251 <addzonefile+0xf1>
movabs $0x100000601,%r13
lea    0xe4a(%rip),%rbp
mov    %r14,%r12
jmp    11d8 <addzonefile+0x78>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x800,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
mov    %r14,%r12
test   %rax,%rax
je     1251 <addzonefile+0xf1>
mov    (%r12),%al
lea    -0x9(%rax),%ecx
cmp    $0x1a,%cl
ja     1200 <addzonefile+0xa0>
movzbl %cl,%ecx
movslq 0x0(%rbp,%rcx,4),%rcx
add    %rbp,%rcx
jmp    *%rcx
add    $0x1,%r12
jmp    11d8 <addzonefile+0x78>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%ebx
jmp    1219 <addzonefile+0xb9>
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%eax
add    $0x1,%rbx
cmp    $0x20,%al
ja     1210 <addzonefile+0xb0>
movzbl %al,%eax
bt     %rax,%r13
jae    1210 <addzonefile+0xb0>
movb   $0x0,-0x1(%r12,%rbx,1)
mov    %ebx,%edi
mov    $0x1,%esi
call   1030 <ecalloc@plt>
mov    %eax,%edi
mov    %r12,%rsi
mov    %ebx,%edx
call   1060 <memcpy@plt>
mov    %rax,%rdi
call   1070 <addzone@plt>
jmp    11c0 <addzonefile+0x60>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
jmp    1262 <addzonefile+0x102>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @addzonefile(i8* nocapture %0) {
%2 = alloca [2048 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%5 = icmp eq i32* %3, null
br i1 %5, label %36, label %6
6: ; preds = %1
%7 = call i64 @fgets(i8* %4, i32 2048, i32* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %34, label %9
9: ; preds = %6, %14
%10 = phi i8* [ %15, %14 ], [ %4, %6 ]
%11 = load i8, i8* %10
switch i8 %11, label %16 [
i8 32, label %12
i8 9, label %12
i8 35, label %31
i8 10, label %31
]
12: ; preds = %9, %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
br label %14
14: ; preds = %12, %31
%15 = phi i8* [ %13, %12 ], [ %4, %31 ]
br label %9
16: ; preds = %9, %19
%17 = phi i8 [ %21, %19 ], [ %11, %9 ]
%18 = phi i8* [ %20, %19 ], [ %10, %9 ]
switch i8 %17, label %19 [
i8 0, label %22
i8 32, label %22
i8 9, label %22
i8 10, label %22
]
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %18, i64 1
%21 = load i8, i8* %20
br label %16
22: ; preds = %16, %16, %16, %16
%23 = getelementptr inbounds i8, i8* %18, i64 1
store i8 0, i8* %18
%24 = ptrtoint i8* %23 to i64
%25 = ptrtoint i8* %10 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
%28 = call i32 @ecalloc(i32 %27, i32 1)
%29 = call i8* @memcpy(i32 %28, i8* %10, i32 %27)
%30 = call i32 @addzone(i8* %29)
br label %31
31: ; preds = %9, %9, %22
%32 = call i64 @fgets(i8* %4, i32 2048, i32* %3)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %14
34: ; preds = %31, %6
%35 = call i32 @fclose(i32* %3)
br label %36
36: ; preds = %1, %34
%37 = phi i32 [ 1, %34 ], [ 0, %1 ]
ret i32 %37
}