#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 int /*<<< orphan*/ max_mem_alloc_size;
typedef int /*<<< orphan*/ global_memsize;
typedef size_t cl_uint;
typedef int /*<<< orphan*/ cl_platform_id;
typedef int cl_long;
typedef int /*<<< orphan*/ cl_int;
typedef int /*<<< orphan*/ cl_device_id;

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_GLOBAL_MEM_SIZE;
int /*<<< orphan*/ CL_DEVICE_MAX_MEM_ALLOC_SIZE;
int /*<<< orphan*/ CL_DEVICE_TYPE_ALL;
int EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ check_cl_error(int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ clGetDeviceIDs(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                  int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ clGetDeviceInfo(int /*<<< orphan*/, int /*<<< orphan*/, int,
                                   int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ clGetPlatformIDs(int, int /*<<< orphan*/ *, size_t *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int main(void) {
  cl_int err;
  cl_platform_id platforms[32];
  cl_uint nplatforms;
  cl_device_id devices[32];
  cl_uint ndevices;
  cl_uint i, j;
  err = clGetPlatformIDs(32, platforms, &nplatforms);
  do {
    if (check_cl_error(err, 20, "clGetPlatformIDs"))
      exit(EXIT_FAILURE);
  } while (0);
  if (!nplatforms)
    return EXIT_FAILURE;
  for (i = 0; i < nplatforms; i++) {
    err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 32, devices,
                         &ndevices);
    do {
      if (check_cl_error(err, 28, "clGetDeviceIDs"))
        exit(EXIT_FAILURE);
    } while (0);
    for (j = 0; j < ndevices; j++) {
      cl_long global_memsize, max_mem_alloc_size, min_max_mem_alloc_size;
      err = clGetDeviceInfo(devices[j], CL_DEVICE_GLOBAL_MEM_SIZE,
                            sizeof(global_memsize), &global_memsize, NULL);
      do {
        if (check_cl_error(err, 36, "clGetDeviceInfo"))
          exit(EXIT_FAILURE);
      } while (0);
      err = clGetDeviceInfo(devices[j], CL_DEVICE_MAX_MEM_ALLOC_SIZE,
                            sizeof(max_mem_alloc_size), &max_mem_alloc_size,
                            NULL);
      do {
        if (check_cl_error(err, 41, "clGetDeviceInfo"))
          exit(EXIT_FAILURE);
      } while (0);
      do {
        if (!(global_memsize > 0)) {
          fprintf(stderr,
                  "Assertion: \n"
                  "global_memsize > 0"
                  "\nfailed on %s:%i\n",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/jrprice/pocl/refs/heads/"
                  "master/tests/runtime/test_clGetDeviceInfo.c",
                  43);
          return EXIT_FAILURE;
        }
      } while (0);
      min_max_mem_alloc_size = 128 * 1024 * 1024;
      if (min_max_mem_alloc_size < global_memsize / 4)
        min_max_mem_alloc_size = global_memsize / 4;
      do {
        if (!(max_mem_alloc_size >= min_max_mem_alloc_size)) {
          fprintf(stderr,
                  "Assertion: \n"
                  "max_mem_alloc_size >= min_max_mem_alloc_size"
                  "\nfailed on %s:%i\n",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/jrprice/pocl/refs/heads/"
                  "master/tests/runtime/test_clGetDeviceInfo.c",
                  49);
          return EXIT_FAILURE;
        }
      } while (0);
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rsi
mov    $0x20,%edi
lea    -0x98(%rbp),%rdx
call   1050 <clGetPlatformIDs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x14,%esi
lea    0xe64(%rip),%rdx
call   1070 <check_cl_error@plt>
cmp    $0x0,%rax
je     11b9 <main+0x59>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11be <main+0x5e>
cmpq   $0x0,-0x98(%rbp)
jne    11dd <main+0x7d>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1463 <main+0x303>
movq   $0x0,-0x130(%rbp)
mov    -0x130(%rbp),%rax
cmp    -0x98(%rbp),%rax
jae    1457 <main+0x2f7>
mov    -0x130(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%edi
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
lea    -0x120(%rbp),%rcx
mov    $0x20,%edx
lea    -0x128(%rbp),%r8
call   1030 <clGetDeviceIDs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1c,%esi
lea    0xdd4(%rip),%rdx
call   1070 <check_cl_error@plt>
cmp    $0x0,%rax
je     125a <main+0xfa>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    125f <main+0xff>
movq   $0x0,-0x138(%rbp)
mov    -0x138(%rbp),%rax
cmp    -0x128(%rbp),%rax
jae    143b <main+0x2db>
mov    -0x138(%rbp),%rax
mov    -0x120(%rbp,%rax,4),%edi
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x13c(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x24,%esi
lea    0xd63(%rip),%rdx
call   1070 <check_cl_error@plt>
cmp    $0x0,%rax
je     12da <main+0x17a>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    12df <main+0x17f>
mov    -0x138(%rbp),%rax
mov    -0x120(%rbp,%rax,4),%edi
mov    0x2d04(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    -0x140(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <clGetDeviceInfo@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x29,%esi
lea    0xd02(%rip),%rdx
call   1070 <check_cl_error@plt>
cmp    $0x0,%rax
je     133b <main+0x1db>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1340 <main+0x1e0>
jmp    1345 <main+0x1e5>
cmpl   $0x0,-0x13c(%rbp)
jg     1384 <main+0x224>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0xcce(%rip),%rsi
lea    0xcf7(%rip),%rdx
mov    $0x2b,%ecx
call   1060 <fprintf@plt>
mov    0x2c4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1463 <main+0x303>
jmp    1389 <main+0x229>
movl   $0x8000000,-0x144(%rbp)
mov    -0x144(%rbp),%eax
mov    %eax,-0x148(%rbp)
mov    -0x13c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x148(%rbp),%eax
cmp    %ecx,%eax
jge    13d1 <main+0x271>
mov    -0x13c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x144(%rbp)
jmp    13d6 <main+0x276>
mov    -0x140(%rbp),%eax
cmp    -0x144(%rbp),%eax
jge    141a <main+0x2ba>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
lea    0xc61(%rip),%rdx
mov    $0x31,%ecx
call   1060 <fprintf@plt>
mov    0x2bb8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1463 <main+0x303>
jmp    141f <main+0x2bf>
jmp    1424 <main+0x2c4>
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    126a <main+0x10a>
jmp    1440 <main+0x2e0>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
jmp    11e8 <main+0x88>
mov    0x2b62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
lea    0xa0(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    $0x20,%edi
call   1050 <clGetPlatformIDs@plt>
lea    0xe71(%rip),%rdx
mov    %eax,%edi
mov    $0x14,%esi
call   1070 <check_cl_error@plt>
test   %rax,%rax
jne    1351 <main+0x1f1>
cmpq   $0x0,0x18(%rsp)
je     132d <main+0x1cd>
xor    %r14d,%r14d
mov    0x2e26(%rip),%rax
lea    0x20(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0xe46(%rip),%rbp
lea    0xe4e(%rip),%rbx
jmp    1201 <main+0xa1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
cmp    0x18(%rsp),%r14
mov    0x2df0(%rip),%rax
lea    0x20(%rsp),%rcx
mov    %r15,%r8
mov    %r12,%rbp
jae    1348 <main+0x1e8>
mov    0xa0(%rsp,%r14,4),%edi
mov    (%rax),%esi
mov    $0x20,%edx
mov    %r8,%r15
call   1030 <clGetDeviceIDs@plt>
mov    %eax,%edi
mov    $0x1c,%esi
mov    %rbp,%r12
mov    %rbp,%rdx
call   1070 <check_cl_error@plt>
test   %rax,%rax
jne    1351 <main+0x1f1>
cmpq   $0x0,0x10(%rsp)
mov    0x2d70(%rip),%rbp
je     11e0 <main+0x80>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x20(%rsp,%r13,4),%edi
mov    0x0(%rbp),%esi
mov    $0x4,%edx
lea    0xc(%rsp),%rcx
xor    %r8d,%r8d
call   1040 <clGetDeviceInfo@plt>
mov    %eax,%edi
mov    $0x24,%esi
mov    %rbx,%rdx
call   1070 <check_cl_error@plt>
test   %rax,%rax
jne    1351 <main+0x1f1>
mov    0x20(%rsp,%r13,4),%edi
mov    0x2d6a(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edx
lea    0x8(%rsp),%rcx
xor    %r8d,%r8d
call   1040 <clGetDeviceInfo@plt>
mov    %eax,%edi
mov    $0x29,%esi
mov    %rbx,%rdx
call   1070 <check_cl_error@plt>
test   %rax,%rax
jne    1351 <main+0x1f1>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    12ee <main+0x18e>
mov    %eax,%ecx
shr    $0x2,%ecx
cmp    $0x20000004,%eax
mov    $0x8000000,%eax
cmovb  %eax,%ecx
cmp    %ecx,0x8(%rsp)
jl     130c <main+0x1ac>
add    $0x1,%r13
cmp    0x10(%rsp),%r13
jb     1250 <main+0xf0>
jmp    11e0 <main+0x80>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
lea    0xd5b(%rip),%rdx
mov    $0x2b,%ecx
jmp    1328 <main+0x1c8>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
lea    0xd3d(%rip),%rdx
mov    $0x31,%ecx
call   1060 <fprintf@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c71(%rip),%rax
jmp    1334 <main+0x1d4>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"clGetPlatformIDs\00"
@EXIT_FAILURE = global i32 0
@CL_DEVICE_TYPE_ALL = global i32 0
@.str.1 = [15 x i8] c"clGetDeviceIDs\00"
@CL_DEVICE_GLOBAL_MEM_SIZE = global i32 0
@.str.2 = [16 x i8] c"clGetDeviceInfo\00"
@CL_DEVICE_MAX_MEM_ALLOC_SIZE = global i32 0
@stderr = global i32 0
@.str.3 = [48 x i8] c"Assertion: \0Aglobal_memsize > 0\0Afailed on %s:%i\0A\00"
@.str.4 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jrprice/pocl/refs/heads/master/tests/runtime/test_clGetDeviceInfo.c\00"
@.str.5 = [74 x i8] c"Assertion: \0Amax_mem_alloc_size >= min_max_mem_alloc_size\0Afailed on %s:%i\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [32 x i32]
%4 = alloca i64
%5 = alloca [32 x i32]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%13 = call i32 @clGetPlatformIDs(i32 32, i32* %12, i64* %4)
store i32 %13, i32* %2
br label %14
14: ; preds = %0
%15 = load i32, i32* %2
%16 = call i64 @check_cl_error(i32 %15, i32 20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %14
br label %22
22: ; preds = %21
%23 = load i64, i64* %4
%24 = icmp ne i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = load i32, i32* @EXIT_FAILURE
store i32 %26, i32* %1
br label %117
27: ; preds = %22
store i64 0, i64* %7
br label %28
28: ; preds = %112, %27
%29 = load i64, i64* %7
%30 = load i64, i64* %4
%31 = icmp ult i64 %29, %30
br i1 %31, label %32, label %115
32: ; preds = %28
%33 = load i64, i64* %7
%34 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* @CL_DEVICE_TYPE_ALL
%37 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 0
%38 = call i32 @clGetDeviceIDs(i32 %35, i32 %36, i32 32, i32* %37, i64* %6)
store i32 %38, i32* %2
br label %39
39: ; preds = %32
%40 = load i32, i32* %2
%41 = call i64 @check_cl_error(i32 %40, i32 28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %39
br label %47
47: ; preds = %46
store i64 0, i64* %8
br label %48
48: ; preds = %108, %47
%49 = load i64, i64* %8
%50 = load i64, i64* %6
%51 = icmp ult i64 %49, %50
br i1 %51, label %52, label %111
52: ; preds = %48
%53 = load i64, i64* %8
%54 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = load i32, i32* @CL_DEVICE_GLOBAL_MEM_SIZE
%57 = call i32 @clGetDeviceInfo(i32 %55, i32 %56, i32 4, i32* %9, i32* null)
store i32 %57, i32* %2
br label %58
58: ; preds = %52
%59 = load i32, i32* %2
%60 = call i64 @check_cl_error(i32 %59, i32 36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %58
br label %66
66: ; preds = %65
%67 = load i64, i64* %8
%68 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = load i32, i32* @CL_DEVICE_MAX_MEM_ALLOC_SIZE
%71 = call i32 @clGetDeviceInfo(i32 %69, i32 %70, i32 4, i32* %10, i32* null)
store i32 %71, i32* %2
br label %72
72: ; preds = %66
%73 = load i32, i32* %2
%74 = call i64 @check_cl_error(i32 %73, i32 41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %72
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
%82 = load i32, i32* %9
%83 = icmp sgt i32 %82, 0
br i1 %83, label %88, label %84
84: ; preds = %81
%85 = load i32, i32* @stderr
%86 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.4, i64 0, i64 0), i32 43)
%87 = load i32, i32* @EXIT_FAILURE
store i32 %87, i32* %1
br label %117
88: ; preds = %81
br label %89
89: ; preds = %88
store i32 134217728, i32* %11
%90 = load i32, i32* %11
%91 = load i32, i32* %9
%92 = sdiv i32 %91, 4
%93 = icmp slt i32 %90, %92
br i1 %93, label %94, label %97
94: ; preds = %89
%95 = load i32, i32* %9
%96 = sdiv i32 %95, 4
store i32 %96, i32* %11
br label %97
97: ; preds = %94, %89
br label %98
98: ; preds = %97
%99 = load i32, i32* %10
%100 = load i32, i32* %11
%101 = icmp sge i32 %99, %100
br i1 %101, label %106, label %102
102: ; preds = %98
%103 = load i32, i32* @stderr
%104 = call i32 @fprintf(i32 %103, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.4, i64 0, i64 0), i32 49)
%105 = load i32, i32* @EXIT_FAILURE
store i32 %105, i32* %1
br label %117
106: ; preds = %98
br label %107
107: ; preds = %106
br label %108
108: ; preds = %107
%109 = load i64, i64* %8
%110 = add i64 %109, 1
store i64 %110, i64* %8
br label %48
111: ; preds = %48
br label %112
112: ; preds = %111
%113 = load i64, i64* %7
%114 = add i64 %113, 1
store i64 %114, i64* %7
br label %28
115: ; preds = %28
%116 = load i32, i32* @EXIT_SUCCESS
store i32 %116, i32* %1
br label %117
117: ; preds = %115, %102, %84, %25
%118 = load i32, i32* %1
ret i32 %118
}

LLVM IR (-O2):
@.str = [17 x i8] c"clGetPlatformIDs\00"
@EXIT_FAILURE = global i32 0
@CL_DEVICE_TYPE_ALL = global i32 0
@.str.1 = [15 x i8] c"clGetDeviceIDs\00"
@CL_DEVICE_GLOBAL_MEM_SIZE = global i32 0
@.str.2 = [16 x i8] c"clGetDeviceInfo\00"
@CL_DEVICE_MAX_MEM_ALLOC_SIZE = global i32 0
@stderr = global i32 0
@.str.3 = [48 x i8] c"Assertion: \0Aglobal_memsize > 0\0Afailed on %s:%i\0A\00"
@.str.4 = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jrprice/pocl/refs/heads/master/tests/runtime/test_clGetDeviceInfo.c\00"
@.str.5 = [74 x i8] c"Assertion: \0Amax_mem_alloc_size >= min_max_mem_alloc_size\0Afailed on %s:%i\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [32 x i32]
%2 = alloca i64
%3 = alloca [32 x i32]
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [32 x i32]* %1 to i8*
%8 = bitcast i64* %2 to i8*
%9 = bitcast [32 x i32]* %3 to i8*
%10 = bitcast i64* %4 to i8*
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 0
%12 = call i32 @clGetPlatformIDs(i32 32, i32* %11, i64* %2)
%13 = call i64 @check_cl_error(i32 %12, i32 20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %0
%19 = load i64, i64* %2
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%23 = bitcast i32* %5 to i8*
%24 = bitcast i32* %6 to i8*
br label %27
25: ; preds = %18
%26 = load i32, i32* @EXIT_FAILURE
br label %88
27: ; preds = %21, %82
%28 = phi i64 [ 0, %21 ], [ %83, %82 ]
%29 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = load i32, i32* @CL_DEVICE_TYPE_ALL
%32 = call i32 @clGetDeviceIDs(i32 %30, i32 %31, i32 32, i32* %22, i64* %4)
%33 = call i64 @check_cl_error(i32 %32, i32 28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = load i64, i64* %4
%37 = icmp eq i64 %36, 0
br i1 %37, label %82, label %41
38: ; preds = %27
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %35, %78
%42 = phi i64 [ %79, %78 ], [ 0, %35 ]
%43 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* @CL_DEVICE_GLOBAL_MEM_SIZE
%46 = call i32 @clGetDeviceInfo(i32 %44, i32 %45, i32 4, i32* %5, i32* null)
%47 = call i64 @check_cl_error(i32 %46, i32 36, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %41
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %41
%53 = load i32, i32* %43
%54 = load i32, i32* @CL_DEVICE_MAX_MEM_ALLOC_SIZE
%55 = call i32 @clGetDeviceInfo(i32 %53, i32 %54, i32 4, i32* %6, i32* null)
%56 = call i64 @check_cl_error(i32 %55, i32 41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %52
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %52
%62 = load i32, i32* %5
%63 = icmp sgt i32 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %61
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.4, i64 0, i64 0), i32 43)
br label %76
67: ; preds = %61
%68 = icmp ugt i32 %62, 536870915
%69 = lshr i32 %62, 2
%70 = select i1 %68, i32 %69, i32 134217728
%71 = load i32, i32* %6
%72 = icmp slt i32 %71, %70
br i1 %72, label %73, label %78
73: ; preds = %67
%74 = load i32, i32* @stderr
%75 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str.4, i64 0, i64 0), i32 49)
br label %76
76: ; preds = %73, %64
%77 = load i32, i32* @EXIT_FAILURE
br label %88
78: ; preds = %67
%79 = add nuw i64 %42, 1
%80 = load i64, i64* %4
%81 = icmp ult i64 %79, %80
br i1 %81, label %41, label %82
82: ; preds = %78, %35
%83 = add nuw i64 %28, 1
%84 = load i64, i64* %2
%85 = icmp ult i64 %83, %84
br i1 %85, label %27, label %86
86: ; preds = %82
%87 = load i32, i32* @EXIT_SUCCESS
br label %88
88: ; preds = %76, %86, %25
%89 = phi i32 [ %87, %86 ], [ %26, %25 ], [ %77, %76 ]
ret i32 %89
}