#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*/ get_string(char *);
int /*<<< orphan*/ hex2int(char *, int);
int /*<<< orphan*/ l_askNbytes(int /*<<< orphan*/, char *, int /*<<< orphan*/,
                               int);
int /*<<< orphan*/ long2str(char *, int /*<<< orphan*/);
char *s_let(char *, char *);
int /*<<< orphan*/ s_scmp(char *, char *);
char *macwhichIP(char *arg) {
  l_askNbytes(get_string(arg), "54", 0, 8);
  if (!s_scmp(arg, "00000000"))
    return s_let("", arg);
  {
    int i;
    char *ptr = arg;
    char ip[9];
    ip[8] = '\0';
    s_let(arg, ip);
    for (i = 0; i < 8; i += 2) {
      long2str(ptr, hex2int(ip + i, 2));
      while (*ptr != '\0')
        ptr++;
      if (i != 6)
        *(ptr++) = '.';
    }
  }
  return arg;
}


x86 assembly (clang, -O0):
<macwhichIP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_string@plt>
mov    %eax,%edi
lea    0xe82(%rip),%rsi
xor    %edx,%edx
mov    $0x8,%ecx
call   1030 <l_askNbytes@plt>
mov    -0x10(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <s_scmp@plt>
cmp    $0x0,%eax
jne    11bc <macwhichIP+0x5c>
mov    -0x10(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <s_let@plt>
mov    %rax,-0x8(%rbp)
jmp    1266 <macwhichIP+0x106>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x29(%rbp),%rsi
call   1040 <s_let@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    125e <macwhichIP+0xfe>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x29(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    $0x2,%esi
call   1060 <hex2int@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1080 <long2str@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     122f <macwhichIP+0xcf>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    120e <macwhichIP+0xae>
cmpl   $0x6,-0x14(%rbp)
je     124b <macwhichIP+0xeb>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2e,(%rax)
jmp    1250 <macwhichIP+0xf0>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    11dc <macwhichIP+0x7c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<macwhichIP>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
call   1050 <get_string@plt>
lea    0xe8a(%rip),%rsi
mov    %eax,%edi
xor    %edx,%edx
mov    $0x8,%ecx
call   1030 <l_askNbytes@plt>
lea    0xe78(%rip),%rsi
mov    %r14,%rdi
call   1070 <s_scmp@plt>
test   %eax,%eax
je     1261 <macwhichIP+0x101>
movb   $0x0,0x17(%rsp)
lea    0xf(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <s_let@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <hex2int@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1080 <long2str@plt>
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    11d0 <macwhichIP+0x70>
movb   $0x2e,-0x1(%rbx)
lea    0x11(%rsp),%rdi
mov    $0x2,%esi
call   1060 <hex2int@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <long2str@plt>
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1200 <macwhichIP+0xa0>
movb   $0x2e,-0x1(%rbx)
lea    0x13(%rsp),%rdi
mov    $0x2,%esi
call   1060 <hex2int@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <long2str@plt>
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1230 <macwhichIP+0xd0>
movb   $0x2e,-0x1(%rbx)
lea    0x15(%rsp),%rdi
mov    $0x2,%esi
call   1060 <hex2int@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1080 <long2str@plt>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xda3(%rip),%rdi
mov    %r14,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1040 <s_let@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"54\00"
@.str.1 = [9 x i8] c"00000000\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @macwhichIP(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [9 x i8]
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @get_string(i8* %7)
%9 = call i32 @l_askNbytes(i32 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 0, i32 8)
%10 = load i8*, i8** %3
%11 = call i32 @s_scmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i8* @s_let(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %14)
store i8* %15, i8** %2
br label %53
16: ; preds = %1
%17 = load i8*, i8** %3
store i8* %17, i8** %5
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 8
store i8 0, i8* %18
%19 = load i8*, i8** %3
%20 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%21 = call i8* @s_let(i8* %19, i8* %20)
store i32 0, i32* %4
br label %22
22: ; preds = %48, %16
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 8
br i1 %24, label %25, label %51
25: ; preds = %22
%26 = load i8*, i8** %5
%27 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = call i32 @hex2int(i8* %30, i32 2)
%32 = call i32 @long2str(i8* %26, i32 %31)
br label %33
33: ; preds = %38, %25
%34 = load i8*, i8** %5
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
br label %33
41: ; preds = %33
%42 = load i32, i32* %4
%43 = icmp ne i32 %42, 6
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %5
store i8 46, i8* %45
br label %47
47: ; preds = %44, %41
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 2
store i32 %50, i32* %4
br label %22
51: ; preds = %22
%52 = load i8*, i8** %3
store i8* %52, i8** %2
br label %53
53: ; preds = %51, %13
%54 = load i8*, i8** %2
ret i8* %54
}

LLVM IR (-O2):
@.str = [3 x i8] c"54\00"
@.str.1 = [9 x i8] c"00000000\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @macwhichIP(i8* %0) {
%2 = alloca [9 x i8]
%3 = tail call i32 @get_string(i8* %0)
%4 = tail call i32 @l_askNbytes(i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 0, i32 8)
%5 = tail call i32 @s_scmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i8* @s_let(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %42
9: ; preds = %1
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 8
store i8 0, i8* %11
%12 = call i8* @s_let(i8* %0, i8* %10)
%13 = call i32 @hex2int(i8* %10, i32 2)
%14 = call i32 @long2str(i8* %0, i32 %13)
br label %15
15: ; preds = %15, %9
%16 = phi i8* [ %0, %9 ], [ %19, %15 ]
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = getelementptr inbounds i8, i8* %16, i64 1
br i1 %18, label %20, label %15
20: ; preds = %15
store i8 46, i8* %16
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 2
%22 = call i32 @hex2int(i8* %21, i32 2)
%23 = call i32 @long2str(i8* %19, i32 %22)
br label %24
24: ; preds = %24, %20
%25 = phi i8* [ %19, %20 ], [ %28, %24 ]
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
%28 = getelementptr inbounds i8, i8* %25, i64 1
br i1 %27, label %29, label %24
29: ; preds = %24
store i8 46, i8* %25
%30 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 4
%31 = call i32 @hex2int(i8* %30, i32 2)
%32 = call i32 @long2str(i8* %28, i32 %31)
br label %33
33: ; preds = %33, %29
%34 = phi i8* [ %28, %29 ], [ %37, %33 ]
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
%37 = getelementptr inbounds i8, i8* %34, i64 1
br i1 %36, label %38, label %33
38: ; preds = %33
store i8 46, i8* %34
%39 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 6
%40 = call i32 @hex2int(i8* %39, i32 2)
%41 = call i32 @long2str(i8* %37, i32 %40)
br label %42
42: ; preds = %38, %7
%43 = phi i8* [ %0, %38 ], [ %8, %7 ]
ret i8* %43
}