#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 */
int /*<<< orphan*/ assert(int);
int memcmp(char *, char *, size_t);
char *memcpy(char *, char *, size_t);
int strlen(char *);
int main() {
  char *src = "HELLO";
  char dest[100];
  char *res;
  int err = 0;
  size_t bytes = strlen(src) * sizeof(char);
  res = memcpy(dest, src, bytes);
  assert(res == dest);
  err = memcmp(res, src, bytes);
  assert(err != 0);
  res = memcpy(dest, src, bytes);
  assert(res == dest);
  err = memcmp(res, src, bytes);
  assert(err != 0);
  return err;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %rax,-0x98(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x98(%rbp),%rdx
call   1060 <memcpy@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
lea    -0x80(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x88(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x98(%rbp),%rdx
call   1040 <memcmp@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x0,-0x8c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x98(%rbp),%rdx
call   1060 <memcpy@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
lea    -0x80(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x88(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x98(%rbp),%rdx
call   1040 <memcmp@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x0,-0x8c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8c(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xea0(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
mov    $0x1,%edi
call   1050 <assert@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1070 <bcmp@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1050 <assert@plt>
mov    $0x1,%edi
call   1050 <assert@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <memcmp@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1050 <assert@plt>
mov    %ebx,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"HELLO\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [100 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
store i32 0, i32* %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 0, i32* %5
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 1
store i64 %10, i64* %6
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = load i8*, i8** %2
%13 = load i64, i64* %6
%14 = call i8* @memcpy(i8* %11, i8* %12, i64 %13)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = icmp eq i8* %15, %16
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i8*, i8** %4
%21 = load i8*, i8** %2
%22 = load i64, i64* %6
%23 = call i32 @memcmp(i8* %20, i8* %21, i64 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%29 = load i8*, i8** %2
%30 = load i64, i64* %6
%31 = call i8* @memcpy(i8* %28, i8* %29, i64 %30)
store i8* %31, i8** %4
%32 = load i8*, i8** %4
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%34 = icmp eq i8* %32, %33
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i8*, i8** %4
%38 = load i8*, i8** %2
%39 = load i64, i64* %6
%40 = call i32 @memcmp(i8* %37, i8* %38, i64 %39)
store i32 %40, i32* %5
%41 = load i32, i32* %5
%42 = icmp ne i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i32, i32* %5
ret i32 %45
}

LLVM IR (-O2):
@.str = [6 x i8] c"HELLO\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = sext i32 %3 to i64
%5 = tail call i32 @assert(i32 1)
%6 = call i32 @bcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %4)
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @assert(i32 1)
%11 = call i32 @memcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %4)
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
ret i32 %11
}