#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 _ConvertSMVer2CoresDrvApi(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},
                                     {-1, -1}};
  int index = 0;
  while (nGpuArchCoresPerSM[index].SM != -1) {
    if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor)) {
      return nGpuArchCoresPerSM[index].Cores;
    }
    index++;
  }
  printf("MapSMtoCores undefined SMversion %d.%d!\n", major, minor);
  return -1;
}


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

x86 assembly (clang, -O2):
<_ConvertSMVer2CoresDrvApi>:
push   %rax
mov    %esi,%edx
mov    %edi,%esi
mov    %edi,%eax
shl    $0x4,%eax
lea    (%rax,%rdx,1),%ecx
add    $0xfffffff0,%ecx
cmp    $0x11,%ecx
ja     114c <_ConvertSMVer2CoresDrvApi+0x3c>
xor    %eax,%eax
lea    0xed2(%rip),%rdi
movslq (%rdi,%rcx,4),%rcx
add    %rdi,%rcx
jmp    *%rcx
mov    $0x1,%eax
jmp    116b <_ConvertSMVer2CoresDrvApi+0x5b>
mov    $0x2,%eax
jmp    116b <_ConvertSMVer2CoresDrvApi+0x5b>
mov    $0x3,%eax
jmp    116b <_ConvertSMVer2CoresDrvApi+0x5b>
lea    0xf35(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    $0x4,%eax
jmp    116b <_ConvertSMVer2CoresDrvApi+0x5b>
mov    $0x5,%eax
lea    0xede(%rip),%rcx
mov    0x4(%rcx,%rax,8),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sSMtoCores = type { i32, i32 }
@__const._ConvertSMVer2CoresDrvApi.nGpuArchCoresPerSM = [7 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 -1, i32 -1 }]
@.str = [41 x i8] c"MapSMtoCores undefined SMversion %d.%d!\0A\00"
define i32 @_ConvertSMVer2CoresDrvApi(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [7 x %struct.sSMtoCores]
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = bitcast [7 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 [7 x %struct.sSMtoCores], [7 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 [7 x %struct.sSMtoCores], [7 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 [7 x %struct.sSMtoCores], [7 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 %40
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 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38)
store i32 -1, i32* %3
br label %40
40: ; preds = %36, %27
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
%struct.sSMtoCores = type { i32, i32 }
@__const._ConvertSMVer2CoresDrvApi.nGpuArchCoresPerSM = [7 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 -1, i32 -1 }]
@.str = [41 x i8] c"MapSMtoCores undefined SMversion %d.%d!\0A\00"
define i32 @_ConvertSMVer2CoresDrvApi(i32 %0, i32 %1) {
%3 = shl i32 %0, 4
%4 = add nsw i32 %3, %1
switch i32 %4, label %14 [
i32 16, label %10
i32 17, label %5
i32 18, label %6
i32 19, label %7
i32 32, label %8
i32 33, label %9
]
5: ; preds = %2
br label %10
6: ; preds = %2
br label %10
7: ; preds = %2
br label %10
8: ; preds = %2
br label %10
9: ; preds = %2
br label %10
10: ; preds = %2, %9, %8, %7, %6, %5
%11 = phi i64 [ 0, %2 ], [ 1, %5 ], [ 2, %6 ], [ 3, %7 ], [ 4, %8 ], [ 5, %9 ]
%12 = getelementptr inbounds [7 x %struct.sSMtoCores], [7 x %struct.sSMtoCores]* @__const._ConvertSMVer2CoresDrvApi.nGpuArchCoresPerSM, i64 0, i64 %11, i32 1
%13 = load i32, i32* %12
br label %16
14: ; preds = %2
%15 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %16
16: ; preds = %14, %10
%17 = phi i32 [ %13, %10 ], [ -1, %14 ]
ret i32 %17
}