#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*/ printf(char *, int, int, int);
int _ConvertSMVer2Cores(int major, int minor) {
  typedef struct {
    int SM;
    int Cores;
  } sSMtoCores;
  sSMtoCores nGpuArchCoresPerSM[] = {{0x10, 8},   {0x11, 8},   {0x12, 8},
                                     {0x13, 8},   {0x20, 32},  {0x21, 48},
                                     {0x30, 192}, {0x35, 192}, {-1, -1}};
  int index = 0;
  while (nGpuArchCoresPerSM[index].SM != -1) {
    if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) {
      return nGpuArchCoresPerSM[index].Cores;
    }
    index++;
  }
  printf(
      "MapSMtoCores for SM %d.%d is undefined.  Default to use %d Cores/SM\n",
      major, minor, nGpuArchCoresPerSM[7].Cores);
  return nGpuArchCoresPerSM[7].Cores;
}


x86 assembly (clang, -O0):
<_ConvertSMVer2Cores>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xec7(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x64(%rbp)
movslq -0x64(%rbp),%rax
cmpl   $0xffffffff,-0x60(%rbp,%rax,8)
je     1190 <_ConvertSMVer2Cores+0x70>
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%eax
mov    -0x8(%rbp),%ecx
shl    $0x4,%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jne    1182 <_ConvertSMVer2Cores+0x62>
movslq -0x64(%rbp),%rax
mov    -0x5c(%rbp,%rax,8),%eax
mov    %eax,-0x4(%rbp)
jmp    11ab <_ConvertSMVer2Cores+0x8b>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    114a <_ConvertSMVer2Cores+0x2a>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ConvertSMVer2Cores>:
push   %rbx
mov    %esi,%edx
mov    %edi,%esi
mov    %edi,%eax
shl    $0x4,%eax
lea    (%rax,%rdx,1),%ecx
add    $0xfffffff0,%ecx
cmp    $0x25,%ecx
ja     114c <_ConvertSMVer2Cores+0x3c>
xor    %eax,%eax
lea    0xed2(%rip),%rdi
movslq (%rdi,%rcx,4),%rcx
add    %rdi,%rcx
jmp    *%rcx
mov    $0x1,%eax
jmp    117e <_ConvertSMVer2Cores+0x6e>
mov    $0x2,%eax
jmp    117e <_ConvertSMVer2Cores+0x6e>
mov    $0x3,%eax
jmp    117e <_ConvertSMVer2Cores+0x6e>
lea    0xf95(%rip),%rdi
mov    $0xc0,%ebx
mov    $0xc0,%ecx
call   1030 <printf@plt>
jmp    1189 <_ConvertSMVer2Cores+0x79>
mov    $0x4,%eax
jmp    117e <_ConvertSMVer2Cores+0x6e>
mov    $0x5,%eax
jmp    117e <_ConvertSMVer2Cores+0x6e>
mov    $0x6,%eax
jmp    117e <_ConvertSMVer2Cores+0x6e>
mov    $0x7,%eax
lea    0xf1b(%rip),%rcx
mov    0x4(%rcx,%rax,8),%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.sSMtoCores = type { i32, i32 }
@__const._ConvertSMVer2Cores.nGpuArchCoresPerSM = [9 x %struct.sSMtoCores] [%struct.sSMtoCores { i32 16, i32 8 }, %struct.sSMtoCores { i32 17, i32 8 }, %struct.sSMtoCores { i32 18, i32 8 }, %struct.sSMtoCores { i32 19, i32 8 }, %struct.sSMtoCores { i32 32, i32 32 }, %struct.sSMtoCores { i32 33, i32 48 }, %struct.sSMtoCores { i32 48, i32 192 }, %struct.sSMtoCores { i32 53, i32 192 }, %struct.sSMtoCores { i32 -1, i32 -1 }]
@.str = [69 x i8] c"MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\0A\00"
define i32 @_ConvertSMVer2Cores(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [9 x %struct.sSMtoCores]
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = bitcast [9 x %struct.sSMtoCores]* %6 to i8*
store i32 0, i32* %7
br label %9
9: ; preds = %33, %2
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [9 x %struct.sSMtoCores], [9 x %struct.sSMtoCores]* %6, i64 0, i64 %11
%13 = getelementptr inbounds %struct.sSMtoCores, %struct.sSMtoCores* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %36
16: ; preds = %9
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [9 x %struct.sSMtoCores], [9 x %struct.sSMtoCores]* %6, i64 0, i64 %18
%20 = getelementptr inbounds %struct.sSMtoCores, %struct.sSMtoCores* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = load i32, i32* %4
%23 = shl i32 %22, 4
%24 = load i32, i32* %5
%25 = add nsw i32 %23, %24
%26 = icmp eq i32 %21, %25
br i1 %26, label %27, label %33
27: ; preds = %16
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [9 x %struct.sSMtoCores], [9 x %struct.sSMtoCores]* %6, i64 0, i64 %29
%31 = getelementptr inbounds %struct.sSMtoCores, %struct.sSMtoCores* %30, i32 0, i32 1
%32 = load i32, i32* %31
store i32 %32, i32* %3
br label %46
33: ; preds = %16
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %9
36: ; preds = %9
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = getelementptr inbounds [9 x %struct.sSMtoCores], [9 x %struct.sSMtoCores]* %6, i64 0, i64 7
%40 = getelementptr inbounds %struct.sSMtoCores, %struct.sSMtoCores* %39, i32 0, i32 1
%41 = load i32, i32* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38, i32 %41)
%43 = getelementptr inbounds [9 x %struct.sSMtoCores], [9 x %struct.sSMtoCores]* %6, i64 0, i64 7
%44 = getelementptr inbounds %struct.sSMtoCores, %struct.sSMtoCores* %43, i32 0, i32 1
%45 = load i32, i32* %44
store i32 %45, i32* %3
br label %46
46: ; preds = %36, %27
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
%struct.sSMtoCores = type { i32, i32 }
@__const._ConvertSMVer2Cores.nGpuArchCoresPerSM = [9 x %struct.sSMtoCores] [%struct.sSMtoCores { i32 16, i32 8 }, %struct.sSMtoCores { i32 17, i32 8 }, %struct.sSMtoCores { i32 18, i32 8 }, %struct.sSMtoCores { i32 19, i32 8 }, %struct.sSMtoCores { i32 32, i32 32 }, %struct.sSMtoCores { i32 33, i32 48 }, %struct.sSMtoCores { i32 48, i32 192 }, %struct.sSMtoCores { i32 53, i32 192 }, %struct.sSMtoCores { i32 -1, i32 -1 }]
@.str = [69 x i8] c"MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\0A\00"
define i32 @_ConvertSMVer2Cores(i32 %0, i32 %1) {
%3 = shl i32 %0, 4
%4 = add nsw i32 %3, %1
switch i32 %4, label %16 [
i32 16, label %12
i32 17, label %5
i32 18, label %6
i32 19, label %7
i32 32, label %8
i32 33, label %9
i32 48, label %10
i32 53, label %11
]
5: ; preds = %2
br label %12
6: ; preds = %2
br label %12
7: ; preds = %2
br label %12
8: ; preds = %2
br label %12
9: ; preds = %2
br label %12
10: ; preds = %2
br label %12
11: ; preds = %2
br label %12
12: ; preds = %2, %11, %10, %9, %8, %7, %6, %5
%13 = phi i64 [ 0, %2 ], [ 1, %5 ], [ 2, %6 ], [ 3, %7 ], [ 4, %8 ], [ 5, %9 ], [ 6, %10 ], [ 7, %11 ]
%14 = getelementptr inbounds [9 x %struct.sSMtoCores], [9 x %struct.sSMtoCores]* @__const._ConvertSMVer2Cores.nGpuArchCoresPerSM, i64 0, i64 %13, i32 1
%15 = load i32, i32* %14
br label %18
16: ; preds = %2
%17 = tail call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 192)
br label %18
18: ; preds = %16, %12
%19 = phi i32 [ %15, %12 ], [ 192, %16 ]
ret i32 %19
}