#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef int ssize_t;

/* Variables and functions */
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int sscanf(char *, char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
ssize_t mac_get_from_str(char *string, uint8_t *mac) {
  ssize_t mac_len = sscanf(string, "%2x:%2x:%2x:%2x:%2x:%2x", mac, mac + 1,
                           mac + 2, mac + 3, mac + 4, mac + 5);
  if (!(mac_len == 6)) {
    fprintf(stderr,
            "[ERROR] (%s:%d: errno: %s) "
            "mac_get_from_str() failed"
            "\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/anryko/daft-dhcp-client/refs/heads/"
            "master/daft-dhcp-client.c",
            133, (errno == 0 ? "None" : strerror(errno)));
    errno = 0;
    goto error;
  };
  return 0;
error:
  return -1;
}


x86 assembly (clang, -O0):
<mac_get_from_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
add    $0x4,%rcx
mov    -0x18(%rbp),%r8
add    $0x8,%r8
mov    -0x18(%rbp),%r9
add    $0xc,%r9
mov    -0x18(%rbp),%r10
add    $0x10,%r10
mov    -0x18(%rbp),%rax
add    $0x14,%rax
lea    0xe89(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <sscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
je     1204 <mac_get_from_str+0xd4>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e33(%rip),%rax
cmpq   $0x0,(%rax)
jne    11bf <mac_get_from_str+0x8f>
lea    0xf2f(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11d2 <mac_get_from_str+0xa2>
mov    0x2e12(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x28(%rbp),%r8
lea    0xe38(%rip),%rsi
lea    0xe67(%rip),%rdx
mov    $0x85,%ecx
call   1030 <fprintf@plt>
mov    0x2de0(%rip),%rax
movq   $0x0,(%rax)
jmp    1210 <mac_get_from_str+0xe0>
movl   $0x0,-0x4(%rbp)
jmp    1217 <mac_get_from_str+0xe7>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac_get_from_str>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rdx
lea    0x4(%rsi),%rcx
lea    0x8(%rsi),%r8
lea    0xc(%rsi),%r9
lea    0x10(%rsi),%rax
lea    0x14(%rsi),%rbx
lea    0xeae(%rip),%rsi
push   %rbx
push   %rax
call   1040 <sscanf@plt>
add    $0x10,%rsp
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x6,%ecx
je     11b5 <mac_get_from_str+0x85>
mov    0x2e73(%rip),%rax
mov    (%rax),%ebx
mov    0x2e62(%rip),%r14
mov    (%r14),%rdi
test   %rdi,%rdi
je     1188 <mac_get_from_str+0x58>
call   1050 <strerror@plt>
mov    %rax,%r8
jmp    118f <mac_get_from_str+0x5f>
lea    0xf56(%rip),%r8
lea    0xe82(%rip),%rsi
lea    0xeb1(%rip),%rdx
mov    %ebx,%edi
mov    $0x85,%ecx
call   1030 <fprintf@plt>
movq   $0x0,(%r14)
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%2x:%2x:%2x:%2x:%2x:%2x\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"[ERROR] (%s:%d: errno: %s) mac_get_from_str() failed\0A\00"
@.str.2 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/anryko/daft-dhcp-client/refs/heads/master/daft-dhcp-client.c\00"
@errno = global i64 0
@.str.3 = [5 x i8] c"None\00"
define i32 @mac_get_from_str(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = load i32*, i32** %5
%9 = load i32*, i32** %5
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32*, i32** %5
%12 = getelementptr inbounds i32, i32* %11, i64 2
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 3
%15 = load i32*, i32** %5
%16 = getelementptr inbounds i32, i32* %15, i64 4
%17 = load i32*, i32** %5
%18 = getelementptr inbounds i32, i32* %17, i64 5
%19 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %8, i32* %10, i32* %12, i32* %14, i32* %16, i32* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 6
br i1 %21, label %33, label %22
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = load i64, i64* @errno
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
br label %30
27: ; preds = %22
%28 = load i64, i64* @errno
%29 = call i8* @strerror(i64 %28)
br label %30
30: ; preds = %27, %26
%31 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %26 ], [ %29, %27 ]
%32 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.2, i64 0, i64 0), i32 133, i8* %31)
store i64 0, i64* @errno
br label %34
33: ; preds = %2
store i32 0, i32* %3
br label %35
34: ; preds = %30
store i32 -1, i32* %3
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [24 x i8] c"%2x:%2x:%2x:%2x:%2x:%2x\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"[ERROR] (%s:%d: errno: %s) mac_get_from_str() failed\0A\00"
@.str.2 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/anryko/daft-dhcp-client/refs/heads/master/daft-dhcp-client.c\00"
@errno = global i64 0
@.str.3 = [5 x i8] c"None\00"
define i32 @mac_get_from_str(i8* nocapture %0, i32* %1) {
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = getelementptr inbounds i32, i32* %1, i64 2
%5 = getelementptr inbounds i32, i32* %1, i64 3
%6 = getelementptr inbounds i32, i32* %1, i64 4
%7 = getelementptr inbounds i32, i32* %1, i64 5
%8 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7)
%9 = icmp eq i32 %8, 6
br i1 %9, label %19, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i64, i64* @errno
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i8* @strerror(i64 %12)
br label %16
16: ; preds = %10, %14
%17 = phi i8* [ %15, %14 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %10 ]
%18 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.2, i64 0, i64 0), i32 133, i8* %17)
store i64 0, i64* @errno
br label %19
19: ; preds = %2, %16
%20 = phi i32 [ -1, %16 ], [ 0, %2 ]
ret i32 %20
}