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

/* Variables and functions */
int getaddrinfo(char const *, char const *, int /*<<< orphan*/ *,
                struct addrinfo **);
int /*<<< orphan*/ printf(char *, ...);
struct addrinfo *createAddressInfo(const char *address, const char *port) {
  printf("Creating address info for %s:%s\n", address, port);
  struct addrinfo *addr;
  int err = getaddrinfo(address, port, NULL, &addr);
  if (err == 0) {
    printf("Successfully created address info.\n");
    return addr;
  }
  printf("Error occurred in createAddressInfo with err=%ld.\n", err);
  return NULL;
}


x86 assembly (clang, -O0):
<createAddressInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x20(%rbp),%rcx
call   1040 <getaddrinfo@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1183 <createAddressInfo+0x63>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <createAddressInfo+0x7c>
mov    -0x24(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createAddressInfo>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <getaddrinfo@plt>
test   %eax,%eax
je     1176 <createAddressInfo+0x46>
lea    0xeb8(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1186 <createAddressInfo+0x56>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32 }
@.str = [33 x i8] c"Creating address info for %s:%s\0A\00"
@.str.1 = [36 x i8] c"Successfully created address info.\0A\00"
@.str.2 = [51 x i8] c"Error occurred in createAddressInfo with err=%ld.\0A\00"
define %struct.addrinfo* @createAddressInfo(i8* %0, i8* %1) {
%3 = alloca %struct.addrinfo*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.addrinfo*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = load i8*, i8** %4
%12 = load i8*, i8** %5
%13 = call i32 @getaddrinfo(i8* %11, i8* %12, i32* null, %struct.addrinfo** %6)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%18 = load %struct.addrinfo*, %struct.addrinfo** %6
store %struct.addrinfo* %18, %struct.addrinfo** %3
br label %22
19: ; preds = %2
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %20)
store %struct.addrinfo* null, %struct.addrinfo** %3
br label %22
22: ; preds = %19, %16
%23 = load %struct.addrinfo*, %struct.addrinfo** %3
ret %struct.addrinfo* %23
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [33 x i8] c"Creating address info for %s:%s\0A\00"
@.str.2 = [51 x i8] c"Error occurred in createAddressInfo with err=%ld.\0A\00"
@str = [35 x i8] c"Successfully created address info.\00"
define %struct.addrinfo* @createAddressInfo(i8* %0, i8* %1) {
%3 = alloca %struct.addrinfo*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%5 = bitcast %struct.addrinfo** %3 to i8*
%6 = call i32 @getaddrinfo(i8* %0, i8* %1, i32* null, %struct.addrinfo** %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%10 = load %struct.addrinfo*, %struct.addrinfo** %3
br label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %6)
br label %13
13: ; preds = %11, %8
%14 = phi %struct.addrinfo* [ %10, %8 ], [ null, %11 ]
ret %struct.addrinfo* %14
}