#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 sprintf(char *, char *, unsigned int, unsigned int, unsigned int,
            unsigned int);
char *statstr_dup(char *, int);
char *dotQuad(unsigned int a) {
  char buff[20];
  int len;
  len = sprintf(buff, "%d.%d.%d.%d", (a & 0xff000000) >> 24,
                (a & 0xff0000) >> 16, (a & 0xff00) >> 8, (a & 0xff));
  if (len < 0)
    len = 0;
  return statstr_dup(buff, len);
}


x86 assembly (clang, -O0):
<dotQuad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
and    $0xff000000,%edx
shr    $0x18,%edx
mov    -0x4(%rbp),%ecx
and    $0xff0000,%ecx
shr    $0x10,%ecx
mov    -0x4(%rbp),%r8d
and    $0xff00,%r8d
shr    $0x8,%r8d
mov    -0x4(%rbp),%r9d
and    $0xff,%r9d
lea    0xe98(%rip),%rsi
call   1040 <sprintf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1181 <dotQuad+0x61>
movl   $0x0,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <statstr_dup@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotQuad>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%edx
mov    %edi,%eax
movzbl %dh,%ebp
movzbl %dl,%r9d
shr    $0x18,%edx
shr    $0x10,%eax
movzbl %al,%ecx
lea    0xebf(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%r8d
call   1040 <sprintf@plt>
xor    %esi,%esi
test   %eax,%eax
cmovns %eax,%esi
mov    %rbx,%rdi
call   1030 <statstr_dup@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @dotQuad(i32 %0) {
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* %2
%7 = and i32 %6, -16777216
%8 = lshr i32 %7, 24
%9 = load i32, i32* %2
%10 = and i32 %9, 16711680
%11 = lshr i32 %10, 16
%12 = load i32, i32* %2
%13 = and i32 %12, 65280
%14 = lshr i32 %13, 8
%15 = load i32, i32* %2
%16 = and i32 %15, 255
%17 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %14, i32 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %1
store i32 0, i32* %4
br label %21
21: ; preds = %20, %1
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%23 = load i32, i32* %4
%24 = call i8* @statstr_dup(i8* %22, i32 %23)
ret i8* %24
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d.%d.%d.%d\00"
define i8* @dotQuad(i32 %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = lshr i32 %0, 24
%5 = lshr i32 %0, 16
%6 = and i32 %5, 255
%7 = lshr i32 %0, 8
%8 = and i32 %7, 255
%9 = and i32 %0, 255
%10 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6, i32 %8, i32 %9)
%11 = icmp sgt i32 %10, 0
%12 = select i1 %11, i32 %10, i32 0
%13 = call i8* @statstr_dup(i8* %3, i32 %12)
ret i8* %13
}