#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 jx {
  int dummy;
};

/* Variables and functions */
int jx_lookup_integer(struct jx *, char *);
char *jx_lookup_string(struct jx *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, int, char const *);
void make_hash_key(struct jx *j, char *key) {
  const char *name, *addr;
  int port;
  addr = jx_lookup_string(j, "address");
  if (!addr)
    addr = "unknown";
  port = jx_lookup_integer(j, "port");
  name = jx_lookup_string(j, "name");
  if (!name)
    name = "unknown";
  sprintf(key, "%s:%d:%s", addr, port, name);
}


x86 assembly (clang, -O0):
<make_hash_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1030 <jx_lookup_string@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116a <make_hash_key+0x3a>
lea    0xea2(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <jx_lookup_integer@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <jx_lookup_string@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a7 <make_hash_key+0x77>
lea    0xe65(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%r8
lea    0xe5d(%rip),%rsi
call   1050 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_hash_key>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xebb(%rip),%rsi
call   1030 <jx_lookup_string@plt>
mov    %rax,%rbx
test   %rax,%rax
lea    0xeb1(%rip),%r12
cmove  %r12,%rbx
lea    0xeae(%rip),%rsi
mov    %r15,%rdi
call   1040 <jx_lookup_integer@plt>
mov    %eax,%ebp
lea    0xea2(%rip),%rsi
mov    %r15,%rdi
call   1030 <jx_lookup_string@plt>
test   %rax,%rax
cmovne %rax,%r12
lea    0xe91(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %r12,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <sprintf@plt>

LLVM IR (-O0):
%struct.jx = type { i32 }
@.str = [8 x i8] c"address\00"
@.str.1 = [8 x i8] c"unknown\00"
@.str.2 = [5 x i8] c"port\00"
@.str.3 = [5 x i8] c"name\00"
@.str.4 = [9 x i8] c"%s:%d:%s\00"
define void @make_hash_key(%struct.jx* %0, i8* %1) {
%3 = alloca %struct.jx*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store %struct.jx* %0, %struct.jx** %3
store i8* %1, i8** %4
%8 = load %struct.jx*, %struct.jx** %3
%9 = call i8* @jx_lookup_string(%struct.jx* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %13
13: ; preds = %12, %2
%14 = load %struct.jx*, %struct.jx** %3
%15 = call i32 @jx_lookup_integer(%struct.jx* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 %15, i32* %7
%16 = load %struct.jx*, %struct.jx** %3
%17 = call i8* @jx_lookup_string(%struct.jx* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %17, i8** %5
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %13
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %21
21: ; preds = %20, %13
%22 = load i8*, i8** %4
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = load i8*, i8** %5
%26 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %23, i32 %24, i8* %25)
ret void
}

LLVM IR (-O2):
%struct.jx = type { i32 }
@.str = [8 x i8] c"address\00"
@.str.1 = [8 x i8] c"unknown\00"
@.str.2 = [5 x i8] c"port\00"
@.str.3 = [5 x i8] c"name\00"
@.str.4 = [9 x i8] c"%s:%d:%s\00"
define void @make_hash_key(%struct.jx* %0, i8* nocapture writeonly %1) {
%3 = tail call i8* @jx_lookup_string(%struct.jx* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
%5 = select i1 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %3
%6 = tail call i32 @jx_lookup_integer(%struct.jx* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i8* @jx_lookup_string(%struct.jx* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i8* %7, null
%9 = select i1 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %7
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %5, i32 %6, i8* %9)
ret void
}