#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 sockaddr_in6 {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ server_addr;

/* Variables and functions */
int /*<<< orphan*/ dieError(char *, int);
scalar_t__ sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
void sendRequest(int sock, struct sockaddr_in6 server_addr) {
  if (sendto(sock, "request", 7, 0, (struct sockaddr *)&server_addr,
             sizeof(server_addr)) < 0) {
    dieError("sendto() failed", sock);
  }
}


x86 assembly (clang, -O0):
<sendRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %esi,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x8(%rbp),%r8
lea    0xec4(%rip),%rsi
mov    $0x7,%edx
xor    %ecx,%ecx
mov    $0x4,%r9d
call   1030 <sendto@plt>
cmp    $0x0,%rax
jge    1167 <sendRequest+0x47>
mov    -0xc(%rbp),%esi
lea    0xea6(%rip),%rdi
call   1040 <dieError@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendRequest>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %esi,0x8(%rsp)
lea    0xece(%rip),%rsi
lea    0x8(%rsp),%r8
mov    $0x7,%edx
xor    %ecx,%ecx
mov    $0x4,%r9d
call   1030 <sendto@plt>
test   %rax,%rax
jns    115c <sendRequest+0x3c>
lea    0xeb3(%rip),%rdi
mov    %ebx,%esi
call   1040 <dieError@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [8 x i8] c"request\00"
@.str.1 = [16 x i8] c"sendto() failed\00"
define void @sendRequest(i32 %0, i32 %1) {
%3 = alloca %struct.sockaddr_in6
%4 = alloca i32
%5 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %3, i32 0, i32 0
store i32 %1, i32* %5
store i32 %0, i32* %4
%6 = load i32, i32* %4
%7 = bitcast %struct.sockaddr_in6* %3 to %struct.sockaddr*
%8 = call i64 @sendto(i32 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7, i32 0, %struct.sockaddr* %7, i32 4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 @dieError(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %10, %2
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [8 x i8] c"request\00"
@.str.1 = [16 x i8] c"sendto() failed\00"
define void @sendRequest(i32 %0, i32 %1) {
%3 = alloca %struct.sockaddr_in6
%4 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %3, i64 0, i32 0
store i32 %1, i32* %4
%5 = bitcast %struct.sockaddr_in6* %3 to %struct.sockaddr*
%6 = call i64 @sendto(i32 %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7, i32 0, %struct.sockaddr* %5, i32 4)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @dieError(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %8, %2
ret void
}