#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*/ output;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
size_t strlen(char *);
char const *get_gpu(void) {
  static char ret[255];
  FILE *fp;
  char output[255];
  size_t i, len;
  char *cmd = "system_profiler -detailLevel mini SPDisplaysDataType 2> "
              "/dev/null | grep \"Chipset Model:\" | sed -e 's/Chipset "
              "Model://' | sed -e 's/^[ \\t ]*//'";
  fp = popen(cmd, "r");
  if (!fp)
    return NULL;
  if ((len = fread(output, 1, sizeof(output) - 1, fp)) == 0) {
    pclose(fp);
    return NULL;
  }
  pclose(fp);
  output[len] = '\0';
  len = strlen(output);
  memcpy(ret, output, len);
  for (i = 0; i < len; i++) {
    if (ret[i] == '\n') {
      ret[i] = ',';
    }
  }
  ret[len - 1] = '\0';
  return ret;
}


x86 assembly (clang, -O0):
<get_gpu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
lea    0xe9e(%rip),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
lea    0xf19(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1198 <get_gpu+0x48>
movq   $0x0,-0x8(%rbp)
jmp    12a7 <get_gpu+0x157>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0xfe,%edx
call   1030 <fread@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
jne    11d9 <get_gpu+0x89>
mov    -0x10(%rbp),%rdi
call   1050 <pclose@plt>
movq   $0x0,-0x8(%rbp)
jmp    12a7 <get_gpu+0x157>
mov    -0x10(%rbp),%rdi
call   1050 <pclose@plt>
mov    -0x120(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rsi
mov    -0x120(%rbp),%rdx
lea    0x2e47(%rip),%rdi
call   1060 <memcpy@plt>
movq   $0x0,-0x118(%rbp)
mov    -0x118(%rbp),%rax
cmp    -0x120(%rbp),%rax
jae    1286 <get_gpu+0x136>
mov    -0x118(%rbp),%rcx
lea    0x2e15(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    126a <get_gpu+0x11a>
mov    -0x118(%rbp),%rcx
lea    0x2dfa(%rip),%rax
movb   $0x2c,(%rax,%rcx,1)
jmp    126f <get_gpu+0x11f>
mov    -0x118(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x118(%rbp)
jmp    1229 <get_gpu+0xd9>
mov    -0x120(%rbp),%rcx
sub    $0x1,%rcx
lea    0x2dc8(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2dbd(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_gpu>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xebd(%rip),%rdi
lea    0xf46(%rip),%rsi
call   1070 <popen@plt>
test   %rax,%rax
je     11da <get_gpu+0x8a>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0xfe,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <pclose@plt>
test   %r14,%r14
je     11da <get_gpu+0x8a>
movb   $0x0,(%rsp,%r14,1)
mov    %rsp,%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%r14
lea    0x2eaa(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1060 <memcpy@plt>
test   %r14,%r14
je     139b <get_gpu+0x24b>
cmp    $0x10,%r14
jae    11e1 <get_gpu+0x91>
xor    %eax,%eax
jmp    138b <get_gpu+0x23b>
xor    %ebx,%ebx
jmp    13a1 <get_gpu+0x251>
mov    %r14,%rax
and    $0xfffffffffffffff0,%rax
xor    %ecx,%ecx
movdqa 0xe0e(%rip),%xmm0
movdqa 0xe16(%rip),%xmm1
jmp    120d <get_gpu+0xbd>
nopl   0x0(%rax)
add    $0x10,%rcx
cmp    %rcx,%rax
je     1386 <get_gpu+0x236>
movq   (%rcx,%rbx,1),%xmm3
movdqa %xmm3,%xmm2
pcmpeqb %xmm0,%xmm2
movd   %xmm2,%edx
test   $0x1,%dl
je     1227 <get_gpu+0xd7>
movb   $0x2c,(%rcx,%rbx,1)
movdqa %xmm2,%xmm4
pslld  $0x8,%xmm4
movd   %xmm4,%edx
shr    $0x10,%edx
test   $0x1,%dl
je     1241 <get_gpu+0xf1>
movb   $0x2c,0x1(%rcx,%rbx,1)
pshuflw $0x55,%xmm3,%xmm4
pcmpeqb %xmm0,%xmm4
pextrw $0x2,%xmm4,%edx
test   $0x1,%dl
je     1259 <get_gpu+0x109>
movb   $0x2c,0x2(%rcx,%rbx,1)
movdqa %xmm2,%xmm4
psllq  $0x18,%xmm4
pextrw $0x3,%xmm4,%edx
test   $0x1,%dl
je     1271 <get_gpu+0x121>
movb   $0x2c,0x3(%rcx,%rbx,1)
pshufd $0x55,%xmm3,%xmm3
pcmpeqb %xmm1,%xmm3
pextrw $0x4,%xmm3,%edx
test   $0x1,%dl
je     1289 <get_gpu+0x139>
movb   $0x2c,0x4(%rcx,%rbx,1)
movdqa %xmm2,%xmm3
pslldq $0x5,%xmm3
pextrw $0x5,%xmm3,%edx
test   $0x1,%dl
je     12a1 <get_gpu+0x151>
movb   $0x2c,0x5(%rcx,%rbx,1)
pextrw $0x3,%xmm2,%edx
test   $0x1,%dl
je     12b0 <get_gpu+0x160>
movb   $0x2c,0x6(%rcx,%rbx,1)
pslldq $0x7,%xmm2
pextrw $0x7,%xmm2,%edx
test   $0x1,%dl
je     12c4 <get_gpu+0x174>
movb   $0x2c,0x7(%rcx,%rbx,1)
movq   0x8(%rcx,%rbx,1),%xmm3
movdqa %xmm3,%xmm2
pcmpeqb %xmm0,%xmm2
movd   %xmm2,%edx
test   $0x1,%dl
je     12e0 <get_gpu+0x190>
movb   $0x2c,0x8(%rcx,%rbx,1)
movdqa %xmm2,%xmm4
pslld  $0x8,%xmm4
movd   %xmm4,%edx
shr    $0x10,%edx
test   $0x1,%dl
je     12fa <get_gpu+0x1aa>
movb   $0x2c,0x9(%rcx,%rbx,1)
pshuflw $0x55,%xmm3,%xmm4
pcmpeqb %xmm0,%xmm4
pextrw $0x2,%xmm4,%edx
test   $0x1,%dl
je     1312 <get_gpu+0x1c2>
movb   $0x2c,0xa(%rcx,%rbx,1)
movdqa %xmm2,%xmm4
psllq  $0x18,%xmm4
pextrw $0x3,%xmm4,%edx
test   $0x1,%dl
je     132a <get_gpu+0x1da>
movb   $0x2c,0xb(%rcx,%rbx,1)
pshufd $0x55,%xmm3,%xmm3
pcmpeqb %xmm1,%xmm3
pextrw $0x4,%xmm3,%edx
test   $0x1,%dl
je     1342 <get_gpu+0x1f2>
movb   $0x2c,0xc(%rcx,%rbx,1)
movdqa %xmm2,%xmm3
pslldq $0x5,%xmm3
pextrw $0x5,%xmm3,%edx
test   $0x1,%dl
je     135a <get_gpu+0x20a>
movb   $0x2c,0xd(%rcx,%rbx,1)
pextrw $0x3,%xmm2,%edx
test   $0x1,%dl
je     1369 <get_gpu+0x219>
movb   $0x2c,0xe(%rcx,%rbx,1)
pslldq $0x7,%xmm2
pextrw $0x7,%xmm2,%edx
test   $0x1,%dl
je     1200 <get_gpu+0xb0>
movb   $0x2c,0xf(%rcx,%rbx,1)
jmp    1200 <get_gpu+0xb0>
cmp    %rax,%r14
je     139b <get_gpu+0x24b>
cmpb   $0xa,(%rax,%rbx,1)
jne    1395 <get_gpu+0x245>
movb   $0x2c,(%rax,%rbx,1)
add    $0x1,%rax
jmp    1386 <get_gpu+0x236>
movb   $0x0,-0x1(%r14,%rbx,1)
mov    %rbx,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@get_gpu.ret = internal global [255 x i8] zeroinitializer
@.str = [144 x i8] c"system_profiler -detailLevel mini SPDisplaysDataType 2> /dev/null | grep \22Chipset Model:\22 | sed -e 's/Chipset Model://' | sed -e 's/^[ \\t ]*//'\00"
@.str.1 = [2 x i8] c"r\00"
define i8* @get_gpu() {
%1 = alloca i8*
%2 = alloca i32*
%3 = alloca [255 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
store i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8*, i8** %6
%8 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %0
store i8* null, i8** %1
br label %51
12: ; preds = %0
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%14 = load i32*, i32** %2
%15 = call i64 @fread(i8* %13, i32 1, i32 254, i32* %14)
store i64 %15, i64* %5
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32*, i32** %2
%19 = call i32 @pclose(i32* %18)
store i8* null, i8** %1
br label %51
20: ; preds = %12
%21 = load i32*, i32** %2
%22 = call i32 @pclose(i32* %21)
%23 = load i64, i64* %5
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%26 = call i64 @strlen(i8* %25)
store i64 %26, i64* %5
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%28 = load i64, i64* %5
%29 = call i32 @memcpy(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 0), i8* %27, i64 %28)
store i64 0, i64* %4
br label %30
30: ; preds = %44, %20
%31 = load i64, i64* %4
%32 = load i64, i64* %5
%33 = icmp ult i64 %31, %32
br i1 %33, label %34, label %47
34: ; preds = %30
%35 = load i64, i64* %4
%36 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 10
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = load i64, i64* %4
%42 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %41
store i8 44, i8* %42
br label %43
43: ; preds = %40, %34
br label %44
44: ; preds = %43
%45 = load i64, i64* %4
%46 = add i64 %45, 1
store i64 %46, i64* %4
br label %30
47: ; preds = %30
%48 = load i64, i64* %5
%49 = sub i64 %48, 1
%50 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %49
store i8 0, i8* %50
store i8* getelementptr inbounds ([255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 0), i8** %1
br label %51
51: ; preds = %47, %17, %11
%52 = load i8*, i8** %1
ret i8* %52
}

LLVM IR (-O2):
@get_gpu.ret = internal global [255 x i8] zeroinitializer
@.str = [144 x i8] c"system_profiler -detailLevel mini SPDisplaysDataType 2> /dev/null | grep \22Chipset Model:\22 | sed -e 's/Chipset Model://' | sed -e 's/^[ \\t ]*//'\00"
@.str.1 = [2 x i8] c"r\00"
define i8* @get_gpu() {
%1 = alloca [255 x i8]
%2 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @popen(i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %125, label %5
5: ; preds = %0
%6 = call i64 @fread(i8* %2, i32 1, i32 254, i32* %3)
%7 = icmp eq i64 %6, 0
%8 = tail call i32 @pclose(i32* %3)
br i1 %7, label %125, label %9
9: ; preds = %5
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 %6
store i8 0, i8* %10
%11 = call i64 @strlen(i8* %2)
%12 = call i32 @memcpy(i8* getelementptr inbounds ([255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 0), i8* %2, i64 %11)
%13 = icmp eq i64 %11, 0
br i1 %13, label %122, label %14
14: ; preds = %9
%15 = icmp ult i64 %11, 16
br i1 %15, label %111, label %16
16: ; preds = %14
%17 = and i64 %11, -16
br label %18
18: ; preds = %106, %16
%19 = phi i64 [ 0, %16 ], [ %107, %106 ]
%20 = or i64 %19, 8
%21 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %19
%22 = bitcast i8* %21 to <8 x i8>*
%23 = load <8 x i8>, <8 x i8>* %22
%24 = getelementptr inbounds i8, i8* %21, i64 8
%25 = bitcast i8* %24 to <8 x i8>*
%26 = load <8 x i8>, <8 x i8>* %25
%27 = icmp eq <8 x i8> %23, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%28 = icmp eq <8 x i8> %26, <i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10, i8 10>
%29 = extractelement <8 x i1> %27, i64 0
br i1 %29, label %30, label %32
30: ; preds = %18
%31 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %19
store i8 44, i8* %31
br label %32
32: ; preds = %30, %18
%33 = extractelement <8 x i1> %27, i64 1
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = or i64 %19, 1
%36 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %35
store i8 44, i8* %36
br label %37
37: ; preds = %34, %32
%38 = extractelement <8 x i1> %27, i64 2
br i1 %38, label %39, label %42
39: ; preds = %37
%40 = or i64 %19, 2
%41 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %40
store i8 44, i8* %41
br label %42
42: ; preds = %39, %37
%43 = extractelement <8 x i1> %27, i64 3
br i1 %43, label %44, label %47
44: ; preds = %42
%45 = or i64 %19, 3
%46 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %45
store i8 44, i8* %46
br label %47
47: ; preds = %44, %42
%48 = extractelement <8 x i1> %27, i64 4
br i1 %48, label %49, label %52
49: ; preds = %47
%50 = or i64 %19, 4
%51 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %50
store i8 44, i8* %51
br label %52
52: ; preds = %49, %47
%53 = extractelement <8 x i1> %27, i64 5
br i1 %53, label %54, label %57
54: ; preds = %52
%55 = or i64 %19, 5
%56 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %55
store i8 44, i8* %56
br label %57
57: ; preds = %54, %52
%58 = extractelement <8 x i1> %27, i64 6
br i1 %58, label %59, label %62
59: ; preds = %57
%60 = or i64 %19, 6
%61 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %60
store i8 44, i8* %61
br label %62
62: ; preds = %59, %57
%63 = extractelement <8 x i1> %27, i64 7
br i1 %63, label %64, label %67
64: ; preds = %62
%65 = or i64 %19, 7
%66 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %65
store i8 44, i8* %66
br label %67
67: ; preds = %64, %62
%68 = extractelement <8 x i1> %28, i64 0
br i1 %68, label %69, label %71
69: ; preds = %67
%70 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %20
store i8 44, i8* %70
br label %71
71: ; preds = %69, %67
%72 = extractelement <8 x i1> %28, i64 1
br i1 %72, label %73, label %76
73: ; preds = %71
%74 = or i64 %19, 9
%75 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %74
store i8 44, i8* %75
br label %76
76: ; preds = %73, %71
%77 = extractelement <8 x i1> %28, i64 2
br i1 %77, label %78, label %81
78: ; preds = %76
%79 = or i64 %19, 10
%80 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %79
store i8 44, i8* %80
br label %81
81: ; preds = %78, %76
%82 = extractelement <8 x i1> %28, i64 3
br i1 %82, label %83, label %86
83: ; preds = %81
%84 = or i64 %19, 11
%85 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %84
store i8 44, i8* %85
br label %86
86: ; preds = %83, %81
%87 = extractelement <8 x i1> %28, i64 4
br i1 %87, label %88, label %91
88: ; preds = %86
%89 = or i64 %19, 12
%90 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %89
store i8 44, i8* %90
br label %91
91: ; preds = %88, %86
%92 = extractelement <8 x i1> %28, i64 5
br i1 %92, label %93, label %96
93: ; preds = %91
%94 = or i64 %19, 13
%95 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %94
store i8 44, i8* %95
br label %96
96: ; preds = %93, %91
%97 = extractelement <8 x i1> %28, i64 6
br i1 %97, label %98, label %101
98: ; preds = %96
%99 = or i64 %19, 14
%100 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %99
store i8 44, i8* %100
br label %101
101: ; preds = %98, %96
%102 = extractelement <8 x i1> %28, i64 7
br i1 %102, label %103, label %106
103: ; preds = %101
%104 = or i64 %19, 15
%105 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %104
store i8 44, i8* %105
br label %106
106: ; preds = %103, %101
%107 = add nuw i64 %19, 16
%108 = icmp eq i64 %107, %17
br i1 %108, label %109, label %18
109: ; preds = %106
%110 = icmp eq i64 %11, %17
br i1 %110, label %122, label %111
111: ; preds = %14, %109
%112 = phi i64 [ 0, %14 ], [ %17, %109 ]
br label %113
113: ; preds = %111, %119
%114 = phi i64 [ %120, %119 ], [ %112, %111 ]
%115 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %114
%116 = load i8, i8* %115
%117 = icmp eq i8 %116, 10
br i1 %117, label %118, label %119
118: ; preds = %113
store i8 44, i8* %115
br label %119
119: ; preds = %113, %118
%120 = add nuw i64 %114, 1
%121 = icmp eq i64 %120, %11
br i1 %121, label %122, label %113
122: ; preds = %119, %109, %9
%123 = add i64 %11, -1
%124 = getelementptr inbounds [255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 %123
store i8 0, i8* %124
br label %125
125: ; preds = %5, %0, %122
%126 = phi i8* [ getelementptr inbounds ([255 x i8], [255 x i8]* @get_gpu.ret, i64 0, i64 0), %122 ], [ null, %0 ], [ null, %5 ]
ret i8* %126
}