#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 */
char EOF;
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char getopt(int, char **, char *);
int /*<<< orphan*/ help();
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
void conway(int argc, char *argv[]) {
  int N;
  char ch;
  while ((ch = getopt(argc, argv, "hN:")) != EOF)
    switch (ch) {
    case 'N':
      N = atoi(optarg);
      break;
    case 'h':
      help();
      break;
    default:
      fprintf(stderr, "Unknown option for conway: '%s'\n", optarg);
      help();
    }
  argc -= optind;
  argv += optind;
  double output;
  int a[N];
  long int n = 0;
  for (; n < N; n++) {
    if (n < 3) {
      a[n] = 1;
      output = 1;
    } else {
      a[n] = a[a[n - 1]] + a[n - a[n - 1]];
      output = (double)a[n] - ((double)n / 2.0);
    }
    printf("%.6f\n", output);
  }
}


x86 assembly (clang, -O0):
<conway>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea3(%rip),%rdx
call   1050 <getopt@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2e61(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11fe <conway+0xae>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x4e,%eax
je     11b0 <conway+0x60>
jmp    119f <conway+0x4f>
mov    -0x3c(%rbp),%eax
sub    $0x68,%eax
je     11c7 <conway+0x77>
jmp    11d3 <conway+0x83>
mov    0x2e41(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    11f9 <conway+0xa9>
mov    $0x0,%al
call   1060 <help@plt>
jmp    11f9 <conway+0xa9>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    0x2e15(%rip),%rax
mov    (%rax),%rdx
lea    0xe27(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <help@plt>
jmp    115f <conway+0xf>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edx
mov    -0x4(%rbp),%ecx
sub    %edx,%ecx
mov    %ecx,-0x4(%rbp)
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
lea    (%rax,%rcx,8),%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jge    1300 <conway+0x1b0>
cmpq   $0x3,-0x38(%rbp)
jge    128a <conway+0x13a>
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
movsd  0xd88(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    12de <conway+0x18e>
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movslq (%rax,%rcx,4),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x38(%rbp),%rcx
mov    -0x38(%rbp),%rsi
sub    $0x1,%rsi
movslq (%rax,%rsi,4),%rsi
sub    %rsi,%rcx
add    (%rax,%rcx,4),%edx
mov    -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
cvtsi2sdq -0x38(%rbp),%xmm1
movsd  0xd2f(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xd4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    124d <conway+0xfd>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conway>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xea6(%rip),%rdx
call   1050 <getopt@plt>
mov    0x2e6a(%rip),%r13
cmp    0x0(%r13),%al
je     12d9 <conway+0x189>
lea    0xe89(%rip),%r12
jmp    11c9 <conway+0x79>
nopl   0x0(%rax)
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    0x2e58(%rip),%rax
mov    (%rax),%rdx
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <help@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
cmp    0x0(%r13),%al
je     11ea <conway+0x9a>
movsbl %al,%eax
cmp    $0x68,%eax
je     11af <conway+0x5f>
cmp    $0x4e,%eax
jne    1190 <conway+0x40>
mov    0x2e1b(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
jmp    11b6 <conway+0x66>
mov    %r14d,%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
test   %r14d,%r14d
jle    12d9 <conway+0x189>
movl   $0x1,(%r12)
lea    0xe1b(%rip),%rdi
movsd  0xdde(%rip),%xmm0
call   1030 <printf@plt>
cmp    $0x1,%r14d
je     12d9 <conway+0x189>
movl   $0x1,0x4(%r12)
lea    0xdf4(%rip),%rdi
movsd  0xdb7(%rip),%xmm0
call   1030 <printf@plt>
cmp    $0x2,%r14d
je     12d9 <conway+0x189>
movl   $0x1,0x8(%r12)
lea    0xdcd(%rip),%rdi
movsd  0xd90(%rip),%xmm0
call   1030 <printf@plt>
cmp    $0x3,%r14d
je     12d9 <conway+0x189>
movslq %r14d,%r15
mov    $0x3,%r13d
mov    $0x1,%ebx
lea    0xda5(%rip),%r14
movslq %ebx,%rax
lea    0x0(,%rax,4),%rcx
mov    %r12,%rdx
sub    %rcx,%rdx
mov    (%rdx,%r13,4),%ebx
add    (%r12,%rax,4),%ebx
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r13,%xmm0
mulsd  0xd48(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    %ebx,(%r12,%r13,4)
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r15
jne    1290 <conway+0x140>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"hN:\00"
@EOF = global i8 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [33 x i8] c"Unknown option for conway: '%s'\0A\00"
@optind = global i64 0
@.str.2 = [6 x i8] c"%.6f\0A\00"
define void @conway(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8
%7 = alloca double
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
br label %11
11: ; preds = %32, %2
%12 = load i32, i32* %3
%13 = load i8**, i8*** %4
%14 = call signext i8 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8 %14, i8* %6
%15 = sext i8 %14 to i32
%16 = load i8, i8* @EOF
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %15, %17
br i1 %18, label %19, label %33
19: ; preds = %11
%20 = load i8, i8* %6
%21 = sext i8 %20 to i32
switch i32 %21, label %27 [
i32 78, label %22
i32 104, label %25
]
22: ; preds = %19
%23 = load i8*, i8** @optarg
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %5
br label %32
25: ; preds = %19
%26 = call i32 (...) @help()
br label %32
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = load i8*, i8** @optarg
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = call i32 (...) @help()
br label %32
32: ; preds = %27, %25, %22
br label %11
33: ; preds = %11
%34 = load i64, i64* @optind
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = sub nsw i64 %36, %34
%38 = trunc i64 %37 to i32
store i32 %38, i32* %3
%39 = load i64, i64* @optind
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 %39
store i8** %41, i8*** %4
%42 = load i32, i32* %5
%43 = zext i32 %42 to i64
%44 = call i8* @llvm.stacksave()
store i8* %44, i8** %8
%45 = alloca i32, i64 %43
store i64 %43, i64* %9
store i64 0, i64* %10
br label %46
46: ; preds = %88, %33
%47 = load i64, i64* %10
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = icmp slt i64 %47, %49
br i1 %50, label %51, label %91
51: ; preds = %46
%52 = load i64, i64* %10
%53 = icmp slt i64 %52, 3
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i64, i64* %10
%56 = getelementptr inbounds i32, i32* %45, i64 %55
store i32 1, i32* %56
store double 1.000000e+00, double* %7
br label %85
57: ; preds = %51
%58 = load i64, i64* %10
%59 = sub nsw i64 %58, 1
%60 = getelementptr inbounds i32, i32* %45, i64 %59
%61 = load i32, i32* %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %45, i64 %62
%64 = load i32, i32* %63
%65 = load i64, i64* %10
%66 = load i64, i64* %10
%67 = sub nsw i64 %66, 1
%68 = getelementptr inbounds i32, i32* %45, i64 %67
%69 = load i32, i32* %68
%70 = sext i32 %69 to i64
%71 = sub nsw i64 %65, %70
%72 = getelementptr inbounds i32, i32* %45, i64 %71
%73 = load i32, i32* %72
%74 = add nsw i32 %64, %73
%75 = load i64, i64* %10
%76 = getelementptr inbounds i32, i32* %45, i64 %75
store i32 %74, i32* %76
%77 = load i64, i64* %10
%78 = getelementptr inbounds i32, i32* %45, i64 %77
%79 = load i32, i32* %78
%80 = sitofp i32 %79 to double
%81 = load i64, i64* %10
%82 = sitofp i64 %81 to double
%83 = fdiv double %82, 2.000000e+00
%84 = fsub double %80, %83
store double %84, double* %7
br label %85
85: ; preds = %57, %54
%86 = load double, double* %7
%87 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %86)
br label %88
88: ; preds = %85
%89 = load i64, i64* %10
%90 = add nsw i64 %89, 1
store i64 %90, i64* %10
br label %46
91: ; preds = %46
%92 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"hN:\00"
@EOF = global i8 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [33 x i8] c"Unknown option for conway: '%s'\0A\00"
@optind = global i64 0
@.str.2 = [6 x i8] c"%.6f\0A\00"
define void @conway(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %59, label %6
6: ; preds = %2, %20
%7 = phi i8 [ %22, %20 ], [ %3, %2 ]
%8 = phi i32 [ %21, %20 ], [ undef, %2 ]
%9 = sext i8 %7 to i32
switch i32 %9, label %15 [
i32 78, label %10
i32 104, label %13
]
10: ; preds = %6
%11 = load i8*, i8** @optarg
%12 = tail call i32 @atoi(i8* %11)
br label %20
13: ; preds = %6
%14 = tail call i32 (...) @help()
br label %20
15: ; preds = %6
%16 = load i32, i32* @stderr
%17 = load i8*, i8** @optarg
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = tail call i32 (...) @help()
br label %20
20: ; preds = %15, %13, %10
%21 = phi i32 [ %8, %15 ], [ %8, %13 ], [ %12, %10 ]
%22 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%23 = load i8, i8* @EOF
%24 = icmp eq i8 %22, %23
br i1 %24, label %25, label %6
25: ; preds = %20
%26 = zext i32 %21 to i64
%27 = alloca i32, i64 %26
%28 = sext i32 %21 to i64
%29 = icmp sgt i32 %21, 0
br i1 %29, label %30, label %59
30: ; preds = %25
store i32 1, i32* %27
%31 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 1.000000e+00)
%32 = icmp eq i32 %21, 1
br i1 %32, label %59, label %33
33: ; preds = %30
%34 = getelementptr inbounds i32, i32* %27, i64 1
store i32 1, i32* %34
%35 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 1.000000e+00)
%36 = icmp eq i32 %21, 2
br i1 %36, label %59, label %37
37: ; preds = %33
%38 = getelementptr inbounds i32, i32* %27, i64 2
store i32 1, i32* %38
%39 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 1.000000e+00)
%40 = icmp eq i32 %21, 3
br i1 %40, label %59, label %41
41: ; preds = %37, %41
%42 = phi i32 [ %50, %41 ], [ 1, %37 ]
%43 = phi i64 [ %57, %41 ], [ 3, %37 ]
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds i32, i32* %27, i64 %44
%46 = load i32, i32* %45
%47 = sub nsw i64 %43, %44
%48 = getelementptr inbounds i32, i32* %27, i64 %47
%49 = load i32, i32* %48
%50 = add nsw i32 %49, %46
%51 = sitofp i32 %50 to double
%52 = sitofp i64 %43 to double
%53 = fmul double %52, 5.000000e-01
%54 = fsub double %51, %53
%55 = getelementptr inbounds i32, i32* %27, i64 %43
store i32 %50, i32* %55
%56 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %54)
%57 = add nuw nsw i64 %43, 1
%58 = icmp eq i64 %57, %28
br i1 %58, label %59, label %41
59: ; preds = %41, %2, %30, %33, %37, %25
ret void
}