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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int copy_to_user_ptrace(struct trace_process *, unsigned long, void *, size_t);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int copy_to_user(struct trace_process *process, unsigned long dst, void *src,
                 size_t len) {
  if (dst % sizeof(long) || len % sizeof(long))
    do {
      fprintf(stderr, "unaligned");
      fprintf(stderr, "\n");
      perror("");
      exit(EXIT_FAILURE);
    } while (0);
  return copy_to_user_ptrace(process, dst, src, len);
}


x86 assembly (clang, -O0):
<copy_to_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
jne    117c <copy_to_user+0x3c>
mov    -0x20(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
je     11c5 <copy_to_user+0x85>
jmp    1181 <copy_to_user+0x41>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe59(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <copy_to_user_ptrace@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_to_user>:
mov    %ecx,%eax
or     %esi,%eax
test   $0x7,%al
jne    114d <copy_to_user+0xd>
jmp    1030 <copy_to_user_ptrace@plt>
push   %rbx
mov    0x2e8b(%rip),%rbx
mov    (%rbx),%edi
lea    0xea2(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe9e(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe93(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.trace_process = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"unaligned\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
define i32 @copy_to_user(%struct.trace_process* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca %struct.trace_process*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
store %struct.trace_process* %0, %struct.trace_process** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%9 = load i64, i64* %6
%10 = urem i64 %9, 8
%11 = icmp ne i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %4
%13 = load i64, i64* %8
%14 = urem i64 %13, 8
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %12, %4
br label %17
17: ; preds = %16
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; No predecessors!
br label %26
26: ; preds = %25, %12
%27 = load %struct.trace_process*, %struct.trace_process** %5
%28 = load i64, i64* %6
%29 = load i8*, i8** %7
%30 = load i64, i64* %8
%31 = call i32 @copy_to_user_ptrace(%struct.trace_process* %27, i64 %28, i8* %29, i64 %30)
ret i32 %31
}

LLVM IR (-O2):
%struct.trace_process = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"unaligned\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
define i32 @copy_to_user(%struct.trace_process* %0, i64 %1, i8* %2, i64 %3) {
%5 = or i64 %3, %1
%6 = and i64 %5, 7
%7 = icmp eq i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %4
%17 = tail call i32 @copy_to_user_ptrace(%struct.trace_process* %0, i64 %1, i8* %2, i64 %3)
ret i32 %17
}