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

/* Variables and functions */
int /*<<< orphan*/ cnfnode_setval(struct cnfnode *, char *);
struct cnfnode *create_cnfnode(char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ has_option(struct cnfmodule *, char *);
scalar_t__ isspace(char);
struct cnfnode *parse_file(struct cnfmodule *cm, FILE *fptr) {
  struct cnfnode *cn_root;
  char buf[4096];
  int n;
  cn_root = create_cnfnode("(root)");
  if (cn_root) {
    char *p = buf;
    n = fread(buf, 1, 4095, fptr);
    buf[n] = 0;
    if (has_option(cm, "strip")) {
      while (n && isspace(buf[n - 1]))
        n--;
      buf[n] = 0;
      while (isspace(*p))
        p++;
    }
    cnfnode_setval(cn_root, p);
  }
  return cn_root;
}


x86 assembly (clang, -O0):
<parse_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe96(%rip),%rdi
call   1070 <create_cnfnode@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     128f <parse_file+0x13f>
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1030(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0xfff,%edx
call   1030 <fread@plt>
mov    %eax,-0x1024(%rbp)
movslq -0x1024(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1060 <has_option@plt>
cmp    $0x0,%rax
je     127f <parse_file+0x12f>
jmp    11da <parse_file+0x8a>
xor    %eax,%eax
cmpl   $0x0,-0x1024(%rbp)
mov    %al,-0x1031(%rbp)
je     1214 <parse_file+0xc4>
mov    -0x1024(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x1020(%rbp,%rax,1),%edi
ff
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1031(%rbp)
mov    -0x1031(%rbp),%al
test   $0x1,%al
jne    1227 <parse_file+0xd7>
jmp    123b <parse_file+0xeb>
mov    -0x1024(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1024(%rbp)
jmp    11da <parse_file+0x8a>
movslq -0x1024(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
mov    -0x1030(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     127a <parse_file+0x12a>
mov    -0x1030(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1030(%rbp)
jmp    124a <parse_file+0xfa>
jmp    127f <parse_file+0x12f>
mov    -0x18(%rbp),%rdi
mov    -0x1030(%rbp),%rsi
call   1050 <cnfnode_setval@plt>
mov    -0x18(%rbp),%rax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_file>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%r12
mov    %rdi,%r15
lea    0xe93(%rip),%rdi
call   1070 <create_cnfnode@plt>
mov    %rax,%r14
test   %rax,%rax
je     121d <parse_file+0xcd>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xfff,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
movslq %eax,%r12
movb   $0x0,(%rsp,%r12,1)
lea    0xe62(%rip),%rsi
mov    %r15,%rdi
call   1060 <has_option@plt>
test   %rax,%rax
je     1212 <parse_file+0xc2>
mov    %r12,%rcx
shl    $0x20,%rcx
movabs $0xffffffff00000000,%r15
ff ff ff
mov    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rcx,%r13
sub    $0x1,%rbx
jb     11f0 <parse_file+0xa0>
movsbl -0x1(%rsp,%r12,1),%edi
call   1040 <isspace@plt>
lea    (%r15,%r13,1),%rcx
mov    %rbx,%r12
test   %rax,%rax
jne    11d0 <parse_file+0x80>
sar    $0x20,%r13
movb   $0x0,(%rsp,%r13,1)
lea    -0x1(%rsp),%rbx
xchg   %ax,%ax
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1200 <parse_file+0xb0>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <cnfnode_setval@plt>
mov    %r14,%rax
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.cnfnode = type { i32 }
%struct.cnfmodule = type { i32 }
@.str = [7 x i8] c"(root)\00"
@.str.1 = [6 x i8] c"strip\00"
define %struct.cnfnode* @parse_file(%struct.cnfmodule* %0, i32* %1) {
%3 = alloca %struct.cnfmodule*
%4 = alloca i32*
%5 = alloca %struct.cnfnode*
%6 = alloca [4096 x i8]
%7 = alloca i32
%8 = alloca i8*
store %struct.cnfmodule* %0, %struct.cnfmodule** %3
store i32* %1, i32** %4
%9 = call %struct.cnfnode* @create_cnfnode(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store %struct.cnfnode* %9, %struct.cnfnode** %5
%10 = load %struct.cnfnode*, %struct.cnfnode** %5
%11 = icmp ne %struct.cnfnode* %10, null
br i1 %11, label %12, label %57
12: ; preds = %2
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
store i8* %13, i8** %8
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i32 @fread(i8* %14, i32 1, i32 4095, i32* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %18
store i8 0, i8* %19
%20 = load %struct.cnfmodule*, %struct.cnfmodule** %3
%21 = call i64 @has_option(%struct.cnfmodule* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %53
23: ; preds = %12
br label %24
24: ; preds = %37, %23
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load i32, i32* %7
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = call i64 @isspace(i8 signext %32)
%34 = icmp ne i64 %33, 0
br label %35
35: ; preds = %27, %24
%36 = phi i1 [ false, %24 ], [ %34, %27 ]
br i1 %36, label %37, label %40
37: ; preds = %35
%38 = load i32, i32* %7
%39 = add nsw i32 %38, -1
store i32 %39, i32* %7
br label %24
40: ; preds = %35
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %42
store i8 0, i8* %43
br label %44
44: ; preds = %49, %40
%45 = load i8*, i8** %8
%46 = load i8, i8* %45
%47 = call i64 @isspace(i8 signext %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %44
%50 = load i8*, i8** %8
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %8
br label %44
52: ; preds = %44
br label %53
53: ; preds = %52, %12
%54 = load %struct.cnfnode*, %struct.cnfnode** %5
%55 = load i8*, i8** %8
%56 = call i32 @cnfnode_setval(%struct.cnfnode* %54, i8* %55)
br label %57
57: ; preds = %53, %2
%58 = load %struct.cnfnode*, %struct.cnfnode** %5
ret %struct.cnfnode* %58
}

LLVM IR (-O2):
%struct.cnfnode = type { i32 }
%struct.cnfmodule = type { i32 }
@.str = [7 x i8] c"(root)\00"
@.str.1 = [6 x i8] c"strip\00"
define %struct.cnfnode* @parse_file(%struct.cnfmodule* %0, i32* nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = tail call %struct.cnfnode* @create_cnfnode(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq %struct.cnfnode* %5, null
br i1 %6, label %35, label %7
7: ; preds = %2
%8 = call i32 @fread(i8* %4, i32 1, i32 4095, i32* %1)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %9
store i8 0, i8* %10
%11 = tail call i64 @has_option(%struct.cnfmodule* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %32, label %13
13: ; preds = %7, %16
%14 = phi i64 [ %17, %16 ], [ %9, %7 ]
%15 = icmp eq i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = add nsw i64 %14, -1
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = tail call i64 @isspace(i8 signext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %13
22: ; preds = %13, %16
%23 = shl i64 %14, 32
%24 = ashr exact i64 %23, 32
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %24
store i8 0, i8* %25
br label %26
26: ; preds = %26, %22
%27 = phi i8* [ %4, %22 ], [ %31, %26 ]
%28 = load i8, i8* %27
%29 = tail call i64 @isspace(i8 signext %28)
%30 = icmp eq i64 %29, 0
%31 = getelementptr inbounds i8, i8* %27, i64 1
br i1 %30, label %32, label %26
32: ; preds = %26, %7
%33 = phi i8* [ %4, %7 ], [ %27, %26 ]
%34 = call i32 @cnfnode_setval(%struct.cnfnode* %5, i8* %33)
br label %35
35: ; preds = %32, %2
ret %struct.cnfnode* %5
}