#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*/ strcpy(char *, char *);
void next_generation(char *cur, char *next, int len) {
  int i = 0;
  for (i = 1; i < (len - 1); i++) {
    if ((cur[i] == '0') && ((cur[i - 1] == '1' || cur[i + 1] == '1') &&
                            !(cur[i - 1] == '1' && cur[i + 1] == '1'))) {
      next[i] = '1';
    } else
      next[i] = '0';
  }
  next[0] = next[i] = '0';
  next[i + 1] = '\0';
  strcpy(cur, next);
}


x86 assembly (clang, -O0):
<next_generation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ef <next_generation+0xdf>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    11d0 <next_generation+0xc0>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
je     118b <next_generation+0x7b>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    11d0 <next_generation+0xc0>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
jne    11bf <next_generation+0xaf>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
je     11d0 <next_generation+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    11dc <next_generation+0xcc>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
jmp    11e1 <next_generation+0xd1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <next_generation+0x21>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_generation>:
mov    $0x1,%eax
cmp    $0x3,%edx
jl     116c <next_generation+0x5c>
add    $0xffffffff,%edx
mov    %edx,%r8d
mov    $0x1,%ecx
jmp    113e <next_generation+0x2e>
nopw   0x0(%rax,%rax,1)
mov    $0x30,%al
mov    %al,(%rsi,%rcx,1)
add    $0x1,%rcx
cmp    %rcx,%r8
je     116a <next_generation+0x5a>
cmpb   $0x30,(%rdi,%rcx,1)
jne    1130 <next_generation+0x20>
movzbl 0x1(%rdi,%rcx,1),%r9d
cmpb   $0x31,-0x1(%rdi,%rcx,1)
jne    1160 <next_generation+0x50>
mov    $0x31,%al
cmp    $0x31,%r9b
je     1130 <next_generation+0x20>
jmp    1132 <next_generation+0x22>
nopl   0x0(%rax,%rax,1)
mov    $0x31,%al
cmp    $0x31,%r9b
jne    1130 <next_generation+0x20>
jmp    1132 <next_generation+0x22>
mov    %edx,%eax
mov    %eax,%eax
movb   $0x30,(%rsi,%rax,1)
movb   $0x30,(%rsi)
movb   $0x0,0x1(%rsi,%rax,1)
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
define void @next_generation(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 1, i32* %7
br label %8
8: ; preds = %68, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = sub nsw i32 %10, 1
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %71
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 48
br i1 %20, label %21, label %62
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = load i32, i32* %7
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 49
br i1 %29, label %39, label %30
30: ; preds = %21
%31 = load i8*, i8** %4
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 49
br i1 %38, label %39, label %62
39: ; preds = %30, %21
%40 = load i8*, i8** %4
%41 = load i32, i32* %7
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 49
br i1 %47, label %48, label %57
48: ; preds = %39
%49 = load i8*, i8** %4
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %49, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 49
br i1 %56, label %62, label %57
57: ; preds = %48, %39
%58 = load i8*, i8** %5
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
store i8 49, i8* %61
br label %67
62: ; preds = %48, %30, %13
%63 = load i8*, i8** %5
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
store i8 48, i8* %66
br label %67
67: ; preds = %62, %57
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %8
71: ; preds = %8
%72 = load i8*, i8** %5
%73 = load i32, i32* %7
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
store i8 48, i8* %75
%76 = load i8*, i8** %5
%77 = getelementptr inbounds i8, i8* %76, i64 0
store i8 48, i8* %77
%78 = load i8*, i8** %5
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %78, i64 %81
store i8 0, i8* %82
%83 = load i8*, i8** %4
%84 = load i8*, i8** %5
%85 = call i32 @strcpy(i8* %83, i8* %84)
ret void
}

LLVM IR (-O2):
define void @next_generation(i8* %0, i8* %1, i32 %2) {
%4 = add i32 %2, -1
%5 = icmp sgt i32 %2, 2
br i1 %5, label %6, label %30
6: ; preds = %3
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %25
%9 = phi i64 [ 1, %6 ], [ %28, %25 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 48
br i1 %12, label %13, label %24
13: ; preds = %8
%14 = add nsw i64 %9, -1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 49
%18 = add nuw nsw i64 %9, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 49
br i1 %17, label %23, label %22
22: ; preds = %13
br i1 %21, label %25, label %24
23: ; preds = %13
br i1 %21, label %24, label %25
24: ; preds = %23, %22, %8
br label %25
25: ; preds = %23, %22, %24
%26 = phi i8 [ 48, %24 ], [ 49, %22 ], [ 49, %23 ]
%27 = getelementptr inbounds i8, i8* %1, i64 %9
store i8 %26, i8* %27
%28 = add nuw nsw i64 %9, 1
%29 = icmp eq i64 %28, %7
br i1 %29, label %30, label %8
30: ; preds = %25, %3
%31 = phi i32 [ 1, %3 ], [ %4, %25 ]
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %1, i64 %32
store i8 48, i8* %33
store i8 48, i8* %1
%34 = add nuw nsw i32 %31, 1
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %1, i64 %35
store i8 0, i8* %36
%37 = tail call i32 @strcpy(i8* %0, i8* %1)
ret void
}