#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int get_ops(int *, int *, int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
void main() {
  int a[] = {16, 16, 16};
  int len = sizeof(a) / sizeof(a[0]);
  int start[len];
  for (int i = 0; i < len; i++) {
    start[i] = 0;
  }
  int res = get_ops(a, start, len, 0, 0);
  printf("ops required %d", res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xeda(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119a <main+0x7a>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1171 <main+0x51>
mov    -0x38(%rbp),%rsi
lea    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1040 <get_ops@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsp,%rbx
mov    0xeda(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xec7(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x3,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <get_ops@plt>
lea    0xea0(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rsp
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [3 x i32] [i32 16, i32 16, i32 16]
@.str = [16 x i8] c"ops required %d\00"
define void @main() {
%1 = alloca [3 x i32]
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [3 x i32]* %1 to i8*
store i32 3, i32* %2
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32, i64 %9
store i64 %9, i64* %4
store i32 0, i32* %5
br label %12
12: ; preds = %20, %0
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %11, i64 %18
store i32 0, i32* %19
br label %20
20: ; preds = %16
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %12
23: ; preds = %12
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%25 = load i32, i32* %2
%26 = call i32 @get_ops(i32* %24, i32* %11, i32 %25, i32 0, i32 0)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@__const.main.a = [3 x i32] [i32 16, i32 16, i32 16]
@.str = [16 x i8] c"ops required %d\00"
define void @main() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = tail call i8* @llvm.stacksave()
%4 = alloca [3 x i32]
%5 = bitcast [3 x i32]* %4 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%8 = call i32 @get_ops(i32* %7, i32* %6, i32 3, i32 0, i32 0)
%9 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %8)
ret void
}