#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 /*<<< orphan*/ a;

/* Variables and functions */
int fun(int *, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int a[] = {1, 1, 1, 2, 2, 3, 3, 4, 5, 4}, i, n;
  n = fun(a, sizeof(a) / sizeof(int));
  for (i = 0; i < n; printf("%3d", a[i++]))
    ;
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1030 <fun@plt>
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    11af <main+0x6f>
jmp    118d <main+0x4d>
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x34(%rbp)
cltq
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
jmp    117c <main+0x3c>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xee0(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1030 <fun@plt>
test   %eax,%eax
jle    1194 <main+0x64>
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0xeaf(%rip),%r14
nopl   0x0(%rax)
mov    (%rsp,%rbx,4),%esi
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <printf@plt>
cmp    %rbx,%r15
jne    1180 <main+0x50>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [10 x i32] [i32 1, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 5, i32 4]
@.str = [4 x i8] c"%3d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [10 x i32]* %2 to i8*
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%7 = call i32 @fun(i32* %6, i32 10)
store i32 %7, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %13, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
br label %13
13: ; preds = %12
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %8
20: ; preds = %8
%21 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [10 x i32] [i32 1, i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4, i32 5, i32 4]
@.str = [4 x i8] c"%3d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call i32 @fun(i32* %3, i32 10)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %0
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %10, %8 ]
%10 = add nuw nsw i64 %9, 1
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %9
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = icmp eq i64 %10, %7
br i1 %14, label %15, label %8
15: ; preds = %8, %0
%16 = call i32 (...) @getchar()
ret i32 0
}