#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 */
scalar_t__ calloc(int, int);
scalar_t__ malloc(int);
float **newmat(unsigned char unit_flg) {
  int i;
  float **to_ret = (float **)malloc(sizeof(float *) * 4);
  for (i = 0; i < 4; i++) {
    to_ret[i] = (float *)calloc(4, sizeof(float));
    if (unit_flg)
      to_ret[i][i] = 1.0;
  }
  return to_ret;
}


x86 assembly (clang, -O0):
<newmat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11a2 <newmat+0x82>
mov    $0x4,%esi
mov    %esi,%edi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
cmpb   $0x0,-0x1(%rbp)
je     118f <newmat+0x6f>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
movss  0xe76(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    1194 <newmat+0x74>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1143 <newmat+0x23>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newmat>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,(%rbx)
test   %ebp,%ebp
je     119e <newmat+0x7e>
movl   $0x3f800000,(%rax)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x8(%rbx)
movl   $0x3f800000,0x4(%rax)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x10(%rbx)
movl   $0x3f800000,0x8(%rax)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x18(%rbx)
movl   $0x3f800000,0xc(%rax)
jmp    11d7 <newmat+0xb7>
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x10(%rbx)
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,0x18(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float** @newmat(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca float**
store i8 %0, i8* %2
%5 = call i64 @malloc(i32 32)
%6 = inttoptr i64 %5 to float**
store float** %6, float*** %4
store i32 0, i32* %3
br label %7
7: ; preds = %29, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %32
10: ; preds = %7
%11 = call i64 @calloc(i32 4, i32 4)
%12 = inttoptr i64 %11 to float*
%13 = load float**, float*** %4
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds float*, float** %13, i64 %15
store float* %12, float** %16
%17 = load i8, i8* %2
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %10
%20 = load float**, float*** %4
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds float*, float** %20, i64 %22
%24 = load float*, float** %23
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
store float 1.000000e+00, float* %27
br label %28
28: ; preds = %19, %10
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %7
32: ; preds = %7
%33 = load float**, float*** %4
ret float** %33
}

LLVM IR (-O2):
define float** @newmat(i8 zeroext %0) {
%2 = tail call i64 @malloc(i32 32)
%3 = inttoptr i64 %2 to float**
%4 = icmp eq i8 %0, 0
%5 = tail call i64 @calloc(i32 4, i32 4)
%6 = inttoptr i64 %5 to float*
store float* %6, float** %3
br i1 %4, label %7, label %17
7: ; preds = %1
%8 = tail call i64 @calloc(i32 4, i32 4)
%9 = inttoptr i64 %8 to float*
%10 = getelementptr inbounds float*, float** %3, i64 1
store float* %9, float** %10
%11 = tail call i64 @calloc(i32 4, i32 4)
%12 = inttoptr i64 %11 to float*
%13 = getelementptr inbounds float*, float** %3, i64 2
store float* %12, float** %13
%14 = tail call i64 @calloc(i32 4, i32 4)
%15 = inttoptr i64 %14 to float*
%16 = getelementptr inbounds float*, float** %3, i64 3
store float* %15, float** %16
br label %30
17: ; preds = %1
store float 1.000000e+00, float* %6
%18 = tail call i64 @calloc(i32 4, i32 4)
%19 = inttoptr i64 %18 to float*
%20 = getelementptr inbounds float*, float** %3, i64 1
store float* %19, float** %20
%21 = getelementptr inbounds float, float* %19, i64 1
store float 1.000000e+00, float* %21
%22 = tail call i64 @calloc(i32 4, i32 4)
%23 = inttoptr i64 %22 to float*
%24 = getelementptr inbounds float*, float** %3, i64 2
store float* %23, float** %24
%25 = getelementptr inbounds float, float* %23, i64 2
store float 1.000000e+00, float* %25
%26 = tail call i64 @calloc(i32 4, i32 4)
%27 = inttoptr i64 %26 to float*
%28 = getelementptr inbounds float*, float** %3, i64 3
store float* %27, float** %28
%29 = getelementptr inbounds float, float* %27, i64 3
store float 1.000000e+00, float* %29
br label %30
30: ; preds = %7, %17
ret float** %3
}