#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 */
int /*<<< orphan*/ softmax(float *, int, float, float *, int);
void softmax_cpu(float *input, int n, int batch, int batch_offset, int groups,
                 int group_offset, int stride, float temp, float *output) {
  int g, b;
  for (b = 0; b < batch; ++b) {
    for (g = 0; g < groups; ++g) {
      softmax(input + b * batch_offset + g * group_offset, n, temp,
              output + b * batch_offset + g * group_offset, stride);
    }
  }
}


x86 assembly (clang, -O0):
<softmax_cpu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movss  %xmm0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d8 <softmax_cpu+0xc8>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c5 <softmax_cpu+0xb5>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x24(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0xc(%rbp),%esi
movss  -0x20(%rbp),%xmm0
mov    0x18(%rbp),%rdx
mov    -0x28(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x24(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    0x10(%rbp),%ecx
call   1030 <softmax@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1153 <softmax_cpu+0x43>
jmp    11ca <softmax_cpu+0xba>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1140 <softmax_cpu+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<softmax_cpu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,(%rsp)
mov    %rdi,0x10(%rsp)
test   %edx,%edx
jle    11d5 <softmax_cpu+0xc5>
mov    %esi,%r13d
mov    0x78(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x70(%rsp),%r12d
movslq %r9d,%r15
movslq %ecx,%rax
mov    %edx,%ecx
mov    %rcx,0x20(%rsp)
mov    (%rsp),%ecx
mov    %rcx,0x18(%rsp)
shl    $0x2,%rax
mov    %rax,0x28(%rsp)
shl    $0x2,%r15
xor    %ecx,%ecx
movss  %xmm0,0x4(%rsp)
jmp    118f <softmax_cpu+0x7f>
nopl   (%rax)
mov    0x30(%rsp),%rcx
add    $0x1,%rcx
mov    0x28(%rsp),%rax
add    %rax,0x10(%rsp)
add    %rax,0x8(%rsp)
cmp    0x20(%rsp),%rcx
je     11d5 <softmax_cpu+0xc5>
mov    %rcx,0x30(%rsp)
cmpl   $0x0,(%rsp)
jle    1170 <softmax_cpu+0x60>
mov    0x18(%rsp),%r14
mov    0x8(%rsp),%rbx
mov    0x10(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r13d,%esi
movss  0x4(%rsp),%xmm0
mov    %rbx,%rdx
mov    %r12d,%ecx
call   1030 <softmax@plt>
add    %r15,%rbp
add    %r15,%rbx
add    $0xffffffffffffffff,%r14
jne    11b0 <softmax_cpu+0xa0>
jmp    1170 <softmax_cpu+0x60>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @softmax_cpu(float* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, float %7, float* %8) {
%10 = alloca float*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca float
%18 = alloca float*
%19 = alloca i32
%20 = alloca i32
store float* %0, float** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store float %7, float* %17
store float* %8, float** %18
store i32 0, i32* %20
br label %21
21: ; preds = %61, %9
%22 = load i32, i32* %20
%23 = load i32, i32* %12
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %64
25: ; preds = %21
store i32 0, i32* %19
br label %26
26: ; preds = %57, %25
%27 = load i32, i32* %19
%28 = load i32, i32* %14
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %60
30: ; preds = %26
%31 = load float*, float** %10
%32 = load i32, i32* %20
%33 = load i32, i32* %13
%34 = mul nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %31, i64 %35
%37 = load i32, i32* %19
%38 = load i32, i32* %15
%39 = mul nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %36, i64 %40
%42 = load i32, i32* %11
%43 = load float, float* %17
%44 = load float*, float** %18
%45 = load i32, i32* %20
%46 = load i32, i32* %13
%47 = mul nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %44, i64 %48
%50 = load i32, i32* %19
%51 = load i32, i32* %15
%52 = mul nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds float, float* %49, i64 %53
%55 = load i32, i32* %16
%56 = call i32 @softmax(float* %41, i32 %42, float %43, float* %54, i32 %55)
br label %57
57: ; preds = %30
%58 = load i32, i32* %19
%59 = add nsw i32 %58, 1
store i32 %59, i32* %19
br label %26
60: ; preds = %26
br label %61
61: ; preds = %60
%62 = load i32, i32* %20
%63 = add nsw i32 %62, 1
store i32 %63, i32* %20
br label %21
64: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @softmax_cpu(float* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, float %7, float* %8) {
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %34
11: ; preds = %9
%12 = icmp sgt i32 %4, 0
%13 = sext i32 %5 to i64
%14 = sext i32 %3 to i64
%15 = zext i32 %2 to i64
%16 = zext i32 %4 to i64
br label %17
17: ; preds = %11, %31
%18 = phi i64 [ 0, %11 ], [ %32, %31 ]
br i1 %12, label %19, label %31
19: ; preds = %17
%20 = mul nsw i64 %18, %14
%21 = getelementptr inbounds float, float* %0, i64 %20
%22 = getelementptr inbounds float, float* %8, i64 %20
br label %23
23: ; preds = %19, %23
%24 = phi i64 [ 0, %19 ], [ %29, %23 ]
%25 = mul nsw i64 %24, %13
%26 = getelementptr inbounds float, float* %21, i64 %25
%27 = getelementptr inbounds float, float* %22, i64 %25
%28 = tail call i32 @softmax(float* %26, i32 %1, float %7, float* %27, i32 %6)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %16
br i1 %30, label %31, label %23
31: ; preds = %23, %17
%32 = add nuw nsw i64 %18, 1
%33 = icmp eq i64 %32, %15
br i1 %33, label %34, label %17
34: ; preds = %31, %9
ret void
}