#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 */
void *malloc(int);
int **init_votes(int seq_len) {
  int **votes = malloc(sizeof(int *) * seq_len);
  int i, j;
  for (i = 0; i < seq_len; i++) {
    votes[i] = malloc(sizeof(int) * 6);
    for (j = 0; j < 6; j++) {
      votes[i][j] = 0;
    }
  }
  return votes;
}


x86 assembly (clang, -O0):
<init_votes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a3 <init_votes+0x93>
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x18(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    1190 <init_votes+0x80>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1161 <init_votes+0x51>
jmp    1195 <init_votes+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <init_votes+0x25>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_votes>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1165 <init_votes+0x55>
mov    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
xorps  %xmm0,%xmm0
movups %xmm0,(%rax)
movq   $0x0,0x10(%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <init_votes+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32** @init_votes(i32 %0) {
%2 = alloca i32
%3 = alloca i32**
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call i8* @malloc(i32 %9)
%11 = bitcast i8* %10 to i32**
store i32** %11, i32*** %3
store i32 0, i32* %4
br label %12
12: ; preds = %39, %1
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %42
16: ; preds = %12
%17 = call i8* @malloc(i32 24)
%18 = bitcast i8* %17 to i32*
%19 = load i32**, i32*** %3
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32*, i32** %19, i64 %21
store i32* %18, i32** %22
store i32 0, i32* %5
br label %23
23: ; preds = %35, %16
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 6
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load i32**, i32*** %3
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32*, i32** %27, i64 %29
%31 = load i32*, i32** %30
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
store i32 0, i32* %34
br label %35
35: ; preds = %26
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %23
38: ; preds = %23
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %12
42: ; preds = %12
%43 = load i32**, i32*** %3
ret i32** %43
}

LLVM IR (-O2):
define noalias i32** @init_votes(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call i8* @malloc(i32 %2)
%4 = bitcast i8* %3 to i32**
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %15
6: ; preds = %1
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %13, %8 ]
%10 = tail call dereferenceable_or_null(24) i8* @malloc(i32 24)
%11 = getelementptr inbounds i32*, i32** %4, i64 %9
%12 = bitcast i32** %11 to i8**
store i8* %10, i8** %12
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, %7
br i1 %14, label %15, label %8
15: ; preds = %8, %1
ret i32** %4
}