#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 */

/* Variables and functions */
int /*<<< orphan*/ PICO_FREE(void *);
int /*<<< orphan*/ printf(char *, ...);
void cb_dns(char *ip, void *arg) {
  if (!ip) {
    printf("DNS error getaddr\n");
    return;
  }
  printf("DNS -> %s\n", ip);
  PICO_FREE(ip);
  if (arg)
    PICO_FREE(arg);
}


x86 assembly (clang, -O0):
<cb_dns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    114e <cb_dns+0x2e>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    117d <cb_dns+0x5d>
mov    -0x8(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <PICO_FREE@plt>
cmpq   $0x0,-0x10(%rbp)
je     117d <cb_dns+0x5d>
mov    -0x10(%rbp),%rdi
call   1030 <PICO_FREE@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cb_dns>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     116c <cb_dns+0x3c>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeba(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <PICO_FREE@plt>
test   %r14,%r14
je     117f <cb_dns+0x4f>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <PICO_FREE@plt>
lea    0xe98(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"DNS error getaddr\0A\00"
@.str.1 = [11 x i8] c"DNS -> %s\0A\00"
define void @cb_dns(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %19
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %3
%13 = call i32 @PICO_FREE(i8* %12)
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i8*, i8** %4
%18 = call i32 @PICO_FREE(i8* %17)
br label %19
19: ; preds = %7, %16, %9
ret void
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"DNS -> %s\0A\00"
@str = [18 x i8] c"DNS error getaddr\00"
define void @cb_dns(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %12
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = tail call i32 @PICO_FREE(i8* %0)
%9 = icmp eq i8* %1, null
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @PICO_FREE(i8* %1)
br label %12
12: ; preds = %4, %10, %6
ret void
}