#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 /*<<< orphan*/ input;

/* Variables and functions */
scalar_t__ malloc(int);
int strlen(char *);
char *delete_zeros(char *input) {
  int i, current, one_count;
  char *output;
  output = (char *)malloc(sizeof(input));
  current = 0;
  one_count = 0;
  for (i = 0; i < strlen(input); i++) {
    if (input[i] == '1') {
      if (one_count > 5) {
        return "Error: consecutive ones can't be more than 5.";
      } else {
        one_count++;
        output[current] = '1';
        current++;
      }
    } else {
      if (one_count != 5) {
        output[current] = '0';
        current++;
      }
      one_count = 0;
    }
  }
  for (i = strlen(output); i < strlen(input); i++) {
    output[i] = '0';
  }
  return output;
}


x86 assembly (clang, -O0):
<delete_zeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11f6 <delete_zeros+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    11bd <delete_zeros+0x9d>
cmpl   $0x5,-0x1c(%rbp)
jle    119a <delete_zeros+0x7a>
lea    0xe6f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1240 <delete_zeros+0x120>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e3 <delete_zeros+0xc3>
cmpl   $0x5,-0x1c(%rbp)
je     11dc <delete_zeros+0xbc>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
jmp    11e8 <delete_zeros+0xc8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114f <delete_zeros+0x2f>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    1238 <delete_zeros+0x118>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1202 <delete_zeros+0xe2>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_zeros>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a1 <delete_zeros+0x81>
xor    %ebp,%ebp
lea    0xeb0(%rip),%r15
xor    %eax,%eax
xor    %ebx,%ebx
jmp    118e <delete_zeros+0x6e>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x5,%eax
jg     11db <delete_zeros+0xbb>
add    $0x1,%eax
mov    $0x31,%cl
mov    %eax,%r13d
movslq %ebx,%rbx
mov    %cl,(%r14,%rbx,1)
add    $0x1,%ebx
add    $0x1,%rbp
mov    %r12,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    %r13d,%eax
cmp    %rcx,%rbp
jge    11a1 <delete_zeros+0x81>
cmpb   $0x31,(%r12,%rbp,1)
je     1160 <delete_zeros+0x40>
mov    $0x30,%cl
xor    %r13d,%r13d
cmp    $0x5,%eax
jne    116d <delete_zeros+0x4d>
jmp    1177 <delete_zeros+0x57>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r14,%r15
cmp    %eax,%ebp
jge    11db <delete_zeros+0xbb>
movslq %ebp,%rbx
nopl   (%rax)
movb   $0x30,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11c0 <delete_zeros+0xa0>
mov    %r14,%r15
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Error: consecutive ones can't be more than 5.\00"
define i8* @delete_zeros(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = call i64 @malloc(i32 8)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %7
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %4
br label %10
10: ; preds = %49, %1
%11 = load i32, i32* %4
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %52
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 49
br i1 %22, label %23, label %37
23: ; preds = %15
%24 = load i32, i32* %6
%25 = icmp sgt i32 %24, 5
br i1 %25, label %26, label %27
26: ; preds = %23
store i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8** %2
br label %70
27: ; preds = %23
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
%30 = load i8*, i8** %7
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 49, i8* %33
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %36
36: ; preds = %27
br label %48
37: ; preds = %15
%38 = load i32, i32* %6
%39 = icmp ne i32 %38, 5
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i8*, i8** %7
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 48, i8* %44
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %47
47: ; preds = %40, %37
store i32 0, i32* %6
br label %48
48: ; preds = %47, %36
br label %49
49: ; preds = %48
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %10
52: ; preds = %10
%53 = load i8*, i8** %7
%54 = call i32 @strlen(i8* %53)
store i32 %54, i32* %4
br label %55
55: ; preds = %65, %52
%56 = load i32, i32* %4
%57 = load i8*, i8** %3
%58 = call i32 @strlen(i8* %57)
%59 = icmp slt i32 %56, %58
br i1 %59, label %60, label %68
60: ; preds = %55
%61 = load i8*, i8** %7
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
store i8 48, i8* %64
br label %65
65: ; preds = %60
%66 = load i32, i32* %4
%67 = add nsw i32 %66, 1
store i32 %67, i32* %4
br label %55
68: ; preds = %55
%69 = load i8*, i8** %7
store i8* %69, i8** %2
br label %70
70: ; preds = %68, %26
%71 = load i8*, i8** %2
ret i8* %71
}

LLVM IR (-O2):
@.str = [46 x i8] c"Error: consecutive ones can't be more than 5.\00"
define i8* @delete_zeros(i8* %0) {
%2 = tail call i64 @malloc(i32 8)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %32
6: ; preds = %1, %25
%7 = phi i64 [ %28, %25 ], [ 0, %1 ]
%8 = phi i32 [ %27, %25 ], [ 0, %1 ]
%9 = phi i32 [ %26, %25 ], [ 0, %1 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %7
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 49
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = icmp sgt i32 %8, 5
br i1 %14, label %45, label %15
15: ; preds = %13
%16 = add nsw i32 %8, 1
br label %19
17: ; preds = %6
%18 = icmp eq i32 %8, 5
br i1 %18, label %25, label %19
19: ; preds = %17, %15
%20 = phi i8 [ 49, %15 ], [ 48, %17 ]
%21 = phi i32 [ %16, %15 ], [ 0, %17 ]
%22 = sext i32 %9 to i64
%23 = getelementptr inbounds i8, i8* %3, i64 %22
store i8 %20, i8* %23
%24 = add nsw i32 %9, 1
br label %25
25: ; preds = %19, %17
%26 = phi i32 [ %9, %17 ], [ %24, %19 ]
%27 = phi i32 [ 0, %17 ], [ %21, %19 ]
%28 = add nuw nsw i64 %7, 1
%29 = tail call i32 @strlen(i8* %0)
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %6, label %32
32: ; preds = %25, %1
%33 = tail call i32 @strlen(i8* %3)
%34 = tail call i32 @strlen(i8* %0)
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = sext i32 %33 to i64
br label %38
38: ; preds = %36, %38
%39 = phi i64 [ %37, %36 ], [ %41, %38 ]
%40 = getelementptr inbounds i8, i8* %3, i64 %39
store i8 48, i8* %40
%41 = add nsw i64 %39, 1
%42 = tail call i32 @strlen(i8* %0)
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %41, %43
br i1 %44, label %38, label %45
45: ; preds = %13, %38, %32
%46 = phi i8* [ %3, %32 ], [ %3, %38 ], [ getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), %13 ]
ret i8* %46
}