#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
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';
    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    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117a <addzonefile+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    12fc <addzonefile+0x1bc>
jmp    117f <addzonefile+0x3f>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x800,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     12ec <addzonefile+0x1ac>
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     11dd <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    11f0 <addzonefile+0xb0>
jmp    1207 <addzonefile+0xc7>
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    11ac <addzonefile+0x6c>
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     122d <addzonefile+0xed>
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1232 <addzonefile+0xf2>
jmp    117f <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     12a7 <addzonefile+0x167>
mov    -0x830(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x832(%rbp)
je     12a7 <addzonefile+0x167>
mov    -0x830(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x832(%rbp)
je     12a7 <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    12ba <addzonefile+0x17a>
jmp    12d1 <addzonefile+0x191>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    1240 <addzonefile+0x100>
mov    -0x830(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x828(%rbp),%rdi
call   1050 <addzone@plt>
jmp    117f <addzonefile+0x3f>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addzonefile>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
lea    0xf17(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     121e <addzonefile+0xde>
mov    %rax,%r12
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x800,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     120f <addzonefile+0xcf>
movabs $0x100000601,%r15
lea    0xe6d(%rip),%rbx
mov    %r14,%rdi
jmp    11b8 <addzonefile+0x78>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x800,%esi
mov    %r12,%rdx
call   1040 <fgets@plt>
mov    %r14,%rdi
test   %rax,%rax
je     120f <addzonefile+0xcf>
mov    (%rdi),%al
lea    -0x9(%rax),%ecx
cmp    $0x1a,%cl
ja     11e0 <addzonefile+0xa0>
movzbl %cl,%ecx
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
add    $0x1,%rdi
jmp    11b8 <addzonefile+0x78>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rdi),%rcx
jmp    11f7 <addzonefile+0xb7>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rcx),%eax
add    $0x1,%rcx
cmp    $0x20,%al
ja     11f0 <addzonefile+0xb0>
movzbl %al,%eax
bt     %rax,%r15
jae    11f0 <addzonefile+0xb0>
movb   $0x0,-0x1(%rcx)
call   1050 <addzone@plt>
jmp    11a0 <addzonefile+0x60>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    1220 <addzonefile+0xe0>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 %81
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 %78
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
store i8 0, i8* %75
%76 = load i8*, i8** %6
%77 = call i32 @addzone(i8* %76)
br label %14
78: ; preds = %14
%79 = load i32*, i32** %4
%80 = call i32 @fclose(i32* %79)
store i32 1, i32* %2
br label %81
81: ; preds = %78, %12
%82 = load i32, i32* %2
ret i32 %82
}

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 %29, 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 %27, 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 %24
i8 10, label %24
]
12: ; preds = %9, %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
br label %14
14: ; preds = %12, %24
%15 = phi i8* [ %13, %12 ], [ %4, %24 ]
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
store i8 0, i8* %18
%23 = call i32 @addzone(i8* %10)
br label %24
24: ; preds = %9, %9, %22
%25 = call i64 @fgets(i8* %4, i32 2048, i32* %3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %14
27: ; preds = %24, %6
%28 = call i32 @fclose(i32* %3)
br label %29
29: ; preds = %1, %27
%30 = phi i32 [ 1, %27 ], [ 0, %1 ]
ret i32 %30
}