#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*/ printf(char *, ...);
void isTribonacci(int media) {
  printf("\nThe number is in Tribonacci number?\n");
  const int number = media;
  printf("The number generated is %d", number);
  int a = 0;
  int b = 1;
  int c = 1;
  int result = 0;
  if (media == 0) {
    result = a;
    printf("\nbase case\n");
  }
  if (media == 1) {
    result = b;
    printf("\nbase case\n");
  }
  if (media == 2) {
    result = c;
    printf("\nbase case\n");
  }
  while (media > 2) {
    result = a + b + c;
    a = b;
    b = c;
    c = result;
    media--;
    if (result == number) {
      printf(" The number %d is in Tribonacci series", number);
      break;
    }
    if (media == 3) {
      printf(" I'm sorry  isn't in the series!");
    }
  }
}


x86 assembly (clang, -O0):
<isTribonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    117a <isTribonacci+0x6a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1198 <isTribonacci+0x88>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x4(%rbp)
jne    11b6 <isTribonacci+0xa6>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bb <isTribonacci+0xab>
cmpl   $0x2,-0x4(%rbp)
jle    122b <isTribonacci+0x11b>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    120e <isTribonacci+0xfe>
mov    -0x8(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <isTribonacci+0x11b>
cmpl   $0x3,-0x4(%rbp)
jne    1226 <isTribonacci+0x116>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bb <isTribonacci+0xab>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isTribonacci>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
lea    0xf2e(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r15d
je     115c <isTribonacci+0x3c>
cmp    $0x1,%r15d
je     115c <isTribonacci+0x3c>
test   %r15d,%r15d
jne    1176 <isTribonacci+0x56>
lea    0xf25(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
cmp    $0x3,%r15d
jl     11cf <isTribonacci+0xaf>
lea    0x1(%r15),%ebp
mov    $0x1,%ebx
lea    0xeb6(%rip),%r14
mov    $0x1,%r12d
xor    %r13d,%r13d
jmp    11a8 <isTribonacci+0x88>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
cmp    $0x3,%ebp
jbe    11cf <isTribonacci+0xaf>
mov    %r13d,%eax
mov    %r12d,%r13d
mov    %ebx,%r12d
add    %r13d,%eax
mov    %eax,%ebx
add    %r12d,%ebx
cmp    %r15d,%ebx
je     11de <isTribonacci+0xbe>
cmp    $0x5,%ebp
jne    11a0 <isTribonacci+0x80>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <isTribonacci+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe36(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"\0AThe number is in Tribonacci number?\0A\00"
@.str.1 = [27 x i8] c"The number generated is %d\00"
@.str.2 = [12 x i8] c"\0Abase case\0A\00"
@.str.3 = [39 x i8] c" The number %d is in Tribonacci series\00"
@.str.4 = [33 x i8] c" I'm sorry isn't in the series!\00"
define void @isTribonacci(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* %2
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %10)
store i32 0, i32* %4
store i32 1, i32* %5
store i32 1, i32* %6
store i32 0, i32* %7
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i32, i32* %4
store i32 %15, i32* %7
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %14, %1
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %5
store i32 %21, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %20, %17
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %6
store i32 %27, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %55, %29
%31 = load i32, i32* %2
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %56
33: ; preds = %30
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = add nsw i32 %34, %35
%37 = load i32, i32* %6
%38 = add nsw i32 %36, %37
store i32 %38, i32* %7
%39 = load i32, i32* %5
store i32 %39, i32* %4
%40 = load i32, i32* %6
store i32 %40, i32* %5
%41 = load i32, i32* %7
store i32 %41, i32* %6
%42 = load i32, i32* %2
%43 = add nsw i32 %42, -1
store i32 %43, i32* %2
%44 = load i32, i32* %7
%45 = load i32, i32* %3
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %33
%48 = load i32, i32* %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %48)
br label %56
50: ; preds = %33
%51 = load i32, i32* %2
%52 = icmp eq i32 %51, 3
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
br label %30
56: ; preds = %47, %30
ret void
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"The number generated is %d\00"
@.str.3 = [39 x i8] c" The number %d is in Tribonacci series\00"
@.str.4 = [33 x i8] c" I'm sorry isn't in the series!\00"
@str = [37 x i8] c"\0AThe number is in Tribonacci number?\00"
@str.7 = [11 x i8] c"\0Abase case\00"
define void @isTribonacci(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %0)
switch i32 %0, label %10 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
]
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
br label %29
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
br label %29
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
br label %29
10: ; preds = %1
%11 = icmp sgt i32 %0, 2
br i1 %11, label %12, label %29
12: ; preds = %10, %27
%13 = phi i32 [ %18, %27 ], [ 1, %10 ]
%14 = phi i32 [ %13, %27 ], [ 1, %10 ]
%15 = phi i32 [ %14, %27 ], [ 0, %10 ]
%16 = phi i32 [ %19, %27 ], [ %0, %10 ]
%17 = add nsw i32 %14, %15
%18 = add nsw i32 %17, %13
%19 = add nsw i32 %16, -1
%20 = icmp eq i32 %18, %0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %29
23: ; preds = %12
%24 = icmp eq i32 %19, 3
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = icmp ugt i32 %16, 3
br i1 %28, label %12, label %29
29: ; preds = %27, %8, %4, %6, %10, %21
ret void
}