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

/* Variables and functions */
struct confline *_skip_spaces(struct confline *, char const **);
int /*<<< orphan*/ cnfnode_setval(struct cnfnode *, char *);
struct confline *next_char(struct confline *, char const **);
struct confline *parse_syslogng_filter(struct cnfnode *cn_top,
                                       struct confline *cl, const char *p) {
  char buf[256], *q;
  cl = _skip_spaces(cl, &p);
  if (*p == '{') {
    p++;
    cl = _skip_spaces(cl, &p);
    q = buf;
    while (*p && *p != ';' && q < buf + sizeof(buf) - 1) {
      *q++ = *p;
      cl = next_char(cl, &p);
    }
    *q++ = *p;
    *q = 0;
    cnfnode_setval(cn_top, buf);
    cl = _skip_spaces(cl, &p);
  }
  return cl;
}


x86 assembly (clang, -O0):
<parse_syslogng_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <_skip_spaces@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
jne    1276 <parse_syslogng_filter+0x146>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <_skip_spaces@plt>
mov    %rax,-0x10(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x129(%rbp)
je     11e8 <parse_syslogng_filter+0xb8>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3b,%ecx
mov    %al,-0x129(%rbp)
je     11e8 <parse_syslogng_filter+0xb8>
mov    -0x128(%rbp),%rax
lea    -0x120(%rbp),%rcx
add    $0x100,%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
setb   %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    11fb <parse_syslogng_filter+0xcb>
jmp    122e <parse_syslogng_filter+0xfe>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x128(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x128(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <next_char@plt>
mov    %rax,-0x10(%rbp)
jmp    1193 <parse_syslogng_filter+0x63>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x128(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x128(%rbp)
mov    %cl,(%rax)
mov    -0x128(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1050 <cnfnode_setval@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <_skip_spaces@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_syslogng_filter>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rsi,%rax
mov    %rdi,%r14
mov    %rdx,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1040 <_skip_spaces@plt>
mov    0x8(%rsp),%rcx
cmpb   $0x7b,(%rcx)
jne    11eb <parse_syslogng_filter+0xbb>
add    $0x1,%rcx
mov    %rcx,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1040 <_skip_spaces@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rax
mov    (%rax),%al
lea    0x10(%rsp),%rbx
test   %al,%al
je     11c9 <parse_syslogng_filter+0x99>
lea    0x10f(%rsp),%r13
lea    0x8(%rsp),%r15
nopl   0x0(%rax)
cmp    $0x3b,%al
je     11cb <parse_syslogng_filter+0x9b>
cmp    %r13,%rbx
jae    11cb <parse_syslogng_filter+0x9b>
mov    %al,(%rbx)
add    $0x1,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <next_char@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rax
movzbl (%rax),%eax
test   %al,%al
jne    11a0 <parse_syslogng_filter+0x70>
xor    %eax,%eax
mov    %al,(%rbx)
movb   $0x0,0x1(%rbx)
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1050 <cnfnode_setval@plt>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1040 <_skip_spaces@plt>
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.cnfnode = type { i32 }
%struct.confline = type { i32 }
define %struct.confline* @parse_syslogng_filter(%struct.cnfnode* %0, %struct.confline* %1, i8* %2) {
%4 = alloca %struct.cnfnode*
%5 = alloca %struct.confline*
%6 = alloca i8*
%7 = alloca [256 x i8]
%8 = alloca i8*
store %struct.cnfnode* %0, %struct.cnfnode** %4
store %struct.confline* %1, %struct.confline** %5
store i8* %2, i8** %6
%9 = load %struct.confline*, %struct.confline** %5
%10 = call %struct.confline* @_skip_spaces(%struct.confline* %9, i8** %6)
store %struct.confline* %10, %struct.confline** %5
%11 = load i8*, i8** %6
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 123
br i1 %14, label %15, label %57
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %6
%18 = load %struct.confline*, %struct.confline** %5
%19 = call %struct.confline* @_skip_spaces(%struct.confline* %18, i8** %6)
store %struct.confline* %19, %struct.confline** %5
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
store i8* %20, i8** %8
br label %21
21: ; preds = %39, %15
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 59
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = load i8*, i8** %8
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds i8, i8* %33, i64 256
%35 = getelementptr inbounds i8, i8* %34, i64 -1
%36 = icmp ult i8* %32, %35
br label %37
37: ; preds = %31, %26, %21
%38 = phi i1 [ false, %26 ], [ false, %21 ], [ %36, %31 ]
br i1 %38, label %39, label %46
39: ; preds = %37
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %8
store i8 %41, i8* %42
%44 = load %struct.confline*, %struct.confline** %5
%45 = call %struct.confline* @next_char(%struct.confline* %44, i8** %6)
store %struct.confline* %45, %struct.confline** %5
br label %21
46: ; preds = %37
%47 = load i8*, i8** %6
%48 = load i8, i8* %47
%49 = load i8*, i8** %8
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %8
store i8 %48, i8* %49
%51 = load i8*, i8** %8
store i8 0, i8* %51
%52 = load %struct.cnfnode*, %struct.cnfnode** %4
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%54 = call i32 @cnfnode_setval(%struct.cnfnode* %52, i8* %53)
%55 = load %struct.confline*, %struct.confline** %5
%56 = call %struct.confline* @_skip_spaces(%struct.confline* %55, i8** %6)
store %struct.confline* %56, %struct.confline** %5
br label %57
57: ; preds = %46, %3
%58 = load %struct.confline*, %struct.confline** %5
ret %struct.confline* %58
}

LLVM IR (-O2):
%struct.cnfnode = type { i32 }
%struct.confline = type { i32 }
define %struct.confline* @parse_syslogng_filter(%struct.cnfnode* %0, %struct.confline* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca [256 x i8]
store i8* %2, i8** %4
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call %struct.confline* @_skip_spaces(%struct.confline* %1, i8** %4)
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 123
br i1 %10, label %11, label %39
11: ; preds = %3
%12 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %12, i8** %4
%13 = call %struct.confline* @_skip_spaces(%struct.confline* %7, i8** %4)
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %32, label %17
17: ; preds = %11
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 255
br label %19
19: ; preds = %17, %26
%20 = phi i8 [ %15, %17 ], [ %30, %26 ]
%21 = phi i8* [ %6, %17 ], [ %27, %26 ]
%22 = phi %struct.confline* [ %13, %17 ], [ %28, %26 ]
%23 = icmp ne i8 %20, 59
%24 = icmp ult i8* %21, %18
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %20, i8* %21
%28 = call %struct.confline* @next_char(%struct.confline* %22, i8** %4)
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %19
32: ; preds = %19, %26, %11
%33 = phi %struct.confline* [ %13, %11 ], [ %28, %26 ], [ %22, %19 ]
%34 = phi i8* [ %6, %11 ], [ %27, %26 ], [ %21, %19 ]
%35 = phi i8 [ 0, %11 ], [ 0, %26 ], [ %20, %19 ]
%36 = getelementptr inbounds i8, i8* %34, i64 1
store i8 %35, i8* %34
store i8 0, i8* %36
%37 = call i32 @cnfnode_setval(%struct.cnfnode* %0, i8* %6)
%38 = call %struct.confline* @_skip_spaces(%struct.confline* %33, i8** %4)
br label %39
39: ; preds = %32, %3
%40 = phi %struct.confline* [ %38, %32 ], [ %7, %3 ]
ret %struct.confline* %40
}