#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 /*<<< orphan*/ printf(char *, int);
int main() {
  int a[] = {1, 2, 3, 4, 5};
  int size = sizeof(a) / sizeof(a[0]);
  int products[size];
  int p = 1;
  for (int i = 0; i < size; ++i) {
    products[i] = p;
    p *= a[i];
  }
  p = 1;
  for (int i = size - 1; i >= 0; --i) {
    products[i] *= p;
    p *= a[i];
  }
  for (int i = 0; i < size; i++) {
    printf("%d ", products[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeeb(%rip),%eax
mov    %eax,-0x10(%rbp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movl   $0x5,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11a6 <main+0x96>
mov    -0x50(%rbp),%rax
mov    -0x3c(%rbp),%edx
movslq -0x40(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x40(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
imul   -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    116f <main+0x5f>
movl   $0x1,-0x3c(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jl     11ef <main+0xdf>
mov    -0x50(%rbp),%rax
mov    -0x3c(%rbp),%edx
movslq -0x44(%rbp),%rcx
imul   (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
movslq -0x44(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
imul   -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    11b6 <main+0xa6>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1227 <main+0x117>
mov    -0x50(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe00(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11f6 <main+0xe6>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x78,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x18,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [5 x i32]* %2 to i8*
store i32 5, i32* %3
%11 = load i32, i32* %3
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %4
%14 = alloca i32, i64 %12
store i64 %12, i64* %5
store i32 1, i32* %6
store i32 0, i32* %7
br label %15
15: ; preds = %30, %0
%16 = load i32, i32* %7
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %14, i64 %22
store i32 %20, i32* %23
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, %27
store i32 %29, i32* %6
br label %30
30: ; preds = %19
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %15
33: ; preds = %15
store i32 1, i32* %6
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
store i32 %35, i32* %8
br label %36
36: ; preds = %52, %33
%37 = load i32, i32* %8
%38 = icmp sge i32 %37, 0
br i1 %38, label %39, label %55
39: ; preds = %36
%40 = load i32, i32* %6
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %14, i64 %42
%44 = load i32, i32* %43
%45 = mul nsw i32 %44, %40
store i32 %45, i32* %43
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = load i32, i32* %6
%51 = mul nsw i32 %50, %49
store i32 %51, i32* %6
br label %52
52: ; preds = %39
%53 = load i32, i32* %8
%54 = add nsw i32 %53, -1
store i32 %54, i32* %8
br label %36
55: ; preds = %36
store i32 0, i32* %9
br label %56
56: ; preds = %66, %55
%57 = load i32, i32* %9
%58 = load i32, i32* %3
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %69
60: ; preds = %56
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %14, i64 %62
%64 = load i32, i32* %63
%65 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %60
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %56
69: ; preds = %56
store i32 0, i32* %1
%70 = load i8*, i8** %4
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 120)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 60)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 40)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 30)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 24)
ret i32 0
}