#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 */
typedef char cl_platform_id;
typedef int /*<<< orphan*/ cl_int;
typedef char cl_device_id;
typedef int /*<<< orphan*/ cl_context;

/* Variables and functions */
int /*<<< orphan*/ CL_CONTEXT_DEVICES;
int /*<<< orphan*/ CL_DEVICE_PLATFORM;
int /*<<< orphan*/ CL_PLATFORM_NAME;
char *calloc(size_t, int);
int /*<<< orphan*/ check_cl_error(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ clGetContextInfo(int /*<<< orphan*/, int /*<<< orphan*/,
                                    size_t, char *, size_t *);
int /*<<< orphan*/ clGetDeviceInfo(char, int /*<<< orphan*/, size_t, char *,
                                   size_t *);
int /*<<< orphan*/ clGetPlatformInfo(char, int /*<<< orphan*/, size_t, char *,
                                     size_t *);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
char *strstr(char *, char *);
int is_nvidia_platform(cl_context context) {
  cl_int cl_err;
  size_t size_dev, size_platform;
  cl_device_id *device;
  cl_platform_id *platform;
  size_t platform_name_len = 0;
  char *platform_name;
  cl_err = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size_dev);
  check_cl_error(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/"
      "refs/heads/master/src/utils/util_functions.c",
      460, cl_err);
  device = malloc(size_dev);
  cl_err =
      clGetContextInfo(context, CL_CONTEXT_DEVICES, size_dev, device, NULL);
  check_cl_error(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/"
      "refs/heads/master/src/utils/util_functions.c",
      465, cl_err);
  cl_err =
      clGetDeviceInfo(device[0], CL_DEVICE_PLATFORM, 0, NULL, &size_platform);
  check_cl_error(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/"
      "refs/heads/master/src/utils/util_functions.c",
      469, cl_err);
  platform = malloc(size_platform);
  cl_err = clGetDeviceInfo(device[0], CL_DEVICE_PLATFORM, size_platform,
                           platform, NULL);
  check_cl_error(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/"
      "refs/heads/master/src/utils/util_functions.c",
      474, cl_err);
  cl_err = clGetPlatformInfo(platform[0], CL_PLATFORM_NAME, 0, NULL,
                             &platform_name_len);
  check_cl_error(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/"
      "refs/heads/master/src/utils/util_functions.c",
      478, cl_err);
  platform_name = calloc(platform_name_len, sizeof(char));
  cl_err = clGetPlatformInfo(platform[0], CL_PLATFORM_NAME, platform_name_len,
                             platform_name, NULL);
  check_cl_error(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/"
      "refs/heads/master/src/utils/util_functions.c",
      484, cl_err);
  char *found;
  found = strstr(platform_name, "NVIDIA");
  int ret = (found) ? 1 : 0;
  free(platform_name);
  free(device);
  free(platform);
  return ret;
}


x86 assembly (clang, -O0):
<is_nvidia_platform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x10(%rbp),%r8
mov    %rcx,%rdx
call   1030 <clGetContextInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xe44(%rip),%rdi
mov    $0x1cc,%esi
call   1080 <check_cl_error@plt>
mov    -0x10(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <clGetContextInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xe02(%rip),%rdi
mov    $0x1d1,%esi
call   1080 <check_cl_error@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    0x2dd3(%rip),%rcx
mov    (%rcx),%esi
xor    %ecx,%ecx
lea    -0x18(%rbp),%r8
movsbl %al,%edi
mov    %rcx,%rdx
call   1050 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xdcb(%rip),%rdi
mov    $0x1d5,%esi
call   1080 <check_cl_error@plt>
mov    -0x18(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    0x2d8f(%rip),%rcx
mov    (%rcx),%esi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
xor    %edi,%edi
mov    %edi,%r8d
movsbl %al,%edi
call   1050 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xd83(%rip),%rdi
mov    $0x1da,%esi
call   1080 <check_cl_error@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    0x2d3c(%rip),%rcx
mov    (%rcx),%esi
xor    %ecx,%ecx
lea    -0x30(%rbp),%r8
movsbl %al,%edi
mov    %rcx,%rdx
call   1060 <clGetPlatformInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xd4c(%rip),%rdi
mov    $0x1de,%esi
call   1080 <check_cl_error@plt>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    0x2cf3(%rip),%rcx
mov    (%rcx),%esi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
xor    %edi,%edi
mov    %edi,%r8d
movsbl %al,%edi
call   1060 <clGetPlatformInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
lea    0xcff(%rip),%rdi
mov    $0x1e4,%esi
call   1080 <check_cl_error@plt>
mov    -0x38(%rbp),%rdi
lea    0xd9b(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_nvidia_platform>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
mov    0x2e42(%rip),%r12
mov    (%r12),%esi
lea    0x18(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <clGetContextInfo@plt>
lea    0xe49(%rip),%r14
mov    %r14,%rdi
mov    $0x1cc,%esi
mov    %eax,%edx
call   1080 <check_cl_error@plt>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    (%r12),%esi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1030 <clGetContextInfo@plt>
mov    %r14,%rdi
mov    $0x1d1,%esi
mov    %eax,%edx
call   1080 <check_cl_error@plt>
movsbl (%r15),%edi
mov    0x2de4(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x10(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <clGetDeviceInfo@plt>
mov    %r14,%rdi
mov    $0x1d5,%esi
mov    %eax,%edx
call   1080 <check_cl_error@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <malloc@plt>
mov    %rax,%r12
movsbl (%r15),%edi
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1050 <clGetDeviceInfo@plt>
mov    %r14,%rdi
mov    $0x1da,%esi
mov    %eax,%edx
call   1080 <check_cl_error@plt>
movsbl (%r12),%edi
mov    0x2d6c(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x8(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1060 <clGetPlatformInfo@plt>
mov    %r14,%rdi
mov    $0x1de,%esi
mov    %eax,%edx
call   1080 <check_cl_error@plt>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
movsbl (%r12),%edi
mov    0x0(%rbp),%esi
mov    0x8(%rsp),%rdx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1060 <clGetPlatformInfo@plt>
mov    %r14,%rdi
mov    $0x1e4,%esi
mov    %eax,%edx
call   1080 <check_cl_error@plt>
lea    0xded(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strstr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %r12,%rdi
call   1040 <free@plt>
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CL_CONTEXT_DEVICES = global i32 0
@.str = [177 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/refs/heads/master/src/utils/util_functions.c\00"
@CL_DEVICE_PLATFORM = global i32 0
@CL_PLATFORM_NAME = global i32 0
@.str.1 = [7 x i8] c"NVIDIA\00"
define i32 @is_nvidia_platform(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 %0, i32* %2
store i64 0, i64* %8
%12 = load i32, i32* %2
%13 = load i32, i32* @CL_CONTEXT_DEVICES
%14 = call i32 @clGetContextInfo(i32 %12, i32 %13, i64 0, i8* null, i64* %4)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 460, i32 %15)
%17 = load i64, i64* %4
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %6
%19 = load i32, i32* %2
%20 = load i32, i32* @CL_CONTEXT_DEVICES
%21 = load i64, i64* %4
%22 = load i8*, i8** %6
%23 = call i32 @clGetContextInfo(i32 %19, i32 %20, i64 %21, i8* %22, i64* null)
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 465, i32 %24)
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = load i32, i32* @CL_DEVICE_PLATFORM
%30 = call i32 @clGetDeviceInfo(i8 signext %28, i32 %29, i64 0, i8* null, i64* %5)
store i32 %30, i32* %3
%31 = load i32, i32* %3
%32 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 469, i32 %31)
%33 = load i64, i64* %5
%34 = call i8* @malloc(i64 %33)
store i8* %34, i8** %7
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i64 0
%37 = load i8, i8* %36
%38 = load i32, i32* @CL_DEVICE_PLATFORM
%39 = load i64, i64* %5
%40 = load i8*, i8** %7
%41 = call i32 @clGetDeviceInfo(i8 signext %37, i32 %38, i64 %39, i8* %40, i64* null)
store i32 %41, i32* %3
%42 = load i32, i32* %3
%43 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 474, i32 %42)
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i64 0
%46 = load i8, i8* %45
%47 = load i32, i32* @CL_PLATFORM_NAME
%48 = call i32 @clGetPlatformInfo(i8 signext %46, i32 %47, i64 0, i8* null, i64* %8)
store i32 %48, i32* %3
%49 = load i32, i32* %3
%50 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 478, i32 %49)
%51 = load i64, i64* %8
%52 = call i8* @calloc(i64 %51, i32 1)
store i8* %52, i8** %9
%53 = load i8*, i8** %7
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = load i8, i8* %54
%56 = load i32, i32* @CL_PLATFORM_NAME
%57 = load i64, i64* %8
%58 = load i8*, i8** %9
%59 = call i32 @clGetPlatformInfo(i8 signext %55, i32 %56, i64 %57, i8* %58, i64* null)
store i32 %59, i32* %3
%60 = load i32, i32* %3
%61 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 484, i32 %60)
%62 = load i8*, i8** %9
%63 = call i8* @strstr(i8* %62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i8* %63, i8** %10
%64 = load i8*, i8** %10
%65 = icmp ne i8* %64, null
%66 = zext i1 %65 to i64
%67 = select i1 %65, i32 1, i32 0
store i32 %67, i32* %11
%68 = load i8*, i8** %9
%69 = call i32 @free(i8* %68)
%70 = load i8*, i8** %6
%71 = call i32 @free(i8* %70)
%72 = load i8*, i8** %7
%73 = call i32 @free(i8* %72)
%74 = load i32, i32* %11
ret i32 %74
}

LLVM IR (-O2):
@CL_CONTEXT_DEVICES = global i32 0
@.str = [177 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/GPUOpen-ProfessionalCompute-Tools/clARMOR/refs/heads/master/src/utils/util_functions.c\00"
@CL_DEVICE_PLATFORM = global i32 0
@CL_PLATFORM_NAME = global i32 0
@.str.1 = [7 x i8] c"NVIDIA\00"
define i32 @is_nvidia_platform(i32 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%8 = load i32, i32* @CL_CONTEXT_DEVICES
%9 = call i32 @clGetContextInfo(i32 %0, i32 %8, i64 0, i8* null, i64* %2)
%10 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 460, i32 %9)
%11 = load i64, i64* %2
%12 = call i8* @malloc(i64 %11)
%13 = load i32, i32* @CL_CONTEXT_DEVICES
%14 = call i32 @clGetContextInfo(i32 %0, i32 %13, i64 %11, i8* %12, i64* null)
%15 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 465, i32 %14)
%16 = load i8, i8* %12
%17 = load i32, i32* @CL_DEVICE_PLATFORM
%18 = call i32 @clGetDeviceInfo(i8 signext %16, i32 %17, i64 0, i8* null, i64* %3)
%19 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 469, i32 %18)
%20 = load i64, i64* %3
%21 = call i8* @malloc(i64 %20)
%22 = load i8, i8* %12
%23 = load i32, i32* @CL_DEVICE_PLATFORM
%24 = call i32 @clGetDeviceInfo(i8 signext %22, i32 %23, i64 %20, i8* %21, i64* null)
%25 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 474, i32 %24)
%26 = load i8, i8* %21
%27 = load i32, i32* @CL_PLATFORM_NAME
%28 = call i32 @clGetPlatformInfo(i8 signext %26, i32 %27, i64 0, i8* null, i64* %4)
%29 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 478, i32 %28)
%30 = load i64, i64* %4
%31 = call i8* @calloc(i64 %30, i32 1)
%32 = load i8, i8* %21
%33 = load i32, i32* @CL_PLATFORM_NAME
%34 = load i64, i64* %4
%35 = call i32 @clGetPlatformInfo(i8 signext %32, i32 %33, i64 %34, i8* %31, i64* null)
%36 = call i32 @check_cl_error(i8* getelementptr inbounds ([177 x i8], [177 x i8]* @.str, i64 0, i64 0), i32 484, i32 %35)
%37 = call i8* @strstr(i8* dereferenceable(1) %31, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp ne i8* %37, null
%39 = zext i1 %38 to i32
%40 = call i32 @free(i8* %31)
%41 = call i32 @free(i8* %12)
%42 = call i32 @free(i8* %21)
ret i32 %39
}