#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 value(struct pos *, int, int *);
int prod_down(int l, struct pos *p, int n, int nums[]) {
  if (l == 0) {
    return 1;
  }
  int v = value(p, n, nums);
  down(p);
  return v * prod_down(l - 1, p, n, nums);
}


x86 assembly (clang, -O0):
<prod_down>:
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    115c <prod_down+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    119f <prod_down+0x6f>
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   1030 <down@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   1040 <prod_down@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_down>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     1164 <prod_down+0x44>
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   1040 <value@plt>
mov    %eax,%r13d
mov    %r12,%rdi
call   1030 <down@plt>
imul   %r13d,%ebp
add    $0xffffffff,%ebx
jne    1140 <prod_down+0x20>
jmp    1169 <prod_down+0x49>
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_down(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 %29
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 i32, i32* %10
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, 1
%24 = load %struct.pos*, %struct.pos** %7
%25 = load i32, i32* %8
%26 = load i32*, i32** %9
%27 = call i32 @prod_down(i32 %23, %struct.pos* %24, i32 %25, i32* %26)
%28 = mul nsw i32 %21, %27
store i32 %28, i32* %5
br label %29
29: ; preds = %14, %13
%30 = load i32, i32* %5
ret i32 %30
}

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