#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*/ fun(unsigned int, unsigned int, unsigned int, unsigned int);
void written_amount(unsigned int amount) {
  unsigned int temp_number = amount;
  unsigned int number_digit = 1;
  unsigned int number[18] = {0};
  unsigned int temp = 0;
  while (temp_number /= 10) {
    number_digit++;
  }
  temp_number = amount;
  for (temp = 0; temp <= 17; temp++) {
    number[17 - temp] = temp_number % 10;
    temp_number /= 10;
  }
  for (temp = 0; temp < 18; temp += 3) {
    fun(number[temp], number[temp + 1], number[temp + 2], temp);
  }
}


x86 assembly (clang, -O0):
<written_amount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1175 <written_amount+0x55>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <written_amount+0x2f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x11,-0x64(%rbp)
ja     11c3 <written_amount+0xa3>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    $0x11,%eax
sub    -0x64(%rbp),%eax
mov    %eax,%eax
mov    %edx,-0x60(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x8(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1182 <written_amount+0x62>
movl   $0x0,-0x64(%rbp)
cmpl   $0x12,-0x64(%rbp)
jae    1209 <written_amount+0xe9>
mov    -0x64(%rbp),%eax
mov    -0x60(%rbp,%rax,4),%edi
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    -0x60(%rbp,%rax,4),%esi
mov    -0x64(%rbp),%eax
add    $0x2,%eax
mov    %eax,%eax
mov    -0x60(%rbp,%rax,4),%edx
mov    -0x64(%rbp),%ecx
call   1030 <fun@plt>
mov    -0x64(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x64(%rbp)
jmp    11ca <written_amount+0xaa>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<written_amount>:
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x40(%rsp)
mov    $0x12,%eax
mov    $0xcccccccd,%r8d
xchg   %ax,%ax
mov    %edi,%edx
mov    %rdx,%rsi
imul   %r8,%rsi
shr    $0x23,%rsi
lea    (%rsi,%rsi,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%edi
mov    %edi,-0x4(%rsp,%rax,4)
mov    %rsi,%rcx
imul   %r8,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
mov    %esi,-0x8(%rsp,%rax,4)
imul   $0x51eb851f,%rdx,%rdi
shr    $0x25,%rdi
add    $0xfffffffffffffffe,%rax
jne    1140 <written_amount+0x30>
mov    (%rsp),%edi
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
xor    %ecx,%ecx
call   1030 <fun@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    $0x3,%ecx
call   1030 <fun@plt>
mov    0x18(%rsp),%edi
mov    0x1c(%rsp),%esi
mov    0x20(%rsp),%edx
mov    $0x6,%ecx
call   1030 <fun@plt>
mov    0x24(%rsp),%edi
mov    0x28(%rsp),%esi
mov    0x2c(%rsp),%edx
mov    $0x9,%ecx
call   1030 <fun@plt>
mov    0x30(%rsp),%edi
mov    0x34(%rsp),%esi
mov    0x38(%rsp),%edx
mov    $0xc,%ecx
call   1030 <fun@plt>
mov    0x3c(%rsp),%edi
mov    0x40(%rsp),%esi
mov    0x44(%rsp),%edx
mov    $0xf,%ecx
add    $0x48,%rsp
jmp    1030 <fun@plt>

LLVM IR (-O0):
define void @written_amount(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [18 x i32]
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
store i32 %7, i32* %3
store i32 1, i32* %4
%8 = bitcast [18 x i32]* %5 to i8*
store i32 0, i32* %6
br label %9
9: ; preds = %13, %1
%10 = load i32, i32* %3
%11 = udiv i32 %10, 10
store i32 %11, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %4
%15 = add i32 %14, 1
store i32 %15, i32* %4
br label %9
16: ; preds = %9
%17 = load i32, i32* %2
store i32 %17, i32* %3
store i32 0, i32* %6
br label %18
18: ; preds = %30, %16
%19 = load i32, i32* %6
%20 = icmp ule i32 %19, 17
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = load i32, i32* %3
%23 = urem i32 %22, 10
%24 = load i32, i32* %6
%25 = sub i32 17, %24
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [18 x i32], [18 x i32]* %5, i64 0, i64 %26
store i32 %23, i32* %27
%28 = load i32, i32* %3
%29 = udiv i32 %28, 10
store i32 %29, i32* %3
br label %30
30: ; preds = %21
%31 = load i32, i32* %6
%32 = add i32 %31, 1
store i32 %32, i32* %6
br label %18
33: ; preds = %18
store i32 0, i32* %6
br label %34
34: ; preds = %54, %33
%35 = load i32, i32* %6
%36 = icmp ult i32 %35, 18
br i1 %36, label %37, label %57
37: ; preds = %34
%38 = load i32, i32* %6
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [18 x i32], [18 x i32]* %5, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = load i32, i32* %6
%43 = add i32 %42, 1
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [18 x i32], [18 x i32]* %5, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %6
%48 = add i32 %47, 2
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [18 x i32], [18 x i32]* %5, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %6
%53 = call i32 @fun(i32 %41, i32 %46, i32 %51, i32 %52)
br label %54
54: ; preds = %37
%55 = load i32, i32* %6
%56 = add i32 %55, 3
store i32 %56, i32* %6
br label %34
57: ; preds = %34
ret void
}

LLVM IR (-O2):
define void @written_amount(i32 %0) {
%2 = alloca [18 x i32]
%3 = bitcast [18 x i32]* %2 to i8*
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ 0, %1 ], [ %15, %4 ]
%6 = phi i32 [ %0, %1 ], [ %14, %4 ]
%7 = urem i32 %6, 10
%8 = sub nuw nsw i64 17, %5
%9 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 %8
store i32 %7, i32* %9
%10 = udiv i32 %6, 10
%11 = urem i32 %10, 10
%12 = sub nsw i64 16, %5
%13 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 %12
store i32 %11, i32* %13
%14 = udiv i32 %6, 100
%15 = add nuw nsw i64 %5, 2
%16 = icmp eq i64 %15, 18
br i1 %16, label %17, label %4
17: ; preds = %4
%18 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 2
%23 = load i32, i32* %22
%24 = tail call i32 @fun(i32 %19, i32 %21, i32 %23, i32 0)
%25 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 3
%26 = load i32, i32* %25
%27 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 4
%28 = load i32, i32* %27
%29 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 5
%30 = load i32, i32* %29
%31 = tail call i32 @fun(i32 %26, i32 %28, i32 %30, i32 3)
%32 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 6
%33 = load i32, i32* %32
%34 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 7
%35 = load i32, i32* %34
%36 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 8
%37 = load i32, i32* %36
%38 = tail call i32 @fun(i32 %33, i32 %35, i32 %37, i32 6)
%39 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 9
%40 = load i32, i32* %39
%41 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 10
%42 = load i32, i32* %41
%43 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 11
%44 = load i32, i32* %43
%45 = tail call i32 @fun(i32 %40, i32 %42, i32 %44, i32 9)
%46 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 12
%47 = load i32, i32* %46
%48 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 13
%49 = load i32, i32* %48
%50 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 14
%51 = load i32, i32* %50
%52 = tail call i32 @fun(i32 %47, i32 %49, i32 %51, i32 12)
%53 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 15
%54 = load i32, i32* %53
%55 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 16
%56 = load i32, i32* %55
%57 = getelementptr inbounds [18 x i32], [18 x i32]* %2, i64 0, i64 17
%58 = load i32, i32* %57
%59 = tail call i32 @fun(i32 %54, i32 %56, i32 %58, i32 15)
ret void
}