#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*/ sprintf(char *, char *, unsigned char, unsigned char,
                           unsigned char, unsigned char);
long utilIp2IpStr(unsigned char *byIp, char *sBuf) {
  if (byIp == (0) || sBuf == (0))
    return (-1);
  sprintf(sBuf, "%u.%u.%u.%u", byIp[0], byIp[1], byIp[2], byIp[3]);
  return (0);
}


x86 assembly (clang, -O0):
<utilIp2IpStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <utilIp2IpStr+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1143 <utilIp2IpStr+0x33>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1183 <utilIp2IpStr+0x73>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%r8b
mov    -0x10(%rbp),%rax
lea    0xe99(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl 0x3(%rax),%r9d
call   1030 <sprintf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utilIp2IpStr>:
mov    $0xffffffffffffffff,%rax
test   %rdi,%rdi
je     114b <utilIp2IpStr+0x3b>
test   %rsi,%rsi
je     114b <utilIp2IpStr+0x3b>
push   %rax
movzbl (%rdi),%edx
movzbl 0x1(%rdi),%ecx
movzbl 0x2(%rdi),%r8d
movzbl 0x3(%rdi),%r9d
lea    0xec6(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <sprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i64 @utilIp2IpStr(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store i64 -1, i64* %3
br label %27
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 2
%22 = load i8, i8* %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 3
%25 = load i8, i8* %24
%26 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %16, i8 zeroext %19, i8 zeroext %22, i8 zeroext %25)
store i64 0, i64* %3
br label %27
27: ; preds = %12, %11
%28 = load i64, i64* %3
ret i64 %28
}

LLVM IR (-O2):
@.str = [12 x i8] c"%u.%u.%u.%u\00"
define i64 @utilIp2IpStr(i8* %0, i8* writeonly %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = load i8, i8* %0
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %0, i64 3
%13 = load i8, i8* %12
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 zeroext %7, i8 zeroext %9, i8 zeroext %11, i8 zeroext %13)
br label %15
15: ; preds = %2, %6
%16 = phi i64 [ 0, %6 ], [ -1, %2 ]
ret i64 %16
}