#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*/ printf(char *, unsigned char, unsigned char, unsigned char,
                          unsigned char);
void printip(int ip) {
  unsigned char bytes[4];
  bytes[0] = ip;
  bytes[1] = ip >> 8;
  bytes[2] = ip >> 16;
  bytes[3] = ip >> 24;
  printf("%d.%d.%d.%d\n", bytes[3], bytes[2], bytes[1], bytes[0]);
  return;
}


x86 assembly (clang, -O0):
<printip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0x7(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
mov    %al,-0x6(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%dl
mov    -0x6(%rbp),%cl
mov    -0x7(%rbp),%al
lea    0xeb4(%rip),%rdi
movzbl %dl,%esi
movzbl %cl,%edx
movzbl %al,%ecx
movzbl -0x8(%rbp),%r8d
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printip>:
mov    %edi,%edx
mov    %edi,%eax
movzbl %dh,%ecx
movzbl %dl,%r8d
shr    $0x10,%edx
shr    $0x18,%eax
movzbl %dl,%edx
lea    0xed5(%rip),%rdi
mov    %eax,%esi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%d.%d.%d.%d\0A\00"
define void @printip(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8]
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = trunc i32 %4 to i8
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 %5, i8* %6
%7 = load i32, i32* %2
%8 = ashr i32 %7, 8
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %9, i8* %10
%11 = load i32, i32* %2
%12 = ashr i32 %11, 16
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 %13, i8* %14
%15 = load i32, i32* %2
%16 = ashr i32 %15, 24
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 %17, i8* %18
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%20 = load i8, i8* %19
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%22 = load i8, i8* %21
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%24 = load i8, i8* %23
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%26 = load i8, i8* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 zeroext %20, i8 zeroext %22, i8 zeroext %24, i8 zeroext %26)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d.%d.%d.%d\0A\00"
define void @printip(i32 %0) {
%2 = trunc i32 %0 to i8
%3 = lshr i32 %0, 8
%4 = trunc i32 %3 to i8
%5 = lshr i32 %0, 16
%6 = trunc i32 %5 to i8
%7 = lshr i32 %0, 24
%8 = trunc i32 %7 to i8
%9 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 zeroext %8, i8 zeroext %6, i8 zeroext %4, i8 zeroext %2)
ret void
}