#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 */

/* Variables and functions */
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ _debug(char *, int, int /*<<< orphan*/, char *,
                          char const *);
scalar_t__ add_to_blocked_mac_list(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
char *safe_strdup(char const *);
scalar_t__ strlen(char *);
char *strsep(char **, char *);
void parse_blocked_mac_list(const char ptr[]) {
  char *ptrcopy = NULL, *ptrcopyptr;
  char *possiblemac = NULL;
  _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/"
         "conf.c",
         1277, LOG_DEBUG, "Parsing string [%s] for MAC addresses to block",
         ptr);
  ptrcopyptr = ptrcopy = safe_strdup(ptr);
  while ((possiblemac = strsep(&ptrcopy, ", \t"))) {
    if (strlen(possiblemac) > 0) {
      if (add_to_blocked_mac_list(possiblemac) < 0) {
        exit(1);
      }
    }
  }
  free(ptrcopyptr);
}


x86 assembly (clang, -O0):
<parse_blocked_mac_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%r8
lea    0xe60(%rip),%rdi
mov    $0x4fd,%esi
lea    0xede(%rip),%rcx
call   1060 <_debug@plt>
mov    -0x8(%rbp),%rdi
call   1080 <safe_strdup@plt>
mov    %rax,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xeec(%rip),%rsi
call   1070 <strsep@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     121a <parse_blocked_mac_list+0xaa>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jle    1215 <parse_blocked_mac_list+0xa5>
mov    -0x20(%rbp),%rdi
call   1040 <add_to_blocked_mac_list@plt>
cmp    $0x0,%rax
jge    1210 <parse_blocked_mac_list+0xa0>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1215 <parse_blocked_mac_list+0xa5>
jmp    11c2 <parse_blocked_mac_list+0x52>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_blocked_mac_list>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
lea    0xe75(%rip),%rdi
lea    0xef8(%rip),%rcx
mov    $0x4fd,%esi
mov    %rbx,%r8
call   1060 <_debug@plt>
mov    %rbx,%rdi
call   1080 <safe_strdup@plt>
mov    %rax,%r14
mov    %rax,(%rsp)
lea    0xf04(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strsep@plt>
test   %rax,%rax
je     1217 <parse_blocked_mac_list+0xa7>
mov    %rax,%rbx
lea    0xeed(%rip),%r15
mov    %rsp,%r12
jmp    11f3 <parse_blocked_mac_list+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <strsep@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1217 <parse_blocked_mac_list+0xa7>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
jle    11e0 <parse_blocked_mac_list+0x70>
mov    %rbx,%rdi
call   1040 <add_to_blocked_mac_list@plt>
test   %rax,%rax
jns    11e0 <parse_blocked_mac_list+0x70>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/conf.c\00"
@LOG_DEBUG = global i32 0
@.str.1 = [47 x i8] c"Parsing string [%s] for MAC addresses to block\00"
@.str.2 = [4 x i8] c", \09\00"
define void @parse_blocked_mac_list(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
store i8* null, i8** %5
%6 = load i32, i32* @LOG_DEBUG
%7 = load i8*, i8** %2
%8 = call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1277, i32 %6, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %2
%10 = call i8* @safe_strdup(i8* %9)
store i8* %10, i8** %3
store i8* %10, i8** %4
br label %11
11: ; preds = %25, %1
%12 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %12, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = call i64 @strlen(i8* %15)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = call i64 @add_to_blocked_mac_list(i8* %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %18
br label %25
25: ; preds = %24, %14
br label %11
26: ; preds = %11
%27 = load i8*, i8** %4
%28 = call i32 @free(i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/conf.c\00"
@LOG_DEBUG = global i32 0
@.str.1 = [47 x i8] c"Parsing string [%s] for MAC addresses to block\00"
@.str.2 = [4 x i8] c", \09\00"
define void @parse_blocked_mac_list(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i32, i32* @LOG_DEBUG
%5 = tail call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1277, i32 %4, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = tail call i8* @safe_strdup(i8* %0)
store i8* %6, i8** %2
%7 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %21, label %9
9: ; preds = %1, %18
%10 = phi i8* [ %19, %18 ], [ %7, %1 ]
%11 = call i64 @strlen(i8* %10)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = call i64 @add_to_blocked_mac_list(i8* %10)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %13, %9
%19 = call i8* @strsep(i8** %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %9
21: ; preds = %18, %1
%22 = call i32 @free(i8* %6)
ret void
}