#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 uint32_t;
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int sendto(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
           struct sockaddr *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strlen(char *);
int sendAnswer(int sock, const struct sockaddr_in *to, uint32_t value) {
  char str[32];
  sprintf(str, "%u", value);
  if (-1 ==
      sendto(sock, str, strlen(str), 0, (struct sockaddr *)to, sizeof(*to)))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<sendAnswer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xeb0(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4c(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
mov    -0x10(%rbp),%r8
xor    %ecx,%ecx
mov    $0x4,%r9d
call   1040 <sendto@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    11a1 <sendAnswer+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <sendAnswer+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendAnswer>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xebc(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0x4,%r9d
call   1040 <sendto@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"%u\00"
define i32 @sendAnswer(i32 %0, %struct.sockaddr_in* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in*
%7 = alloca i32
%8 = alloca [32 x i8]
store i32 %0, i32* %5
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %6
store i32 %2, i32* %7
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%10 = load i32, i32* %7
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %5
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%17 = bitcast %struct.sockaddr_in* %16 to %struct.sockaddr*
%18 = call i32 @sendto(i32 %12, i8* %13, i32 %15, i32 0, %struct.sockaddr* %17, i32 4)
%19 = icmp eq i32 -1, %18
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 -1, i32* %4
br label %22
21: ; preds = %3
store i32 0, i32* %4
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [3 x i8] c"%u\00"
define i32 @sendAnswer(i32 %0, %struct.sockaddr_in* %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
%7 = call i32 @strlen(i8* %5)
%8 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%9 = call i32 @sendto(i32 %0, i8* %5, i32 %7, i32 0, %struct.sockaddr* %8, i32 4)
%10 = icmp eq i32 %9, -1
%11 = sext i1 %10 to i32
ret i32 %11
}