#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 print_fact(int *arr, int n) {
  int i = n - 1;
  while (arr[i] == 0) {
    i--;
  }
  for (i; i >= 0; i--) {
    printf("%d", arr[i]);
  }
}


x86 assembly (clang, -O0):
<print_fact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1148 <print_fact+0x38>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1128 <print_fact+0x18>
cmpl   $0x0,-0x10(%rbp)
jl     1177 <print_fact+0x67>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <print_fact+0x38>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_fact>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
movslq %esi,%rax
lea    0x1(%rax),%ecx
xchg   %ax,%ax
add    $0xffffffff,%ecx
cmpl   $0x0,-0x4(%r15,%rax,4)
lea    -0x1(%rax),%rax
je     1120 <print_fact+0x10>
test   %ecx,%ecx
jle    1157 <print_fact+0x47>
mov    %eax,%ebx
lea    0xec4(%rip),%r14
nopl   0x0(%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
lea    0x1(%rbx),%eax
test   %eax,%eax
jg     1140 <print_fact+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @print_fact(i32* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
br label %4
4: ; preds = %4, %2
%5 = phi i64 [ %6, %4 ], [ %3, %2 ]
%6 = add nsw i64 %5, -1
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %4
%11 = trunc i64 %5 to i32
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = and i64 %6, 4294967295
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ %14, %13 ], [ %20, %15 ]
%17 = getelementptr inbounds i32, i32* %0, i64 %16
%18 = load i32, i32* %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = add nsw i64 %16, -1
%21 = trunc i64 %16 to i32
%22 = icmp sgt i32 %21, 0
br i1 %22, label %15, label %23
23: ; preds = %15, %10
ret void
}