#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 INET_ADDRSTRLEN;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int);
char *strdup(char *);
char *printIPv4(int ip) {
  char ipStr[INET_ADDRSTRLEN];
  bzero(ipStr, INET_ADDRSTRLEN);
  sprintf(ipStr, "%d.%d.%d.%d", (0x000000ff & ip), (0x0000ff00 & ip) >> 8,
          (0x00ff0000 & ip) >> 16, (0xff000000 & ip) >> 24);
  return strdup(ipStr);
}


x86 assembly (clang, -O0):
<printIPv4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x20(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
call   1030 <bzero@plt>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
and    $0xff,%edx
mov    -0x4(%rbp),%ecx
and    $0xff00,%ecx
sar    $0x8,%ecx
mov    -0x4(%rbp),%r8d
and    $0xff0000,%r8d
sar    $0x10,%r8d
mov    -0x4(%rbp),%r9d
and    $0xff000000,%r9d
shr    $0x18,%r9d
lea    0xe4d(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <strdup@plt>
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printIPv4>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    0x2e9f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <bzero@plt>
mov    %r14d,%eax
movzbl %al,%edx
movzbl %ah,%ecx
mov    %r14d,%r9d
shr    $0x10,%eax
movzbl %al,%r8d
shr    $0x18,%r9d
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <strdup@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@INET_ADDRSTRLEN = global i32 0
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @printIPv4(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* @INET_ADDRSTRLEN
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i8, i64 %6
store i64 %6, i64* %4
%9 = load i32, i32* @INET_ADDRSTRLEN
%10 = call i32 @bzero(i8* %8, i32 %9)
%11 = load i32, i32* %2
%12 = and i32 255, %11
%13 = load i32, i32* %2
%14 = and i32 65280, %13
%15 = ashr i32 %14, 8
%16 = load i32, i32* %2
%17 = and i32 16711680, %16
%18 = ashr i32 %17, 16
%19 = load i32, i32* %2
%20 = and i32 -16777216, %19
%21 = lshr i32 %20, 24
%22 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %15, i32 %18, i32 %21)
%23 = call i8* @strdup(i8* %8)
%24 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
@INET_ADDRSTRLEN = global i32 0
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define noalias i8* @printIPv4(i32 %0) {
%2 = load i32, i32* @INET_ADDRSTRLEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @bzero(i8* %4, i32 %2)
%6 = and i32 %0, 255
%7 = lshr i32 %0, 8
%8 = and i32 %7, 255
%9 = lshr i32 %0, 16
%10 = and i32 %9, 255
%11 = lshr i32 %0, 24
%12 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %10, i32 %11)
%13 = call i8* @strdup(i8* %4)
ret i8* %13
}