#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 uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void nextFibonacciUntil_(uint64_t n1, uint64_t n2, int times, int until,
                         int type) {
  if (type == 1 && times >= until) {
    puts(".");
    return;
  }
  if (times == 0) {
    n1 = -1;
    n2 = 0;
  } else if (times == 1) {
    n1 = 0;
    n2 = 1;
  } else {
    uint64_t temp = n1;
    n1 = n2;
    n2 += temp;
  }
  if (type != 1 && n2 > until) {
    puts(".");
    return;
  }
  if (times) {
    printf(", ");
  }
  printf("%lu", n2);
  nextFibonacciUntil_(n1, n2, times + 1, until, type);
}


x86 assembly (clang, -O0):
<nextFibonacciUntil_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    116f <nextFibonacciUntil_+0x3f>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     116f <nextFibonacciUntil_+0x3f>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
jmp    122b <nextFibonacciUntil_+0xfb>
cmpl   $0x0,-0xc(%rbp)
jne    118c <nextFibonacciUntil_+0x5c>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
jmp    11c3 <nextFibonacciUntil_+0x93>
cmpl   $0x1,-0xc(%rbp)
jne    11a9 <nextFibonacciUntil_+0x79>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
jmp    11be <nextFibonacciUntil_+0x8e>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11c3 <nextFibonacciUntil_+0x93>
cmpl   $0x1,-0x14(%rbp)
je     11ea <nextFibonacciUntil_+0xba>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11ea <nextFibonacciUntil_+0xba>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
jmp    122b <nextFibonacciUntil_+0xfb>
cmpl   $0x0,-0xc(%rbp)
je     1202 <nextFibonacciUntil_+0xd2>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1050 <nextFibonacciUntil_@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextFibonacciUntil_>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%r13d
cmp    $0x1,%r8d
jne    1148 <nextFibonacciUntil_+0x28>
cmp    %r14d,%ebp
jge    11f8 <nextFibonacciUntil_+0xd8>
cmp    $0x1,%r15d
setne  %al
test   %r14d,%r14d
setle  %cl
sets   %dl
and    %al,%cl
mov    %cl,0x7(%rsp)
and    %al,%dl
mov    %dl,0x6(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
je     1190 <nextFibonacciUntil_+0x70>
cmp    $0x1,%ebp
jne    11b0 <nextFibonacciUntil_+0x90>
cmpb   $0x0,0x7(%rsp)
jne    11f8 <nextFibonacciUntil_+0xd8>
xor    %r12d,%r12d
mov    $0x1,%r13d
jmp    11be <nextFibonacciUntil_+0x9e>
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x6(%rsp)
jne    11f8 <nextFibonacciUntil_+0xd8>
mov    $0xffffffff,%r13d
xor    %r12d,%r12d
jmp    11d5 <nextFibonacciUntil_+0xb5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %r12d,%r13d
cmp    $0x1,%r15d
je     11be <nextFibonacciUntil_+0x9e>
cmp    %r14d,%r13d
jg     11f8 <nextFibonacciUntil_+0xd8>
mov    %r12d,%ebx
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%r12d
mov    %ebx,%r13d
lea    0xe29(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x1,%r15d
jne    1170 <nextFibonacciUntil_+0x50>
cmp    %r14d,%ebp
jl     1170 <nextFibonacciUntil_+0x50>
lea    0xe01(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [4 x i8] c"%lu\00"
define void @nextFibonacciUntil_(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp ne i32 %4, 1
%7 = icmp slt i32 %2, %3
%8 = or i1 %6, %7
br i1 %8, label %9, label %35
9: ; preds = %5
%10 = icmp slt i32 %3, 1
%11 = and i1 %10, %6
%12 = icmp slt i32 %3, 0
%13 = and i1 %12, %6
br label %14
14: ; preds = %9, %28
%15 = phi i32 [ %2, %9 ], [ %32, %28 ]
%16 = phi i32 [ %1, %9 ], [ %29, %28 ]
%17 = phi i32 [ %0, %9 ], [ %30, %28 ]
switch i32 %15, label %18 [
i32 0, label %22
i32 1, label %23
]
18: ; preds = %14
%19 = add nsw i32 %16, %17
%20 = icmp sgt i32 %19, %3
%21 = select i1 %6, i1 %20, i1 false
br i1 %21, label %35, label %24
22: ; preds = %14
br i1 %13, label %35, label %28
23: ; preds = %14
br i1 %11, label %35, label %24
24: ; preds = %18, %23
%25 = phi i32 [ 1, %23 ], [ %19, %18 ]
%26 = phi i32 [ 0, %23 ], [ %16, %18 ]
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %22, %24
%29 = phi i32 [ %25, %24 ], [ 0, %22 ]
%30 = phi i32 [ %26, %24 ], [ -1, %22 ]
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%32 = add nsw i32 %15, 1
%33 = icmp slt i32 %32, %3
%34 = or i1 %6, %33
br i1 %34, label %14, label %35
35: ; preds = %18, %23, %22, %28, %5
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}