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

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_NAME;
int /*<<< orphan*/ clGetDeviceInfo(int /*<<< orphan*/, int /*<<< orphan*/,
                                   size_t, char *, size_t *);
int /*<<< orphan*/ clu_CheckErrorInternal(int /*<<< orphan*/, char *, char *,
                                          int);
scalar_t__ malloc(size_t);
char *clu_GetDeviceName(cl_device_id device) {
  size_t name_size;
  cl_int err_code;
  clGetDeviceInfo(device, CL_DEVICE_NAME, 0, NULL, &name_size);
  char *device_name = (char *)malloc(name_size + 1);
  err_code =
      clGetDeviceInfo(device, CL_DEVICE_NAME, name_size, device_name, NULL);
  clu_CheckErrorInternal(
      err_code, "clGetDeviceInfo()",
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/dividiti/pencil-benchmark/refs/heads/master/"
      "NAS/OpenCL/common/cl_util.c",
      216);
  char ch;
  char *cur_pos = device_name;
  char *rst_pos = device_name;
  while ((ch = *cur_pos++)) {
    if (ch == '(' && *cur_pos == 'R' && *(cur_pos + 1) == ')') {
      cur_pos += 2;
      *rst_pos++ = '_';
      continue;
    } else if (ch == ' ' || ch == '@' || ch == '(' || ch == ')') {
      if (rst_pos != device_name && (*(rst_pos - 1) != '_'))
        *rst_pos++ = '_';
      continue;
    }
    *rst_pos++ = ch;
  }
  *rst_pos = '\0';
  return device_name;
}


x86 assembly (clang, -O0):
<clu_GetDeviceName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x10(%rbp),%r8
mov    %rcx,%rdx
call   1030 <clGetDeviceInfo@plt>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <clGetDeviceInfo@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xe6d(%rip),%rsi
lea    0xe78(%rip),%rdx
mov    $0xd8,%ecx
call   1050 <clu_CheckErrorInternal@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%al
mov    %al,-0x21(%rbp)
cmp    $0x0,%al
je     12a9 <clu_GetDeviceName+0x179>
movsbl -0x21(%rbp),%eax
cmp    $0x28,%eax
jne    1221 <clu_GetDeviceName+0xf1>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x52,%eax
jne    1221 <clu_GetDeviceName+0xf1>
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x29,%eax
jne    1221 <clu_GetDeviceName+0xf1>
mov    -0x30(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x5f,(%rax)
jmp    11b4 <clu_GetDeviceName+0x84>
movsbl -0x21(%rbp),%eax
cmp    $0x20,%eax
je     1255 <clu_GetDeviceName+0x125>
movsbl -0x21(%rbp),%eax
cmp    $0x40,%eax
je     1255 <clu_GetDeviceName+0x125>
movsbl -0x21(%rbp),%eax
cmp    $0x28,%eax
je     1255 <clu_GetDeviceName+0x125>
movsbl -0x21(%rbp),%eax
cmp    $0x29,%eax
jne    128b <clu_GetDeviceName+0x15b>
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1286 <clu_GetDeviceName+0x156>
mov    -0x38(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5f,%eax
je     1286 <clu_GetDeviceName+0x156>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x5f,(%rax)
jmp    11b4 <clu_GetDeviceName+0x84>
jmp    1290 <clu_GetDeviceName+0x160>
mov    -0x21(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
mov    %cl,(%rax)
jmp    11b4 <clu_GetDeviceName+0x84>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clu_GetDeviceName>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebp
mov    0x2e9f(%rip),%r14
mov    (%r14),%esi
lea    0x8(%rsp),%r8
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <clGetDeviceInfo@plt>
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    (%r14),%esi
mov    0x8(%rsp),%rdx
mov    %ebp,%edi
mov    %rax,%rcx
xor    %r8d,%r8d
call   1030 <clGetDeviceInfo@plt>
lea    0xf05(%rip),%rsi
lea    0xf10(%rip),%rdx
mov    %eax,%edi
mov    $0xd8,%ecx
call   1050 <clu_CheckErrorInternal@plt>
lea    0xe67(%rip),%rax
mov    %rbx,%rcx
nopl   0x0(%rax)
mov    %rbx,%rdx
add    $0x1,%rcx
mov    %rcx,%rsi
nopw   0x0(%rax,%rax,1)
mov    %rsi,%rcx
movzbl -0x1(%rsi),%esi
lea    -0x20(%rsi),%edi
cmp    $0x20,%dil
ja     11fc <clu_GetDeviceName+0xcc>
movzbl %dil,%edi
movslq (%rax,%rdi,4),%rdi
add    %rax,%rdi
jmp    *%rdi
cmp    %rbx,%rdx
je     11a0 <clu_GetDeviceName+0x70>
lea    0x1(%rcx),%rsi
cmpb   $0x5f,-0x1(%rdx)
je     11b0 <clu_GetDeviceName+0x80>
jmp    11f0 <clu_GetDeviceName+0xc0>
xchg   %ax,%ax
cmpb   $0x52,(%rcx)
jne    11cd <clu_GetDeviceName+0x9d>
cmpb   $0x29,0x1(%rcx)
jne    11cd <clu_GetDeviceName+0x9d>
add    $0x2,%rcx
nop
mov    $0x5f,%sil
mov    %sil,(%rdx)
add    $0x1,%rdx
jmp    11a3 <clu_GetDeviceName+0x73>
test   %sil,%sil
jne    11f3 <clu_GetDeviceName+0xc3>
movb   $0x0,(%rdx)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@CL_DEVICE_NAME = global i32 0
@.str = [18 x i8] c"clGetDeviceInfo()\00"
@.str.1 = [162 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dividiti/pencil-benchmark/refs/heads/master/NAS/OpenCL/common/cl_util.c\00"
define i8* @clu_GetDeviceName(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
store i32 %0, i32* %2
%9 = load i32, i32* %2
%10 = load i32, i32* @CL_DEVICE_NAME
%11 = call i32 @clGetDeviceInfo(i32 %9, i32 %10, i64 0, i8* null, i64* %3)
%12 = load i64, i64* %3
%13 = add i64 %12, 1
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %5
%16 = load i32, i32* %2
%17 = load i32, i32* @CL_DEVICE_NAME
%18 = load i64, i64* %3
%19 = load i8*, i8** %5
%20 = call i32 @clGetDeviceInfo(i32 %16, i32 %17, i64 %18, i8* %19, i64* null)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i32 @clu_CheckErrorInternal(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.1, i64 0, i64 0), i32 216)
%23 = load i8*, i8** %5
store i8* %23, i8** %7
%24 = load i8*, i8** %5
store i8* %24, i8** %8
br label %25
25: ; preds = %81, %79, %45, %1
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %7
%28 = load i8, i8* %26
store i8 %28, i8* %6
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %85
30: ; preds = %25
%31 = load i8, i8* %6
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 40
br i1 %33, label %34, label %50
34: ; preds = %30
%35 = load i8*, i8** %7
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 82
br i1 %38, label %39, label %50
39: ; preds = %34
%40 = load i8*, i8** %7
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 41
br i1 %44, label %45, label %50
45: ; preds = %39
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i64 2
store i8* %47, i8** %7
%48 = load i8*, i8** %8
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %8
store i8 95, i8* %48
br label %25
50: ; preds = %39, %34, %30
%51 = load i8, i8* %6
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 32
br i1 %53, label %66, label %54
54: ; preds = %50
%55 = load i8, i8* %6
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 64
br i1 %57, label %66, label %58
58: ; preds = %54
%59 = load i8, i8* %6
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 40
br i1 %61, label %66, label %62
62: ; preds = %58
%63 = load i8, i8* %6
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 41
br i1 %65, label %66, label %80
66: ; preds = %62, %58, %54, %50
%67 = load i8*, i8** %8
%68 = load i8*, i8** %5
%69 = icmp ne i8* %67, %68
br i1 %69, label %70, label %79
70: ; preds = %66
%71 = load i8*, i8** %8
%72 = getelementptr inbounds i8, i8* %71, i64 -1
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 95
br i1 %75, label %76, label %79
76: ; preds = %70
%77 = load i8*, i8** %8
%78 = getelementptr inbounds i8, i8* %77, i32 1
store i8* %78, i8** %8
store i8 95, i8* %77
br label %79
79: ; preds = %76, %70, %66
br label %25
80: ; preds = %62
br label %81
81: ; preds = %80
%82 = load i8, i8* %6
%83 = load i8*, i8** %8
%84 = getelementptr inbounds i8, i8* %83, i32 1
store i8* %84, i8** %8
store i8 %82, i8* %83
br label %25
85: ; preds = %25
%86 = load i8*, i8** %8
store i8 0, i8* %86
%87 = load i8*, i8** %5
ret i8* %87
}

LLVM IR (-O2):
@CL_DEVICE_NAME = global i32 0
@.str = [18 x i8] c"clGetDeviceInfo()\00"
@.str.1 = [162 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dividiti/pencil-benchmark/refs/heads/master/NAS/OpenCL/common/cl_util.c\00"
define i8* @clu_GetDeviceName(i32 %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = load i32, i32* @CL_DEVICE_NAME
%5 = call i32 @clGetDeviceInfo(i32 %0, i32 %4, i64 0, i8* null, i64* %2)
%6 = load i64, i64* %2
%7 = add i64 %6, 1
%8 = call i64 @malloc(i64 %7)
%9 = inttoptr i64 %8 to i8*
%10 = load i32, i32* @CL_DEVICE_NAME
%11 = load i64, i64* %2
%12 = call i32 @clGetDeviceInfo(i32 %0, i32 %10, i64 %11, i8* %9, i64* null)
%13 = call i32 @clu_CheckErrorInternal(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([162 x i8], [162 x i8]* @.str.1, i64 0, i64 0), i32 216)
br label %14
14: ; preds = %36, %1
%15 = phi i8* [ %9, %1 ], [ %37, %36 ]
%16 = phi i8* [ %9, %1 ], [ %38, %36 ]
%17 = icmp eq i8* %16, %9
%18 = getelementptr inbounds i8, i8* %16, i64 -1
br label %19
19: ; preds = %14, %40
%20 = phi i8* [ %21, %40 ], [ %15, %14 ]
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %20
switch i8 %22, label %32 [
i8 0, label %43
i8 40, label %23
i8 64, label %39
i8 41, label %39
i8 32, label %39
]
23: ; preds = %19
%24 = load i8, i8* %21
%25 = icmp eq i8 %24, 82
br i1 %25, label %26, label %39
26: ; preds = %23
%27 = getelementptr inbounds i8, i8* %20, i64 2
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 41
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = getelementptr inbounds i8, i8* %20, i64 3
br label %32
32: ; preds = %19, %40, %30
%33 = phi i8 [ 95, %30 ], [ %22, %19 ], [ 95, %40 ]
%34 = phi i8* [ %31, %30 ], [ %21, %40 ], [ %21, %19 ]
%35 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %33, i8* %16
br label %36
36: ; preds = %39, %32
%37 = phi i8* [ %34, %32 ], [ %21, %39 ]
%38 = phi i8* [ %35, %32 ], [ %9, %39 ]
br label %14
39: ; preds = %23, %26, %19, %19, %19
br i1 %17, label %36, label %40
40: ; preds = %39
%41 = load i8, i8* %18
%42 = icmp eq i8 %41, 95
br i1 %42, label %19, label %32
43: ; preds = %19
store i8 0, i8* %16
ret i8* %9
}