#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__ gf_error_check(int, int, int, int, int, int, int /*<<< orphan*/,
                          int /*<<< orphan*/ *);
int gf_w128_scratch_size(int, int, int, int, int);
int gf_w16_scratch_size(int, int, int, int, int);
int gf_w32_scratch_size(int, int, int, int, int);
int gf_w4_scratch_size(int, int, int, int, int);
int gf_w64_scratch_size(int, int, int, int, int);
int gf_w8_scratch_size(int, int, int, int, int);
int gf_wgen_scratch_size(int, int, int, int, int, int);
int gf_scratch_size(int w, int mult_type, int region_type, int divide_type,
                    int arg1, int arg2) {
  if (gf_error_check(w, mult_type, region_type, divide_type, arg1, arg2, 0,
                     NULL) == 0)
    return 0;
  switch (w) {
  case 4:
    return gf_w4_scratch_size(mult_type, region_type, divide_type, arg1, arg2);
  case 8:
    return gf_w8_scratch_size(mult_type, region_type, divide_type, arg1, arg2);
  case 16:
    return gf_w16_scratch_size(mult_type, region_type, divide_type, arg1, arg2);
  case 32:
    return gf_w32_scratch_size(mult_type, region_type, divide_type, arg1, arg2);
  case 64:
    return gf_w64_scratch_size(mult_type, region_type, divide_type, arg1, arg2);
  case 128:
    return gf_w128_scratch_size(mult_type, region_type, divide_type, arg1,
                                arg2);
  default:
    return gf_wgen_scratch_size(w, mult_type, region_type, divide_type, arg1,
                                arg2);
  }
}


x86 assembly (clang, -O0):
<gf_scratch_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
xor    %eax,%eax
xor    %eax,%eax
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
call   1030 <gf_error_check@plt>
cmp    $0x0,%rax
jne    11df <gf_scratch_size+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    1314 <gf_scratch_size+0x194>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x4,%eax
je     124a <gf_scratch_size+0xca>
jmp    11f3 <gf_scratch_size+0x73>
mov    -0x20(%rbp),%eax
sub    $0x8,%eax
je     1267 <gf_scratch_size+0xe7>
jmp    1204 <gf_scratch_size+0x84>
mov    -0x20(%rbp),%eax
sub    $0x10,%eax
je     1284 <gf_scratch_size+0x104>
jmp    1215 <gf_scratch_size+0x95>
mov    -0x20(%rbp),%eax
sub    $0x20,%eax
je     12a1 <gf_scratch_size+0x121>
jmp    1226 <gf_scratch_size+0xa6>
mov    -0x20(%rbp),%eax
sub    $0x40,%eax
je     12be <gf_scratch_size+0x13e>
jmp    1237 <gf_scratch_size+0xb7>
mov    -0x20(%rbp),%eax
sub    $0x80,%eax
je     12db <gf_scratch_size+0x15b>
jmp    12f8 <gf_scratch_size+0x178>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1090 <gf_w4_scratch_size@plt>
mov    %eax,-0x4(%rbp)
jmp    1314 <gf_scratch_size+0x194>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1040 <gf_w8_scratch_size@plt>
mov    %eax,-0x4(%rbp)
jmp    1314 <gf_scratch_size+0x194>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1050 <gf_w16_scratch_size@plt>
mov    %eax,-0x4(%rbp)
jmp    1314 <gf_scratch_size+0x194>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1070 <gf_w32_scratch_size@plt>
mov    %eax,-0x4(%rbp)
jmp    1314 <gf_scratch_size+0x194>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1080 <gf_w64_scratch_size@plt>
mov    %eax,-0x4(%rbp)
jmp    1314 <gf_scratch_size+0x194>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1060 <gf_w128_scratch_size@plt>
mov    %eax,-0x4(%rbp)
jmp    1314 <gf_scratch_size+0x194>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
call   10a0 <gf_wgen_scratch_size@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gf_scratch_size>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%ebp
push   $0x0
push   $0x0
call   1030 <gf_error_check@plt>
add    $0x10,%rsp
test   %rax,%rax
je     11e6 <gf_scratch_size+0x66>
lea    -0x4(%rbp),%eax
cmp    $0x1c,%eax
ja     11f7 <gf_scratch_size+0x77>
lea    0xe44(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <gf_w4_scratch_size@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x40,%ebp
je     12af <gf_scratch_size+0x12f>
cmp    $0x80,%ebp
jne    1229 <gf_scratch_size+0xa9>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <gf_w128_scratch_size@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    %r14d,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <gf_wgen_scratch_size@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <gf_w8_scratch_size@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <gf_w16_scratch_size@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <gf_w32_scratch_size@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <gf_w64_scratch_size@plt>

LLVM IR (-O0):
define i32 @gf_scratch_size(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = load i32, i32* %10
%17 = load i32, i32* %11
%18 = load i32, i32* %12
%19 = load i32, i32* %13
%20 = call i64 @gf_error_check(i32 %14, i32 %15, i32 %16, i32 %17, i32 %18, i32 %19, i32 0, i32* null)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %6
store i32 0, i32* %7
br label %75
23: ; preds = %6
%24 = load i32, i32* %8
switch i32 %24, label %67 [
i32 4, label %25
i32 8, label %32
i32 16, label %39
i32 32, label %46
i32 64, label %53
i32 128, label %60
]
25: ; preds = %23
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = load i32, i32* %11
%29 = load i32, i32* %12
%30 = load i32, i32* %13
%31 = call i32 @gf_w4_scratch_size(i32 %26, i32 %27, i32 %28, i32 %29, i32 %30)
store i32 %31, i32* %7
br label %75
32: ; preds = %23
%33 = load i32, i32* %9
%34 = load i32, i32* %10
%35 = load i32, i32* %11
%36 = load i32, i32* %12
%37 = load i32, i32* %13
%38 = call i32 @gf_w8_scratch_size(i32 %33, i32 %34, i32 %35, i32 %36, i32 %37)
store i32 %38, i32* %7
br label %75
39: ; preds = %23
%40 = load i32, i32* %9
%41 = load i32, i32* %10
%42 = load i32, i32* %11
%43 = load i32, i32* %12
%44 = load i32, i32* %13
%45 = call i32 @gf_w16_scratch_size(i32 %40, i32 %41, i32 %42, i32 %43, i32 %44)
store i32 %45, i32* %7
br label %75
46: ; preds = %23
%47 = load i32, i32* %9
%48 = load i32, i32* %10
%49 = load i32, i32* %11
%50 = load i32, i32* %12
%51 = load i32, i32* %13
%52 = call i32 @gf_w32_scratch_size(i32 %47, i32 %48, i32 %49, i32 %50, i32 %51)
store i32 %52, i32* %7
br label %75
53: ; preds = %23
%54 = load i32, i32* %9
%55 = load i32, i32* %10
%56 = load i32, i32* %11
%57 = load i32, i32* %12
%58 = load i32, i32* %13
%59 = call i32 @gf_w64_scratch_size(i32 %54, i32 %55, i32 %56, i32 %57, i32 %58)
store i32 %59, i32* %7
br label %75
60: ; preds = %23
%61 = load i32, i32* %9
%62 = load i32, i32* %10
%63 = load i32, i32* %11
%64 = load i32, i32* %12
%65 = load i32, i32* %13
%66 = call i32 @gf_w128_scratch_size(i32 %61, i32 %62, i32 %63, i32 %64, i32 %65)
store i32 %66, i32* %7
br label %75
67: ; preds = %23
%68 = load i32, i32* %8
%69 = load i32, i32* %9
%70 = load i32, i32* %10
%71 = load i32, i32* %11
%72 = load i32, i32* %12
%73 = load i32, i32* %13
%74 = call i32 @gf_wgen_scratch_size(i32 %68, i32 %69, i32 %70, i32 %71, i32 %72, i32 %73)
store i32 %74, i32* %7
br label %75
75: ; preds = %67, %60, %53, %46, %39, %32, %25, %22
%76 = load i32, i32* %7
ret i32 %76
}

LLVM IR (-O2):
define i32 @gf_scratch_size(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i64 @gf_error_check(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 0, i32* null)
%8 = icmp eq i64 %7, 0
br i1 %8, label %24, label %9
9: ; preds = %6
switch i32 %0, label %22 [
i32 4, label %10
i32 8, label %12
i32 16, label %14
i32 32, label %16
i32 64, label %18
i32 128, label %20
]
10: ; preds = %9
%11 = tail call i32 @gf_w4_scratch_size(i32 %1, i32 %2, i32 %3, i32 %4, i32 %5)
br label %24
12: ; preds = %9
%13 = tail call i32 @gf_w8_scratch_size(i32 %1, i32 %2, i32 %3, i32 %4, i32 %5)
br label %24
14: ; preds = %9
%15 = tail call i32 @gf_w16_scratch_size(i32 %1, i32 %2, i32 %3, i32 %4, i32 %5)
br label %24
16: ; preds = %9
%17 = tail call i32 @gf_w32_scratch_size(i32 %1, i32 %2, i32 %3, i32 %4, i32 %5)
br label %24
18: ; preds = %9
%19 = tail call i32 @gf_w64_scratch_size(i32 %1, i32 %2, i32 %3, i32 %4, i32 %5)
br label %24
20: ; preds = %9
%21 = tail call i32 @gf_w128_scratch_size(i32 %1, i32 %2, i32 %3, i32 %4, i32 %5)
br label %24
22: ; preds = %9
%23 = tail call i32 @gf_wgen_scratch_size(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5)
br label %24
24: ; preds = %6, %22, %20, %18, %16, %14, %12, %10
%25 = phi i32 [ %23, %22 ], [ %21, %20 ], [ %19, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ 0, %6 ]
ret i32 %25
}