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

/* Variables and functions */
int hostname_to_ip_at_dns(char *, char *, struct in_addr *);
int /*<<< orphan*/ inet_ntoa(struct in_addr);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int get_public_ip(char *public_ip) {
  int fn_ret;
  struct in_addr public_ip_addr;
  fn_ret = hostname_to_ip_at_dns("resolver1.opendns.com", "myip.opendns.com",
                                 &public_ip_addr);
  if (fn_ret == 0)
    strcpy(public_ip, inet_ntoa(public_ip_addr));
  return (fn_ret);
}


x86 assembly (clang, -O0):
<get_public_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
lea    0xecc(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <hostname_to_ip_at_dns@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    117b <get_public_ip+0x4b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_public_ip>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec3(%rip),%rdi
lea    0xed2(%rip),%rsi
mov    %rsp,%rdx
call   1050 <hostname_to_ip_at_dns@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1164 <get_public_ip+0x34>
mov    (%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [22 x i8] c"resolver1.opendns.com\00"
@.str.1 = [17 x i8] c"myip.opendns.com\00"
define i32 @get_public_ip(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.in_addr
store i8* %0, i8** %2
%5 = call i32 @hostname_to_ip_at_dns(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %struct.in_addr* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %4, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @inet_ntoa(i32 %11)
%13 = call i32 @strcpy(i8* %9, i32 %12)
br label %14
14: ; preds = %8, %1
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@.str = [22 x i8] c"resolver1.opendns.com\00"
@.str.1 = [17 x i8] c"myip.opendns.com\00"
define i32 @get_public_ip(i8* %0) {
%2 = alloca %struct.in_addr
%3 = bitcast %struct.in_addr* %2 to i8*
%4 = call i32 @hostname_to_ip_at_dns(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %struct.in_addr* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %2, i64 0, i32 0
%8 = load i32, i32* %7
%9 = call i32 @inet_ntoa(i32 %8)
%10 = call i32 @strcpy(i8* %0, i32 %9)
br label %11
11: ; preds = %6, %1
ret i32 %4
}