#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 pow(int, int);
int /*<<< orphan*/ printf(char *, int);
void _generateOredered(int result, int digit, int power, int limit) {
  if (power == pow(10, limit)) {
    printf("%d\n", result);
    return;
  };
  int i;
  for (i = digit; i >= 1; --i) {
    _generateOredered(result + i * power, i - 1, power * 10, limit);
  }
}


x86 assembly (clang, -O0):
<_generateOredered>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jne    1178 <_generateOredered+0x48>
mov    -0x4(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    11b4 <_generateOredered+0x84>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11b4 <_generateOredered+0x84>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%eax
imul   -0xc(%rbp),%eax
add    %eax,%edi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
imul   $0xa,-0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1040 <_generateOredered@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <_generateOredered+0x4e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_generateOredered>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%ebx
mov    $0xa,%edi
mov    %ecx,%esi
call   1050 <pow@plt>
cmp    %r15d,%eax
jne    1169 <_generateOredered+0x39>
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
test   %ebp,%ebp
jle    119b <_generateOredered+0x6b>
lea    (%r15,%r15,1),%eax
lea    (%rax,%rax,4),%r12d
mov    %r15d,%eax
imul   %ebp,%eax
add    $0x1,%ebp
add    %eax,%ebx
lea    -0x2(%rbp),%esi
mov    %ebx,%edi
mov    %r12d,%edx
mov    %r14d,%ecx
call   1040 <_generateOredered@plt>
add    $0xffffffff,%ebp
sub    %r15d,%ebx
cmp    $0x1,%ebp
ja     1180 <_generateOredered+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @_generateOredered(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @pow(i32 10, i32 %3)
%6 = icmp eq i32 %5, %2
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %19
9: ; preds = %7
%10 = mul nsw i32 %2, 10
br label %13
11: ; preds = %4
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %19
13: ; preds = %9, %13
%14 = phi i32 [ %1, %9 ], [ %17, %13 ]
%15 = mul nsw i32 %14, %2
%16 = add nsw i32 %15, %0
%17 = add nsw i32 %14, -1
tail call void @_generateOredered(i32 %16, i32 %17, i32 %10, i32 %3)
%18 = icmp ugt i32 %14, 1
br i1 %18, label %13, label %19
19: ; preds = %13, %7, %11
ret void
}