#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 cl_uint;
typedef int /*<<< orphan*/ cl_platform_id;
typedef scalar_t__ cl_int;

/* Variables and functions */
scalar_t__ CL_OUT_OF_HOST_MEMORY;
scalar_t__ CL_SUCCESS;
scalar_t__ clGetPlatformIDs(int, int /*<<< orphan*/ *, int *);
char *errcode_str(scalar_t__);
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ platform_info(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char *);
int main() {
  cl_platform_id *platforms;
  cl_int result;
  cl_uint num;
  int i;
  result = clGetPlatformIDs(0, 0, &num);
  if (result != CL_SUCCESS) {
    do {
      printf("Error at %i: %s\n", 209, errcode_str(result));
    } while (0);
    ;
    return 1;
  }
  platforms = malloc(num * sizeof(cl_platform_id));
  if (!platforms) {
    do {
      printf("Error at %i: %s\n", 217, errcode_str(CL_OUT_OF_HOST_MEMORY));
    } while (0);
    ;
    return 1;
  }
  result = clGetPlatformIDs(num, platforms, 0);
  if (result != CL_SUCCESS) {
    do {
      printf("Error at %i: %s\n", 225, errcode_str(result));
    } while (0);
    ;
    return 1;
  }
  for (i = 0; i < num; ++i) {
    platform_info(platforms[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x1c(%rbp),%rdx
call   1030 <clGetPlatformIDs@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
je     11b4 <main+0x64>
jmp    118b <main+0x3b>
mov    -0x18(%rbp),%rdi
call   1060 <errcode_str@plt>
mov    %rax,%rdx
lea    0xe62(%rip),%rdi
mov    $0xd1,%esi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128d <main+0x13d>
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1206 <main+0xb6>
jmp    11d7 <main+0x87>
mov    0x2e02(%rip),%rax
mov    (%rax),%rdi
call   1060 <errcode_str@plt>
mov    %rax,%rdx
lea    0xe10(%rip),%rdi
mov    $0xd9,%esi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128d <main+0x13d>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <clGetPlatformIDs@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2db3(%rip),%rcx
cmp    (%rcx),%rax
je     125c <main+0x10c>
jmp    1233 <main+0xe3>
mov    -0x18(%rbp),%rdi
call   1060 <errcode_str@plt>
mov    %rax,%rdx
lea    0xdba(%rip),%rdi
mov    $0xe1,%esi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    128d <main+0x13d>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    128d <main+0x13d>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1070 <platform_info@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1263 <main+0x113>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <clGetPlatformIDs@plt>
mov    0x2e66(%rip),%r12
cmp    (%r12),%rax
jne    11da <main+0x8a>
mov    0xc(%rsp),%r15d
lea    0x0(,%r15,4),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11e1 <main+0x91>
mov    %rax,%r13
xor    %r14d,%r14d
mov    %r15d,%edi
mov    %rax,%rsi
xor    %edx,%edx
call   1030 <clGetPlatformIDs@plt>
cmp    (%r12),%rax
jne    11f2 <main+0xa2>
cmpl   $0x0,0xc(%rsp)
jle    1216 <main+0xc6>
xor    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13,%rbx,4),%edi
call   1070 <platform_info@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11c0 <main+0x70>
jmp    1216 <main+0xc6>
mov    $0xd1,%ebx
jmp    11f7 <main+0xa7>
mov    0x2df8(%rip),%rax
mov    (%rax),%rax
mov    $0xd9,%ebx
jmp    11f7 <main+0xa7>
mov    $0xe1,%ebx
mov    %rax,%rdi
call   1060 <errcode_str@plt>
lea    0xdfa(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@CL_SUCCESS = global i64 0
@.str = [17 x i8] c"Error at %i: %s\0A\00"
@CL_OUT_OF_HOST_MEMORY = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 @clGetPlatformIDs(i32 0, i32* null, i32* %4)
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = load i64, i64* @CL_SUCCESS
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %0
br label %11
11: ; preds = %10
%12 = load i64, i64* %3
%13 = call i8* @errcode_str(i64 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 209, i8* %13)
br label %15
15: ; preds = %11
store i32 1, i32* %1
br label %58
16: ; preds = %0
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = trunc i64 %19 to i32
%21 = call i32* @malloc(i32 %20)
store i32* %21, i32** %2
%22 = load i32*, i32** %2
%23 = icmp ne i32* %22, null
br i1 %23, label %30, label %24
24: ; preds = %16
br label %25
25: ; preds = %24
%26 = load i64, i64* @CL_OUT_OF_HOST_MEMORY
%27 = call i8* @errcode_str(i64 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 217, i8* %27)
br label %29
29: ; preds = %25
store i32 1, i32* %1
br label %58
30: ; preds = %16
%31 = load i32, i32* %4
%32 = load i32*, i32** %2
%33 = call i64 @clGetPlatformIDs(i32 %31, i32* %32, i32* null)
store i64 %33, i64* %3
%34 = load i64, i64* %3
%35 = load i64, i64* @CL_SUCCESS
%36 = icmp ne i64 %34, %35
br i1 %36, label %37, label %43
37: ; preds = %30
br label %38
38: ; preds = %37
%39 = load i64, i64* %3
%40 = call i8* @errcode_str(i64 %39)
%41 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 225, i8* %40)
br label %42
42: ; preds = %38
store i32 1, i32* %1
br label %58
43: ; preds = %30
store i32 0, i32* %5
br label %44
44: ; preds = %55, %43
%45 = load i32, i32* %5
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %58
48: ; preds = %44
%49 = load i32*, i32** %2
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = call i32 @platform_info(i32 %53)
br label %55
55: ; preds = %48
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %44
58: ; preds = %15, %29, %42, %44
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@CL_SUCCESS = global i64 0
@.str = [17 x i8] c"Error at %i: %s\0A\00"
@CL_OUT_OF_HOST_MEMORY = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @clGetPlatformIDs(i32 0, i32* null, i32* %1)
%4 = load i64, i64* @CL_SUCCESS
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %29
6: ; preds = %0
%7 = load i32, i32* %1
%8 = shl i32 %7, 2
%9 = call i32* @malloc(i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = load i64, i64* @CL_OUT_OF_HOST_MEMORY
br label %29
13: ; preds = %6
%14 = call i64 @clGetPlatformIDs(i32 %7, i32* %9, i32* null)
%15 = load i64, i64* @CL_SUCCESS
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %17, %20
%21 = phi i64 [ %25, %20 ], [ 0, %17 ]
%22 = getelementptr inbounds i32, i32* %9, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @platform_info(i32 %23)
%25 = add nuw nsw i64 %21, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %20, label %34
29: ; preds = %13, %0, %11
%30 = phi i64 [ %12, %11 ], [ %3, %0 ], [ %14, %13 ]
%31 = phi i32 [ 217, %11 ], [ 209, %0 ], [ 225, %13 ]
%32 = call i8* @errcode_str(i64 %30)
%33 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %31, i8* %32)
br label %34
34: ; preds = %20, %29, %17
%35 = phi i32 [ 0, %17 ], [ 1, %29 ], [ 0, %20 ]
ret i32 %35
}