#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 checkIfTribonacci(int media) {
  const int number = media;
  int a = 0;
  int b = 1;
  int c = 1;
  int result = 0;
  if (media == 0) {
    result = a;
    printf("%d is part of Tribonacci Sequence\n", result);
  }
  if (media == 1) {
    result = b;
    printf("\n %d  is a part of Tribonacci Sequence\n", result);
  }
  if (media == 2) {
    result = c;
    printf("\n %d  is part of Tribonacci Sequence\n", result);
  }
  while (media > 2) {
    result = a + b + c;
    a = b;
    b = c;
    c = result;
    media--;
    if (result == number) {
      printf("\n");
      printf("%d is part of Tribonacci number\n", number);
      break;
    }
    if (media == 3) {
      printf(" I'm sorry %d isn't in the series!", number);
    }
  }
}


x86 assembly (clang, -O0):
<checkIfTribonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    115e <checkIfTribonacci+0x4e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    117f <checkIfTribonacci+0x6f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x4(%rbp)
jne    11a0 <checkIfTribonacci+0x90>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a5 <checkIfTribonacci+0x95>
cmpl   $0x2,-0x4(%rbp)
jle    1226 <checkIfTribonacci+0x116>
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    1206 <checkIfTribonacci+0xf6>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1226 <checkIfTribonacci+0x116>
cmpl   $0x3,-0x4(%rbp)
jne    1221 <checkIfTribonacci+0x111>
mov    -0x8(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a5 <checkIfTribonacci+0x95>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkIfTribonacci>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
je     1148 <checkIfTribonacci+0x28>
mov    %edi,%r15d
cmp    $0x1,%edi
je     1151 <checkIfTribonacci+0x31>
test   %r15d,%r15d
jne    1172 <checkIfTribonacci+0x52>
lea    0xebc(%rip),%rdi
xor    %esi,%esi
jmp    115d <checkIfTribonacci+0x3d>
lea    0xefc(%rip),%rdi
jmp    1158 <checkIfTribonacci+0x38>
lea    0xecb(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
cmp    $0x3,%r15d
jl     11d2 <checkIfTribonacci+0xb2>
lea    0x1(%r15),%ebp
mov    $0x1,%ebx
lea    0xf0a(%rip),%r14
mov    $0x1,%r12d
xor    %r13d,%r13d
jmp    11a8 <checkIfTribonacci+0x88>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%ebp
cmp    $0x3,%ebp
jbe    11d2 <checkIfTribonacci+0xb2>
mov    %r13d,%eax
mov    %r12d,%r13d
mov    %ebx,%r12d
add    %r13d,%eax
mov    %eax,%ebx
add    %r12d,%ebx
cmp    %r15d,%ebx
je     11e1 <checkIfTribonacci+0xc1>
cmp    $0x5,%ebp
jne    11a0 <checkIfTribonacci+0x80>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <checkIfTribonacci+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe7f(%rip),%rdi
mov    %r15d,%esi
jmp    115d <checkIfTribonacci+0x3d>

LLVM IR (-O0):
@.str = [35 x i8] c"%d is part of Tribonacci Sequence\0A\00"
@.str.1 = [40 x i8] c"\0A %d is a part of Tribonacci Sequence\0A\00"
@.str.2 = [38 x i8] c"\0A %d is part of Tribonacci Sequence\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [33 x i8] c"%d is part of Tribonacci number\0A\00"
@.str.5 = [35 x i8] c" I'm sorry %d isn't in the series!\00"
define void @checkIfTribonacci(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 = load i32, i32* %2
store i32 %8, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
store i32 1, i32* %6
store i32 0, i32* %7
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i32, i32* %4
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %11, %1
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %5
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %18, %15
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* %6
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %22
br label %30
30: ; preds = %57, %29
%31 = load i32, i32* %2
%32 = icmp sgt i32 %31, 2
br i1 %32, label %33, label %58
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 %51
47: ; preds = %33
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%49 = load i32, i32* %3
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %49)
br label %58
51: ; preds = %33
%52 = load i32, i32* %2
%53 = icmp eq i32 %52, 3
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %3
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %54, %51
br label %30
58: ; preds = %47, %30
ret void
}

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