#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int s_addr;
};
struct sockaddr_in {
  int sin_port;
  TYPE_1__ sin_addr;
};

/* Variables and functions */
unsigned int hash_func(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
unsigned int get_table_index(struct sockaddr_in *addr) {
  char key[64] = {0};
  sprintf(key, "%u:%u", addr->sin_addr.s_addr, addr->sin_port);
  return hash_func(key, 1024);
}


x86 assembly (clang, -O0):
<get_table_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
lea    0xe9c(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x400,%esi
call   1030 <hash_func@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_table_index>:
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    (%rdi),%ecx
mov    0x4(%rdi),%edx
lea    0xeb9(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1030 <hash_func@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [6 x i8] c"%u:%u\00"
define i32 @get_table_index(%struct.sockaddr_in* %0) {
%2 = alloca %struct.sockaddr_in*
%3 = alloca [64 x i8]
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %2
%4 = bitcast [64 x i8]* %3 to i8*
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%15 = call i32 @hash_func(i8* %14, i32 1024)
ret i32 %15
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [6 x i8] c"%u:%u\00"
define i32 @get_table_index(%struct.sockaddr_in* nocapture %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
%7 = load i32, i32* %6
%8 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7)
%9 = call i32 @hash_func(i8* %3, i32 1024)
ret i32 %9
}