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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void print_recipe(FILE *stream, int *recipe, int glider_cnt) {
  int phase = 0;
  fprintf(stream, "{");
  int glider_ix;
  for (glider_ix = 0; glider_ix < glider_cnt; glider_ix++) {
    int delay = recipe[glider_ix];
    if (delay == 0) {
      if (phase == 0)
        delay = 256;
      else
        delay = 255;
    } else if (delay == 1) {
      if (phase == 0)
        delay = 255;
      else
        delay = 256;
    }
    phase = (phase + delay) % 2;
    if (glider_ix > 0)
      fprintf(stream, "%3d,", delay);
  }
  fprintf(stream, "  0},");
}


x86 assembly (clang, -O0):
<print_recipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xecb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fd <print_recipe+0xed>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1189 <print_recipe+0x79>
cmpl   $0x0,-0x18(%rbp)
jne    117d <print_recipe+0x6d>
movl   $0x100,-0x20(%rbp)
jmp    1184 <print_recipe+0x74>
movl   $0xff,-0x20(%rbp)
jmp    11ba <print_recipe+0xaa>
cmpl   $0x1,-0x20(%rbp)
jne    11b5 <print_recipe+0xa5>
cmpl   $0x0,-0x18(%rbp)
jne    11a9 <print_recipe+0x99>
movl   $0xff,-0x20(%rbp)
jmp    11b0 <print_recipe+0xa0>
movl   $0x100,-0x20(%rbp)
jmp    11b5 <print_recipe+0xa5>
jmp    11ba <print_recipe+0xaa>
mov    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11ea <print_recipe+0xda>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11ef <print_recipe+0xdf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1143 <print_recipe+0x33>
mov    -0x8(%rbp),%rdi
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_recipe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x7b,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
test   %r15d,%r15d
jle    117a <print_recipe+0x4a>
mov    (%r14),%ebp
test   %ebp,%ebp
je     116f <print_recipe+0x3f>
cmp    $0x1,%ebp
jne    1167 <print_recipe+0x37>
mov    $0xff,%ebp
cmp    $0x1,%r15d
je     117a <print_recipe+0x4a>
jmp    11a1 <print_recipe+0x71>
mov    $0x100,%ebp
cmp    $0x1,%r15d
jne    11a1 <print_recipe+0x71>
lea    0xe84(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r12,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>
mov    %r15d,%r13d
mov    $0x1,%ebx
lea    0xe50(%rip),%r15
jmp    11e3 <print_recipe+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x1,%ebp
mov    $0x100,%edx
sbb    $0x0,%edx
add    %edx,%ebp
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
je     117a <print_recipe+0x4a>
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebp
mov    (%r14,%rbx,4),%edx
cmp    $0x1,%edx
je     11c0 <print_recipe+0x90>
test   %edx,%edx
jne    11cb <print_recipe+0x9b>
cmp    $0x1,%ebp
mov    $0xff,%edx
adc    $0x0,%edx
jmp    11cb <print_recipe+0x9b>

LLVM IR (-O0):
@.str = [2 x i8] c"{\00"
@.str.1 = [5 x i8] c"%3d,\00"
@.str.2 = [6 x i8] c" 0},\00"
define void @print_recipe(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%10 = load i32*, i32** %4
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %12
12: ; preds = %52, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %55
16: ; preds = %12
%17 = load i32*, i32** %5
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %16
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 256, i32* %9
br label %29
28: ; preds = %24
store i32 255, i32* %9
br label %29
29: ; preds = %28, %27
br label %40
30: ; preds = %16
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 255, i32* %9
br label %38
37: ; preds = %33
store i32 256, i32* %9
br label %38
38: ; preds = %37, %36
br label %39
39: ; preds = %38, %30
br label %40
40: ; preds = %39, %29
%41 = load i32, i32* %7
%42 = load i32, i32* %9
%43 = add nsw i32 %41, %42
%44 = srem i32 %43, 2
store i32 %44, i32* %7
%45 = load i32, i32* %8
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %40
%48 = load i32*, i32** %4
%49 = load i32, i32* %9
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %47, %40
br label %52
52: ; preds = %51
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %12
55: ; preds = %12
%56 = load i32*, i32** %4
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%3d,\00"
@.str.2 = [6 x i8] c" 0},\00"
define void @print_recipe(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32 @fputc(i32 123, i32* %0)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %32
6: ; preds = %3
%7 = zext i32 %2 to i64
%8 = load i32, i32* %1
switch i32 %8, label %11 [
i32 0, label %10
i32 1, label %9
]
9: ; preds = %6
br label %11
10: ; preds = %6
br label %11
11: ; preds = %6, %9, %10
%12 = phi i32 [ 256, %10 ], [ %8, %6 ], [ 255, %9 ]
%13 = icmp eq i32 %2, 1
br i1 %13, label %32, label %14
14: ; preds = %11, %26
%15 = phi i64 [ %30, %26 ], [ 1, %11 ]
%16 = phi i32 [ %28, %26 ], [ %12, %11 ]
%17 = srem i32 %16, 2
%18 = getelementptr inbounds i32, i32* %1, i64 %15
%19 = load i32, i32* %18
switch i32 %19, label %26 [
i32 0, label %20
i32 1, label %23
]
20: ; preds = %14
%21 = icmp eq i32 %17, 0
%22 = select i1 %21, i32 256, i32 255
br label %26
23: ; preds = %14
%24 = icmp eq i32 %17, 0
%25 = select i1 %24, i32 255, i32 256
br label %26
26: ; preds = %23, %14, %20
%27 = phi i32 [ %22, %20 ], [ %19, %14 ], [ %25, %23 ]
%28 = add nsw i32 %27, %17
%29 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%30 = add nuw nsw i64 %15, 1
%31 = icmp eq i64 %30, %7
br i1 %31, label %32, label %14
32: ; preds = %26, %11, %3
%33 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5, i64 1, i32* %0)
ret void
}