#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*/ memcpy(int *, int *, int);
void genbf_i(int n, int m, int *maxima, int *choices, int *choice, int j) {
  static int i;
  if (j == n) {
    memcpy(&choices[i * n], choice, n * sizeof(int));
    i++;
    return;
  } else if (j < 0) {
    i = 0;
    j = 0;
  } else if (i == m)
    return;
  int k;
  for (k = 0; k < maxima[j]; k++) {
    choice[j] = k;
    genbf_i(n, m, maxima, choices, choice, j + 1);
  }
  return;
}


x86 assembly (clang, -O0):
<genbf_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1188 <genbf_i+0x68>
mov    -0x18(%rbp),%rdi
mov    0x2ee0(%rip),%eax
imul   -0x4(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    0x2eba(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eb1(%rip)
jmp    1221 <genbf_i+0x101>
cmpl   $0x0,-0x24(%rbp)
jge    11a8 <genbf_i+0x88>
movl   $0x0,0x2e98(%rip)
movl   $0x0,-0x24(%rbp)
jmp    11c1 <genbf_i+0xa1>
mov    0x2e86(%rip),%eax
cmp    -0x8(%rbp),%eax
jne    11bc <genbf_i+0x9c>
jmp    1221 <genbf_i+0x101>
jmp    11c1 <genbf_i+0xa1>
jmp    11c6 <genbf_i+0xa6>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    121c <genbf_i+0xfc>
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
add    $0x1,%r9d
call   1040 <genbf_i@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11cd <genbf_i+0xad>
jmp    1221 <genbf_i+0x101>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genbf_i>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
cmp    %edi,%r9d
jne    1160 <genbf_i+0x40>
movslq 0x2ef7(%rip),%rax
movslq %r9d,%rdx
imul   %rax,%rdx
lea    (%rcx,%rdx,4),%rdi
shl    $0x2,%r9d
mov    %rbx,%rsi
mov    %r9d,%edx
call   1030 <memcpy@plt>
addl   $0x1,0x2ed6(%rip)
jmp    11d8 <genbf_i+0xb8>
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%r15d
test   %r9d,%r9d
js     1177 <genbf_i+0x57>
cmp    %ebp,0x2ec1(%rip)
jne    1184 <genbf_i+0x64>
jmp    11d8 <genbf_i+0xb8>
movl   $0x0,0x2eb3(%rip)
xor    %r9d,%r9d
mov    %r9d,%eax
mov    %rax,0x8(%rsp)
cmpl   $0x0,(%r14,%rax,4)
jle    11d8 <genbf_i+0xb8>
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %eax,0x4(%rsp)
xor    %r12d,%r12d
mov    %rcx,0x10(%rsp)
mov    0x8(%rsp),%r13
nopl   0x0(%rax)
mov    %r12d,(%rbx,%r13,4)
mov    %r15d,%edi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %rbx,%r8
mov    0x4(%rsp),%r9d
call   1040 <genbf_i@plt>
mov    0x10(%rsp),%rcx
add    $0x1,%r12d
cmp    (%r14,%r13,4),%r12d
jl     11b0 <genbf_i+0x90>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@genbf_i.i = internal global i32 0
define void @genbf_i(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32 %5, i32* %12
%14 = load i32, i32* %12
%15 = load i32, i32* %7
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %32
17: ; preds = %6
%18 = load i32*, i32** %10
%19 = load i32, i32* @genbf_i.i
%20 = load i32, i32* %7
%21 = mul nsw i32 %19, %20
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %18, i64 %22
%24 = load i32*, i32** %11
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i32 @memcpy(i32* %23, i32* %24, i32 %28)
%30 = load i32, i32* @genbf_i.i
%31 = add nsw i32 %30, 1
store i32 %31, i32* @genbf_i.i
br label %69
32: ; preds = %6
%33 = load i32, i32* %12
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 0, i32* @genbf_i.i
store i32 0, i32* %12
br label %42
36: ; preds = %32
%37 = load i32, i32* @genbf_i.i
%38 = load i32, i32* %8
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %41
40: ; preds = %36
br label %69
41: ; preds = %36
br label %42
42: ; preds = %41, %35
br label %43
43: ; preds = %42
store i32 0, i32* %13
br label %44
44: ; preds = %65, %43
%45 = load i32, i32* %13
%46 = load i32*, i32** %9
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = icmp slt i32 %45, %50
br i1 %51, label %52, label %68
52: ; preds = %44
%53 = load i32, i32* %13
%54 = load i32*, i32** %11
%55 = load i32, i32* %12
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
store i32 %53, i32* %57
%58 = load i32, i32* %7
%59 = load i32, i32* %8
%60 = load i32*, i32** %9
%61 = load i32*, i32** %10
%62 = load i32*, i32** %11
%63 = load i32, i32* %12
%64 = add nsw i32 %63, 1
br label %65
65: ; preds = %52
%66 = load i32, i32* %13
%67 = add nsw i32 %66, 1
store i32 %67, i32* %13
br label %44
68: ; preds = %44
br label %69
69: ; preds = %68, %40, %17
ret void
}

LLVM IR (-O2):
@genbf_i.i = internal unnamed_addr global i32 0
define void @genbf_i(i32 %0, i32 %1, i32* nocapture %2, i32* %3, i32* %4, i32 %5) {
%7 = icmp eq i32 %5, %0
br i1 %7, label %8, label %17
8: ; preds = %6
%9 = load i32, i32* @genbf_i.i
%10 = mul nsw i32 %9, %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %3, i64 %11
%13 = shl i32 %5, 2
%14 = tail call i32 @memcpy(i32* %12, i32* %4, i32 %13)
%15 = load i32, i32* @genbf_i.i
%16 = add nsw i32 %15, 1
store i32 %16, i32* @genbf_i.i
br label %37
17: ; preds = %6
%18 = icmp slt i32 %5, 0
br i1 %18, label %19, label %20
19: ; preds = %17
store i32 0, i32* @genbf_i.i
br label %23
20: ; preds = %17
%21 = load i32, i32* @genbf_i.i
%22 = icmp eq i32 %21, %1
br i1 %22, label %37, label %23
23: ; preds = %19, %20
%24 = phi i32 [ 0, %19 ], [ %5, %20 ]
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %2, i64 %25
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %23
%30 = getelementptr inbounds i32, i32* %4, i64 %25
%31 = add nuw nsw i32 %24, 1
br label %32
32: ; preds = %29, %32
%33 = phi i32 [ 0, %29 ], [ %34, %32 ]
store i32 %33, i32* %30
tail call void @genbf_i(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32 %31)
%34 = add nuw nsw i32 %33, 1
%35 = load i32, i32* %26
%36 = icmp slt i32 %34, %35
br i1 %36, label %32, label %37
37: ; preds = %32, %23, %20, %8
ret void
}