#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 */
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ err();
int ntohl(unsigned long);
int ntohs(unsigned short);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ printstr(char const *);
void test_getnameinfo_err(int n, unsigned long ipaddr, unsigned short port,
                          socklen_t nodelen, socklen_t servicelen, int flags,
                          const char *exp_result, const char *result) {
  printf("error %d: getnameinfo(0x%.8x, %d, %d, %d, 0x%x); result: ", n,
         ntohl(ipaddr), ntohs(port), nodelen, servicelen, flags);
  printstr(result);
  printf("; expected: ");
  printstr(exp_result);
  printf("\n");
  err();
}


x86 assembly (clang, -O0):
<test_getnameinfo_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dx,%ax
mov    0x18(%rbp),%rdx
mov    0x10(%rbp),%rdx
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <ntohl@plt>
mov    %eax,-0x24(%rbp)
movzwl -0x12(%rbp),%edi
call   1060 <ntohs@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x20(%rbp),%eax
lea    0xe52(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x18(%rbp),%rdi
call   1040 <printstr@plt>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x10(%rbp),%rdi
call   1040 <printstr@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <err@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getnameinfo_err>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebp
mov    %r8d,0xc(%rsp)
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %edi,%r13d
mov    0x50(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0x58(%rsp),%r14
mov    %rsi,%rdi
call   1080 <ntohl@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   1070 <ntohs@plt>
mov    %ebp,(%rsp)
lea    0xe57(%rip),%rdi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %eax,%ecx
mov    %r12d,%r8d
mov    0xc(%rsp),%r9d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <printstr@plt>
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%rdi
call   1050 <printstr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <err@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"error %d: getnameinfo(0x%.8x, %d, %d, %d, 0x%x); result: \00"
@.str.1 = [13 x i8] c"; expected: \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @test_getnameinfo_err(i32 %0, i64 %1, i16 zeroext %2, i32 %3, i32 %4, i32 %5, i8* %6, i8* %7) {
%9 = alloca i32
%10 = alloca i64
%11 = alloca i16
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
store i32 %0, i32* %9
store i64 %1, i64* %10
store i16 %2, i16* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i8* %6, i8** %15
store i8* %7, i8** %16
%17 = load i32, i32* %9
%18 = load i64, i64* %10
%19 = call i32 @ntohl(i64 %18)
%20 = load i16, i16* %11
%21 = call i32 @ntohs(i16 zeroext %20)
%22 = load i32, i32* %12
%23 = load i32, i32* %13
%24 = load i32, i32* %14
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19, i32 %21, i32 %22, i32 %23, i32 %24)
%26 = load i8*, i8** %16
%27 = call i32 @printstr(i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8*, i8** %15
%30 = call i32 @printstr(i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 (...) @err()
ret void
}

LLVM IR (-O2):
@.str = [58 x i8] c"error %d: getnameinfo(0x%.8x, %d, %d, %d, 0x%x); result: \00"
@.str.1 = [13 x i8] c"; expected: \00"
define void @test_getnameinfo_err(i32 %0, i64 %1, i16 zeroext %2, i32 %3, i32 %4, i32 %5, i8* %6, i8* %7) {
%9 = tail call i32 @ntohl(i64 %1)
%10 = tail call i32 @ntohs(i16 zeroext %2)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %9, i32 %10, i32 %3, i32 %4, i32 %5)
%12 = tail call i32 @printstr(i8* %7)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @printstr(i8* %6)
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 (...) @err()
ret void
}