#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 */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  scalar_t__ *sa_data;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void sh_print_client_ip(struct sockaddr_storage client_addr) {
  int ipindex;
  int ipaddr;
  printf("Client ip: ");
  for (ipindex = 2; ipindex < 6; ipindex++) {
    ipaddr = (int)(((struct sockaddr *)&client_addr)->sa_data[ipindex]);
    ipaddr = (ipaddr + 256) % 256;
    printf("%d.", ipaddr);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<sh_print_client_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    117b <sh_print_client_ip+0x6b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x100,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1130 <sh_print_client_ip+0x20>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sh_print_client_ip>:
push   %r14
push   %rbx
push   %rax
mov    %edi,(%rsp)
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rbx
mov    0x10(%rbx),%eax
lea    0x100(%rax),%ecx
lea    0x1ff(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xffffff00,%edx
neg    %edx
lea    (%rax,%rdx,1),%esi
add    $0x100,%esi
lea    0xea7(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%eax
lea    0x100(%rax),%ecx
lea    0x1ff(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xffffff00,%edx
neg    %edx
lea    (%rax,%rdx,1),%esi
add    $0x100,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbx),%eax
lea    0x100(%rax),%ecx
lea    0x1ff(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xffffff00,%edx
neg    %edx
lea    (%rax,%rdx,1),%esi
add    $0x100,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rbx),%eax
lea    0x100(%rax),%ecx
lea    0x1ff(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xffffff00,%edx
neg    %edx
lea    (%rax,%rdx,1),%esi
add    $0x100,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i64* }
@.str = [12 x i8] c"Client ip: \00"
@.str.1 = [4 x i8] c"%d.\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @sh_print_client_ip(i32 %0) {
%2 = alloca %struct.sockaddr_storage
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %2, i32 0, i32 0
store i32 %0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %3
br label %7
7: ; preds = %24, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = bitcast %struct.sockaddr_storage* %2 to %struct.sockaddr*
%12 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %11, i32 0, i32 0
%13 = load i64*, i64** %12
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i64, i64* %13, i64 %15
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 256
%21 = srem i32 %20, 256
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %10
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %7
27: ; preds = %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Client ip: \00"
@.str.1 = [4 x i8] c"%d.\00"
define void @sh_print_client_ip(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i32* %2 to i64**
%5 = load i64*, i64** %4
%6 = getelementptr inbounds i64, i64* %5, i64 2
%7 = load i64, i64* %6
%8 = trunc i64 %7 to i32
%9 = add nsw i32 %8, 256
%10 = srem i32 %9, 256
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds i64, i64* %5, i64 3
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = add nsw i32 %14, 256
%16 = srem i32 %15, 256
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds i64, i64* %5, i64 4
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = add nsw i32 %20, 256
%22 = srem i32 %21, 256
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds i64, i64* %5, i64 5
%25 = load i64, i64* %24
%26 = trunc i64 %25 to i32
%27 = add nsw i32 %26, 256
%28 = srem i32 %27, 256
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = tail call i32 @putchar(i32 10)
ret void
}