#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 */
struct pos {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ down(struct pos *);
int /*<<< orphan*/ right(struct pos *);
int value(struct pos *, int, int *);
int prod_downright(int l, struct pos *p, int n, int nums[]) {
  if (l == 0) {
    return 1;
  }
  int v = value(p, n, nums);
  down(p);
  right(p);
  return v * prod_downright(l - 1, p, n, nums);
}


x86 assembly (clang, -O0):
<prod_downright>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    116c <prod_downright+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <prod_downright+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1050 <value@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <down@plt>
mov    -0x10(%rbp),%rdi
call   1030 <right@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1060 <prod_downright@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prod_downright>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     117c <prod_downright+0x4c>
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%r12
mov    %edi,%ebx
mov    $0x1,%ebp
nop
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1050 <value@plt>
mov    %eax,%r13d
mov    %r12,%rdi
call   1040 <down@plt>
mov    %r12,%rdi
call   1030 <right@plt>
imul   %r13d,%ebp
add    $0xffffffff,%ebx
jne    1150 <prod_downright+0x20>
jmp    1181 <prod_downright+0x51>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pos = type { i32 }
define i32 @prod_downright(i32 %0, %struct.pos* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.pos*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32 %0, i32* %6
store %struct.pos* %1, %struct.pos** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 1, i32* %5
br label %31
14: ; preds = %4
%15 = load %struct.pos*, %struct.pos** %7
%16 = load i32, i32* %8
%17 = load i32*, i32** %9
%18 = call i32 @value(%struct.pos* %15, i32 %16, i32* %17)
store i32 %18, i32* %10
%19 = load %struct.pos*, %struct.pos** %7
%20 = call i32 @down(%struct.pos* %19)
%21 = load %struct.pos*, %struct.pos** %7
%22 = call i32 @right(%struct.pos* %21)
%23 = load i32, i32* %10
%24 = load i32, i32* %6
%25 = sub nsw i32 %24, 1
%26 = load %struct.pos*, %struct.pos** %7
%27 = load i32, i32* %8
%28 = load i32*, i32** %9
%29 = call i32 @prod_downright(i32 %25, %struct.pos* %26, i32 %27, i32* %28)
%30 = mul nsw i32 %23, %29
store i32 %30, i32* %5
br label %31
31: ; preds = %14, %13
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
%struct.pos = type { i32 }
define i32 @prod_downright(i32 %0, %struct.pos* %1, i32 %2, i32* %3) {
%5 = icmp eq i32 %0, 0
br i1 %5, label %15, label %6
6: ; preds = %4, %6
%7 = phi i32 [ %12, %6 ], [ %0, %4 ]
%8 = phi i32 [ %13, %6 ], [ 1, %4 ]
%9 = tail call i32 @value(%struct.pos* %1, i32 %2, i32* %3)
%10 = tail call i32 @down(%struct.pos* %1)
%11 = tail call i32 @right(%struct.pos* %1)
%12 = add nsw i32 %7, -1
%13 = mul nsw i32 %9, %8
%14 = icmp eq i32 %12, 0
br i1 %14, label %15, label %6
15: ; preds = %6, %4
%16 = phi i32 [ 1, %4 ], [ %13, %6 ]
ret i32 %16
}