#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 plambda_program {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fail(char *);
int run_program_vectorially_at(float *, struct plambda_program *, float **,
                               int *, int *, int *, int, int);
int /*<<< orphan*/ setsample_0(float *, int, int, int, int, int, int, float);
int run_program_vectorially(float *out, int pdmax, struct plambda_program *p,
                            float **val, int *w, int *h, int *pd) {
  for (int j = 0; j < *h; j++)
    for (int i = 0; i < *w; i++) {
      float result[pdmax];
      int r = run_program_vectorially_at(result, p, val, w, h, pd, i, j);
      assert(r == pdmax);
      if (r != pdmax)
        fail("r != pdmax");
      for (int l = 0; l < r; l++)
        setsample_0(out, *w, *h, pdmax, i, j, l, result[l]);
    }
  return pdmax;
}


x86 assembly (clang, -O0):
<run_program_vectorially>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%rcx
cmp    (%rcx),%eax
jge    1299 <run_program_vectorially+0x159>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    1286 <run_program_vectorially+0x146>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x58(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
mov    -0x38(%rbp),%r10d
mov    -0x34(%rbp),%eax
sub    $0x10,%rsp
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <run_program_vectorially_at@plt>
add    $0x10,%rsp
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0xc(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x4c(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     1214 <run_program_vectorially+0xd4>
lea    0xdf1(%rip),%rdi
call   1030 <fail@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1271 <run_program_vectorially+0x131>
mov    -0x58(%rbp),%r10
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    -0xc(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x34(%rbp),%r9d
mov    -0x50(%rbp),%eax
movslq -0x50(%rbp),%r11
movss  (%r10,%r11,4),%xmm0
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1060 <setsample_0@plt>
add    $0x10,%rsp
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    121b <run_program_vectorially+0xdb>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1180 <run_program_vectorially+0x40>
jmp    128b <run_program_vectorially+0x14b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116a <run_program_vectorially+0x2a>
mov    -0xc(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_program_vectorially>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,-0x60(%rbp)
mov    %rdx,-0x58(%rbp)
mov    %esi,%r14d
mov    (%r9),%esi
test   %esi,%esi
jle    12a8 <run_program_vectorially+0x168>
mov    %r14d,%edx
mov    (%r8),%ecx
xor    %eax,%eax
lea    0xf(,%rdx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rdi,-0x50(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r14d,-0x2c(%rbp)
jmp    119e <run_program_vectorially+0x5e>
nopl   (%rax)
mov    (%r9),%esi
add    $0x1,%eax
cmp    %esi,%eax
jge    12a8 <run_program_vectorially+0x168>
test   %ecx,%ecx
jle    1193 <run_program_vectorially+0x53>
xor    %ebx,%ebx
jmp    11c6 <run_program_vectorially+0x86>
cs nopw 0x0(%rax,%rax,1)
mov    -0x68(%rbp),%rsp
add    $0x1,%r13d
mov    (%r8),%ecx
cmp    %ecx,%r13d
mov    %r15,%r9
mov    %r13,%rbx
jge    1190 <run_program_vectorially+0x50>
mov    %rsp,-0x68(%rbp)
mov    %rsp,%rdi
sub    -0x48(%rbp),%rdi
mov    %rdi,%rsp
mov    %rdi,-0x40(%rbp)
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    %r8,%rcx
mov    %r9,%r15
mov    %r9,%r8
mov    0x10(%rbp),%r9
mov    %rax,%r12
push   %rax
mov    %rbx,%r13
push   %rbx
call   1040 <run_program_vectorially_at@plt>
add    $0x10,%rsp
mov    %eax,%ebx
xor    %edi,%edi
cmp    %r14d,%eax
sete   %dil
call   1050 <assert@plt>
mov    %ebx,%edx
mov    %r14d,%ebx
cmp    %r14d,%edx
je     122a <run_program_vectorially+0xea>
lea    0xde1(%rip),%rdi
mov    %edx,%r14d
call   1030 <fail@plt>
mov    %r14d,%edx
test   %edx,%edx
mov    -0x38(%rbp),%r8
mov    %ebx,%r14d
mov    -0x50(%rbp),%rcx
mov    %r12,%rax
mov    -0x40(%rbp),%rdi
jle    11b0 <run_program_vectorially+0x70>
mov    %edx,%edx
mov    %rdx,-0x70(%rbp)
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r8),%esi
mov    (%r15),%edx
movss  (%rdi,%rbx,4),%xmm0
sub    $0x8,%rsp
mov    %rcx,%r12
mov    %rcx,%rdi
mov    %r14d,%ecx
mov    %r13d,%r8d
mov    %r15,%r14
mov    %eax,%r9d
push   %rbx
mov    %r13,%r15
mov    %rax,%r13
call   1060 <setsample_0@plt>
mov    -0x40(%rbp),%rdi
mov    %r12,%rcx
mov    %r13,%rax
mov    %r15,%r13
mov    -0x38(%rbp),%r8
mov    %r14,%r15
mov    -0x2c(%rbp),%r14d
add    $0x10,%rsp
add    $0x1,%rbx
cmp    %rbx,-0x70(%rbp)
jne    1250 <run_program_vectorially+0x110>
jmp    11b0 <run_program_vectorially+0x70>
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.plambda_program = type { i32 }
@.str = [11 x i8] c"r != pdmax\00"
define i32 @run_program_vectorially(float* %0, i32 %1, %struct.plambda_program* %2, float** %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca float*
%9 = alloca i32
%10 = alloca %struct.plambda_program*
%11 = alloca float**
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i32
%20 = alloca i32
store float* %0, float** %8
store i32 %1, i32* %9
store %struct.plambda_program* %2, %struct.plambda_program** %10
store float** %3, float*** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
store i32 0, i32* %15
br label %21
21: ; preds = %84, %7
%22 = load i32, i32* %15
%23 = load i32*, i32** %13
%24 = load i32, i32* %23
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %87
26: ; preds = %21
store i32 0, i32* %16
br label %27
27: ; preds = %80, %26
%28 = load i32, i32* %16
%29 = load i32*, i32** %12
%30 = load i32, i32* %29
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %83
32: ; preds = %27
%33 = load i32, i32* %9
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %17
%36 = alloca float, i64 %34
store i64 %34, i64* %18
%37 = load %struct.plambda_program*, %struct.plambda_program** %10
%38 = load float**, float*** %11
%39 = load i32*, i32** %12
%40 = load i32*, i32** %13
%41 = load i32*, i32** %14
%42 = load i32, i32* %16
%43 = load i32, i32* %15
%44 = call i32 @run_program_vectorially_at(float* %36, %struct.plambda_program* %37, float** %38, i32* %39, i32* %40, i32* %41, i32 %42, i32 %43)
store i32 %44, i32* %19
%45 = load i32, i32* %19
%46 = load i32, i32* %9
%47 = icmp eq i32 %45, %46
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i32, i32* %19
%51 = load i32, i32* %9
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %32
%54 = call i32 @fail(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %55
55: ; preds = %53, %32
store i32 0, i32* %20
br label %56
56: ; preds = %75, %55
%57 = load i32, i32* %20
%58 = load i32, i32* %19
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %78
60: ; preds = %56
%61 = load float*, float** %8
%62 = load i32*, i32** %12
%63 = load i32, i32* %62
%64 = load i32*, i32** %13
%65 = load i32, i32* %64
%66 = load i32, i32* %9
%67 = load i32, i32* %16
%68 = load i32, i32* %15
%69 = load i32, i32* %20
%70 = load i32, i32* %20
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds float, float* %36, i64 %71
%73 = load float, float* %72
%74 = call i32 @setsample_0(float* %61, i32 %63, i32 %65, i32 %66, i32 %67, i32 %68, i32 %69, float %73)
br label %75
75: ; preds = %60
%76 = load i32, i32* %20
%77 = add nsw i32 %76, 1
store i32 %77, i32* %20
br label %56
78: ; preds = %56
%79 = load i8*, i8** %17
br label %80
80: ; preds = %78
%81 = load i32, i32* %16
%82 = add nsw i32 %81, 1
store i32 %82, i32* %16
br label %27
83: ; preds = %27
br label %84
84: ; preds = %83
%85 = load i32, i32* %15
%86 = add nsw i32 %85, 1
store i32 %86, i32* %15
br label %21
87: ; preds = %21
%88 = load i32, i32* %9
ret i32 %88
}

LLVM IR (-O2):
%struct.plambda_program = type { i32 }
@.str = [11 x i8] c"r != pdmax\00"
define i32 @run_program_vectorially(float* %0, i32 returned %1, %struct.plambda_program* %2, float** %3, i32* %4, i32* %5, i32* %6) {
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = zext i32 %1 to i64
%12 = load i32, i32* %4
br label %13
13: ; preds = %10, %21
%14 = phi i32 [ %8, %10 ], [ %22, %21 ]
%15 = phi i32 [ %12, %10 ], [ %23, %21 ]
%16 = phi i32 [ 0, %10 ], [ %24, %21 ]
%17 = icmp sgt i32 %15, 0
br i1 %17, label %26, label %21
18: ; preds = %21, %7
ret i32 %1
19: ; preds = %40
%20 = load i32, i32* %5
br label %21
21: ; preds = %19, %13
%22 = phi i32 [ %20, %19 ], [ %14, %13 ]
%23 = phi i32 [ %42, %19 ], [ %15, %13 ]
%24 = add nuw nsw i32 %16, 1
%25 = icmp slt i32 %24, %22
br i1 %25, label %13, label %18
26: ; preds = %13, %40
%27 = phi i32 [ %41, %40 ], [ 0, %13 ]
%28 = call i8* @llvm.stacksave()
%29 = alloca float, i64 %11
%30 = call i32 @run_program_vectorially_at(float* %29, %struct.plambda_program* %2, float** %3, i32* %4, i32* %5, i32* %6, i32 %27, i32 %16)
%31 = icmp eq i32 %30, %1
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
br i1 %31, label %36, label %34
34: ; preds = %26
%35 = call i32 @fail(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %34, %26
%37 = icmp sgt i32 %30, 0
br i1 %37, label %38, label %40
38: ; preds = %36
%39 = zext i32 %30 to i64
br label %44
40: ; preds = %44, %36
%41 = add nuw nsw i32 %27, 1
%42 = load i32, i32* %4
%43 = icmp slt i32 %41, %42
br i1 %43, label %26, label %19
44: ; preds = %38, %44
%45 = phi i64 [ 0, %38 ], [ %52, %44 ]
%46 = load i32, i32* %4
%47 = load i32, i32* %5
%48 = getelementptr inbounds float, float* %29, i64 %45
%49 = load float, float* %48
%50 = trunc i64 %45 to i32
%51 = call i32 @setsample_0(float* %0, i32 %46, i32 %47, i32 %1, i32 %27, i32 %16, i32 %50, float %49)
%52 = add nuw nsw i64 %45, 1
%53 = icmp eq i64 %52, %39
br i1 %53, label %40, label %44
}