#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 *, int);
void fib_division(int x) {
  int arr[9];
  int i = 0, first = 0, second = 1, new_second;
  while (i < 10) {
    new_second = first + second;
    first = second;
    second = new_second;
    if (new_second % x == 0) {
      arr[i] = new_second;
      i++;
    }
  }
  for (int i = 0; i < 10; ++i)
    printf("%d\n", arr[i]);
}


x86 assembly (clang, -O0):
<fib_division>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1178 <fib_division+0x68>
mov    -0x38(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
cltd
idivl  -0x4(%rbp)
cmp    $0x0,%edx
jne    1173 <fib_division+0x63>
mov    -0x40(%rbp),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1130 <fib_division+0x20>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    11ab <fib_division+0x9b>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    117f <fib_division+0x6f>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib_division>:
push   %rbx
sub    $0x30,%rsp
mov    $0x1,%ecx
xor    %esi,%esi
xor    %ebx,%ebx
jmp    1125 <fib_division+0x15>
cmp    $0xa,%esi
jge    1141 <fib_division+0x31>
mov    %ebx,%eax
mov    %ecx,%ebx
mov    %eax,%ecx
add    %ebx,%ecx
mov    %ecx,%eax
cltd
idiv   %edi
test   %edx,%edx
jne    1120 <fib_division+0x10>
movslq %esi,%rsi
mov    %ecx,(%rsp,%rsi,4)
add    $0x1,%esi
jmp    1120 <fib_division+0x10>
mov    (%rsp),%esi
lea    0xeb5(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
add    $0x30,%rsp
pop    %rbx
jmp    1030 <printf@plt>

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

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