int main() {
  char *ip = "192.168.1.102";
  printf("IP : [%u]\n", ip_atoi(ip));
  char mac[18];
  memset(mac, 0, 18);
  if (ip_itoa(ip_atoi(ip), mac, 18) < 0)
    printf("error\n");
  printf("IPSTR : [%s]\n", mac);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1060 <ip_atoi@plt>
mov    %eax,%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1060 <ip_atoi@plt>
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
mov    $0x12,%edx
mov    $0x0,%al
call   1050 <ip_itoa@plt>
cmp    $0x0,%eax
jge    11b9 <main+0x79>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <ip_atoi@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x10(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <ip_atoi@plt>
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x12,%edx
xor    %eax,%eax
call   1050 <ip_itoa@plt>
test   %eax,%eax
jns    119f <main+0x5f>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"192.168.1.102\00"
@.str.1 = [11 x i8] c"IP : [%u]\0A\00"
@.str.2 = [7 x i8] c"error\0A\00"
@.str.3 = [14 x i8] c"IPSTR : [%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [18 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @ip_atoi to i32 (i8*, ...)*)(i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @ip_atoi to i32 (i8*, ...)*)(i8* %8)
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%11 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @ip_itoa to i32 (i32, i8*, i32, ...)*)(i32 %9, i8* %10, i32 18)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %0
%16 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"192.168.1.102\00"
@.str.1 = [11 x i8] c"IP : [%u]\0A\00"
@.str.3 = [14 x i8] c"IPSTR : [%s]\0A\00"
@str = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca [18 x i8]
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ip_atoi to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @ip_atoi to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @ip_itoa to i32 (i32, i8*, i32, ...)*)(i32 %5, i8* %4, i32 18)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 0
}