#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 addr_whitelist {
  int dummy;
};

/* Variables and functions */
int addr_whitelist_add(struct addr_whitelist **, char *);
int addr_whitelist_add_spec(struct addr_whitelist **wl, const char *spec) {
  char buf[128], *d;
  const char *s;
  for (s = spec, d = buf;; ++s, ++d) {
    if (*s == 0 || *s == ',' || d - buf >= 127) {
      int ret;
      *d = 0;
      if ((ret = addr_whitelist_add(wl, buf))) {
        return ret;
      }
      if (!*s) {
        return 0;
      }
      d = buf;
    } else {
      *d = *s;
    }
  }
}


x86 assembly (clang, -O0):
<addr_whitelist_add_spec>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xb0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117d <addr_whitelist_add_spec+0x6d>
mov    -0xb0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
je     117d <addr_whitelist_add_spec+0x6d>
mov    -0xa8(%rbp),%rax
lea    -0xa0(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x7f,%rax
jl     11e3 <addr_whitelist_add_spec+0xd3>
mov    -0xa8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <addr_whitelist_add@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     11b4 <addr_whitelist_add_spec+0xa4>
mov    -0xb4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1223 <addr_whitelist_add_spec+0x113>
mov    -0xb0(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11d0 <addr_whitelist_add_spec+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    1223 <addr_whitelist_add_spec+0x113>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
jmp    11f5 <addr_whitelist_add_spec+0xe5>
mov    -0xb0(%rbp),%rax
mov    (%rax),%cl
mov    -0xa8(%rbp),%rax
mov    %cl,(%rax)
jmp    11fa <addr_whitelist_add_spec+0xea>
mov    -0xb0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xb0(%rbp)
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    113c <addr_whitelist_add_spec+0x2c>
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addr_whitelist_add_spec>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rcx
jmp    1138 <addr_whitelist_add_spec+0x28>
mov    %al,(%rcx)
nopl   0x0(%rax)
add    $0x1,%rbx
add    $0x1,%rcx
movzbl (%rbx),%eax
test   %al,%al
je     1150 <addr_whitelist_add_spec+0x40>
cmp    $0x2c,%al
je     1150 <addr_whitelist_add_spec+0x40>
mov    %rcx,%rdx
sub    %r15,%rdx
cmp    $0x7f,%rdx
jl     112a <addr_whitelist_add_spec+0x1a>
nop
movb   $0x0,(%rcx)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <addr_whitelist_add@plt>
test   %eax,%eax
jne    116a <addr_whitelist_add_spec+0x5a>
cmpb   $0x0,(%rbx)
mov    %r15,%rcx
jne    1130 <addr_whitelist_add_spec+0x20>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.addr_whitelist = type { i32 }
define i32 @addr_whitelist_add_spec(%struct.addr_whitelist** %0, i8* nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = ptrtoint [128 x i8]* %3 to i64
br label %6
6: ; preds = %21, %2
%7 = phi i8* [ %4, %2 ], [ %24, %21 ]
%8 = phi i8* [ %1, %2 ], [ %23, %21 ]
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 0, label %14
i8 44, label %14
]
10: ; preds = %6
%11 = ptrtoint i8* %7 to i64
%12 = sub i64 %11, %5
%13 = icmp sgt i64 %12, 126
br i1 %13, label %14, label %20
14: ; preds = %6, %6, %10
store i8 0, i8* %7
%15 = call i32 @addr_whitelist_add(%struct.addr_whitelist** %0, i8* %4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i8, i8* %8
%19 = icmp eq i8 %18, 0
br i1 %19, label %25, label %21
20: ; preds = %10
store i8 %9, i8* %7
br label %21
21: ; preds = %20, %17
%22 = phi i8* [ %4, %17 ], [ %7, %20 ]
%23 = getelementptr inbounds i8, i8* %8, i64 1
%24 = getelementptr inbounds i8, i8* %22, i64 1
br label %6
25: ; preds = %14, %17
ret i32 %15
}