#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 long strlen(char *);
void move_code(char code[]) {
  unsigned long int len = strlen(code);
  if (len == 8)
    for (int i = 0; i < len; i++)
      code[i] = '\0';
  else {
    for (int i = 8; i <= len; i++)
      code[i - 8] = code[i];
  }
}


x86 assembly (clang, -O0):
<move_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x8,-0x10(%rbp)
jne    1168 <move_code+0x58>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1163 <move_code+0x53>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <move_code+0x2b>
jmp    11ab <move_code+0x9b>
movl   $0x8,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     11a6 <move_code+0x96>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x8,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116f <move_code+0x5f>
jmp    11ab <move_code+0x9b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move_code>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x8,%rax
jne    1138 <move_code+0x18>
movq   $0x0,(%rbx)
pop    %rbx
ret
jb     114d <move_code+0x2d>
lea    0x8(%rbx),%rsi
add    $0xfffffffffffffff9,%rax
mov    %rbx,%rdi
mov    %rax,%rdx
call   1040 <memmove@plt>
pop    %rbx
ret

LLVM IR (-O0):
define void @move_code(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
store i64 %7, i64* %3
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 8
br i1 %9, label %10, label %25
10: ; preds = %1
store i32 0, i32* %4
br label %11
11: ; preds = %21, %10
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = load i64, i64* %3
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %16
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %11
24: ; preds = %11
br label %46
25: ; preds = %1
store i32 8, i32* %5
br label %26
26: ; preds = %42, %25
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = load i64, i64* %3
%30 = icmp ule i64 %28, %29
br i1 %30, label %31, label %45
31: ; preds = %26
%32 = load i8*, i8** %2
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = load i8*, i8** %2
%38 = load i32, i32* %5
%39 = sub nsw i32 %38, 8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 %36, i8* %41
br label %42
42: ; preds = %31
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %26
45: ; preds = %26
br label %46
46: ; preds = %45, %24
ret void
}

LLVM IR (-O2):
define void @move_code(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp eq i64 %2, 8
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = bitcast i8* %0 to i64*
store i64 0, i64* %5
br label %11
6: ; preds = %1
%7 = icmp ult i64 %2, 8
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = getelementptr i8, i8* %0, i64 8
%10 = add i64 %2, -7
br label %11
11: ; preds = %8, %4, %6
ret void
}