#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 in_addr {
  int /*<<< orphan*/ s_addr;
};
struct drcom_conf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ add_except(struct drcom_conf *, int /*<<< orphan*/,
                      int /*<<< orphan*/);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, struct in_addr *);
char *strchr(char *, char);
int strlen(char *);
int get_except(struct drcom_conf *conf, char *buf) {
  struct in_addr ip, mask;
  char *t, *p, *m;
  p = buf;
  while (*p != '\0') {
    t = strchr(p, ',');
    if (t == NULL)
      t = p + strlen(p);
    else {
      *t = '\0';
      t++;
    }
    m = strchr(p, '/');
    if (m == NULL)
      return -1;
    *m = '\0';
    m++;
    if (!inet_pton(AF_INET, p, &ip) || !inet_pton(AF_INET, m, &mask))
      return -1;
    if (add_except(conf, ip.s_addr, mask.s_addr) != 0)
      return -1;
    p = t;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_except>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1276 <get_except+0x136>
mov    -0x38(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ab <get_except+0x6b>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    11be <get_except+0x7e>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11e7 <get_except+0xa7>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <get_except+0x13d>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <inet_pton@plt>
cmp    $0x0,%eax
je     1238 <get_except+0xf8>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <inet_pton@plt>
cmp    $0x0,%eax
jne    1244 <get_except+0x104>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <get_except+0x13d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1050 <add_except@plt>
cmp    $0x0,%rax
je     1269 <get_except+0x129>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <get_except+0x13d>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1158 <get_except+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_except>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r12
mov    0x2e8d(%rip),%r14
mov    $0xffffffff,%ebp
cmpb   $0x0,(%rbx)
je     1200 <get_except+0xc0>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1190 <get_except+0x50>
mov    %rax,%r13
movb   $0x0,(%rax)
add    $0x1,%r13
jmp    119e <get_except+0x5e>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%r13
add    %rbx,%r13
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1202 <get_except+0xc2>
mov    %rax,%r15
movb   $0x0,(%rax)
mov    (%r14),%edi
mov    %rbx,%rsi
lea    0x10(%rsp),%rdx
call   1060 <inet_pton@plt>
test   %eax,%eax
je     1202 <get_except+0xc2>
add    $0x1,%r15
mov    (%r14),%edi
mov    %r15,%rsi
lea    0x8(%rsp),%rdx
call   1060 <inet_pton@plt>
test   %eax,%eax
je     1202 <get_except+0xc2>
mov    0x10(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r12,%rdi
call   1050 <add_except@plt>
mov    %r13,%rbx
test   %rax,%rax
je     1160 <get_except+0x20>
jmp    1202 <get_except+0xc2>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.drcom_conf = type { i32 }
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
define i32 @get_except(%struct.drcom_conf* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.drcom_conf*
%5 = alloca i8*
%6 = alloca %struct.in_addr
%7 = alloca %struct.in_addr
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store %struct.drcom_conf* %0, %struct.drcom_conf** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %5
store i8* %11, i8** %9
br label %12
12: ; preds = %61, %2
%13 = load i8*, i8** %9
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %63
17: ; preds = %12
%18 = load i8*, i8** %9
%19 = call i8* @strchr(i8* %18, i8 signext 44)
store i8* %19, i8** %8
%20 = load i8*, i8** %8
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i8*, i8** %9
%24 = load i8*, i8** %9
%25 = call i32 @strlen(i8* %24)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8* %27, i8** %8
br label %32
28: ; preds = %17
%29 = load i8*, i8** %8
store i8 0, i8* %29
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %8
br label %32
32: ; preds = %28, %22
%33 = load i8*, i8** %9
%34 = call i8* @strchr(i8* %33, i8 signext 47)
store i8* %34, i8** %10
%35 = load i8*, i8** %10
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %38
37: ; preds = %32
store i32 -1, i32* %3
br label %64
38: ; preds = %32
%39 = load i8*, i8** %10
store i8 0, i8* %39
%40 = load i8*, i8** %10
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %10
%42 = load i32, i32* @AF_INET
%43 = load i8*, i8** %9
%44 = call i32 @inet_pton(i32 %42, i8* %43, %struct.in_addr* %6)
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %38
%47 = load i32, i32* @AF_INET
%48 = load i8*, i8** %10
%49 = call i32 @inet_pton(i32 %47, i8* %48, %struct.in_addr* %7)
%50 = icmp ne i32 %49, 0
br i1 %50, label %52, label %51
51: ; preds = %46, %38
store i32 -1, i32* %3
br label %64
52: ; preds = %46
%53 = load %struct.drcom_conf*, %struct.drcom_conf** %4
%54 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%55 = load i32, i32* %54
%56 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%57 = load i32, i32* %56
%58 = call i64 @add_except(%struct.drcom_conf* %53, i32 %55, i32 %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %52
store i32 -1, i32* %3
br label %64
61: ; preds = %52
%62 = load i8*, i8** %8
store i8* %62, i8** %9
br label %12
63: ; preds = %12
store i32 0, i32* %3
br label %64
64: ; preds = %63, %60, %51, %37
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
%struct.drcom_conf = type { i32 }
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
define i32 @get_except(%struct.drcom_conf* %0, i8* %1) {
%3 = alloca %struct.in_addr
%4 = alloca %struct.in_addr
%5 = bitcast %struct.in_addr* %3 to i8*
%6 = bitcast %struct.in_addr* %4 to i8*
%7 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
%8 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i64 0, i32 0
br label %9
9: ; preds = %35, %2
%10 = phi i8* [ %1, %2 ], [ %23, %35 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %40, label %13
13: ; preds = %9
%14 = call i8* @strchr(i8* %10, i8 signext 44)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = call i32 @strlen(i8* %10)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %10, i64 %18
br label %22
20: ; preds = %13
store i8 0, i8* %14
%21 = getelementptr inbounds i8, i8* %14, i64 1
br label %22
22: ; preds = %20, %16
%23 = phi i8* [ %19, %16 ], [ %21, %20 ]
%24 = call i8* @strchr(i8* %10, i8 signext 47)
%25 = icmp eq i8* %24, null
br i1 %25, label %40, label %26
26: ; preds = %22
store i8 0, i8* %24
%27 = load i32, i32* @AF_INET
%28 = call i32 @inet_pton(i32 %27, i8* %10, %struct.in_addr* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %40, label %30
30: ; preds = %26
%31 = getelementptr inbounds i8, i8* %24, i64 1
%32 = load i32, i32* @AF_INET
%33 = call i32 @inet_pton(i32 %32, i8* %31, %struct.in_addr* %4)
%34 = icmp eq i32 %33, 0
br i1 %34, label %40, label %35
35: ; preds = %30
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = call i64 @add_except(%struct.drcom_conf* %0, i32 %36, i32 %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %9, label %40
40: ; preds = %9, %35, %26, %30, %22
%41 = phi i32 [ -1, %22 ], [ -1, %30 ], [ -1, %26 ], [ -1, %35 ], [ 0, %9 ]
ret i32 %41
}