#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 */
unsigned int csum_partial_copy_from_user(char const *, char *, int, int, int *);
scalar_t__ verify_area(int /*<<< orphan*/, char const *, int);
unsigned int csum_and_copy_from_user(const char *src, char *dst, int len,
                                     int sum, int *err_ptr) {
  if (verify_area(0, src, len) == 0)
    return csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
  if (len)
    *err_ptr = -14;
  return sum;
}


x86 assembly (clang, -O0):
<csum_and_copy_from_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %edi,%edi
call   1030 <verify_area@plt>
cmp    $0x0,%rax
jne    1171 <csum_and_copy_from_user+0x51>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1040 <csum_partial_copy_from_user@plt>
mov    %eax,-0x4(%rbp)
jmp    118b <csum_and_copy_from_user+0x6b>
cmpl   $0x0,-0x1c(%rbp)
je     1185 <csum_and_copy_from_user+0x65>
mov    -0x28(%rbp),%rax
movl   $0xfffffff2,(%rax)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csum_and_copy_from_user>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <verify_area@plt>
test   %rax,%rax
je     115c <csum_and_copy_from_user+0x3c>
test   %ebp,%ebp
je     1150 <csum_and_copy_from_user+0x30>
movl   $0xfffffff2,(%r14)
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <csum_partial_copy_from_user@plt>

LLVM IR (-O0):
define i32 @csum_and_copy_from_user(i8* %0, i8* %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32* %4, i32** %11
%12 = load i8*, i8** %7
%13 = load i32, i32* %9
%14 = call i64 @verify_area(i32 0, i8* %12, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %5
%17 = load i8*, i8** %7
%18 = load i8*, i8** %8
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = load i32*, i32** %11
%22 = call i32 @csum_partial_copy_from_user(i8* %17, i8* %18, i32 %19, i32 %20, i32* %21)
store i32 %22, i32* %6
br label %30
23: ; preds = %5
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32*, i32** %11
store i32 -14, i32* %27
br label %28
28: ; preds = %26, %23
%29 = load i32, i32* %10
store i32 %29, i32* %6
br label %30
30: ; preds = %28, %16
%31 = load i32, i32* %6
ret i32 %31
}

LLVM IR (-O2):
define i32 @csum_and_copy_from_user(i8* %0, i8* %1, i32 %2, i32 %3, i32* %4) {
%6 = tail call i64 @verify_area(i32 0, i8* %0, i32 %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @csum_partial_copy_from_user(i8* %0, i8* %1, i32 %2, i32 %3, i32* %4)
br label %13
10: ; preds = %5
%11 = icmp eq i32 %2, 0
br i1 %11, label %13, label %12
12: ; preds = %10
store i32 -14, i32* %4
br label %13
13: ; preds = %10, %12, %8
%14 = phi i32 [ %9, %8 ], [ %3, %12 ], [ %3, %10 ]
ret i32 %14
}