#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int strcspn(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ strstr(char *, char *);
int strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
void checkk8(void) {
  char *line = NULL;
  size_t size = 0;
  int bad = 0;
  FILE *f = fopen("/proc/cpuinfo", "r");
  if (!f)
    return;
  while (getline(&line, &size, f) > 0) {
    if (!strncmp("vendor_id", line, 9)) {
      if (!strstr(line, "AMD"))
        bad++;
    }
    if (!strncmp("cpu family", line, 10)) {
      char *s = line + strcspn(line, ":");
      int family;
      if (*s == ':')
        ++s;
      family = strtoul(s, NULL, 0);
      if (family != 15)
        bad++;
    }
  }
  if (bad) {
    printf("not a opteron cpu\n");
    exit(1);
  }
  free(line);
  fclose(f);
}


x86 assembly (clang, -O0):
<checkk8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe3a(%rip),%rdi
lea    0xe41(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e6 <checkk8+0x46>
jmp    130e <checkk8+0x16e>
jmp    11eb <checkk8+0x4b>
mov    -0x20(%rbp),%rdx
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   10a0 <getline@plt>
cmp    $0x0,%rax
jle    12dc <checkk8+0x13c>
mov    -0x8(%rbp),%rsi
lea    0xdff(%rip),%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    124b <checkk8+0xab>
mov    -0x8(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%eax
jne    1246 <checkk8+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    124b <checkk8+0xab>
mov    -0x8(%rbp),%rsi
lea    0xdc8(%rip),%rdi
mov    $0xa,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    12d7 <checkk8+0x137>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1070 <strcspn@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    12ad <checkk8+0x10d>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <strtoul@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xf,-0x2c(%rbp)
je     12d2 <checkk8+0x132>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12d7 <checkk8+0x137>
jmp    11eb <checkk8+0x4b>
cmpl   $0x0,-0x14(%rbp)
je     12fc <checkk8+0x15c>
lea    0xd3e(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkk8>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe3a(%rip),%rdi
lea    0xe41(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12eb <checkk8+0x14b>
mov    %rax,%r12
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   10a0 <getline@plt>
test   %rax,%rax
jle    12da <checkk8+0x13a>
xor    %r14d,%r14d
lea    0xe0f(%rip),%rbp
lea    0xe16(%rip),%rbx
mov    %rsp,%r13
lea    0x8(%rsp),%r15
jmp    1237 <checkk8+0x97>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   10a0 <getline@plt>
test   %rax,%rax
jle    12d5 <checkk8+0x135>
mov    (%rsp),%rsi
mov    %rbp,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1263 <checkk8+0xc3>
mov    (%rsp),%rdi
lea    0xdc3(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x1,%eax
adc    $0x0,%r14d
mov    (%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1220 <checkk8+0x80>
mov    %r14,0x10(%rsp)
mov    %r12,%r14
mov    %r15,%r12
mov    %r13,%r15
mov    (%rsp),%r13
mov    %r13,%rdi
lea    0xd95(%rip),%rsi
call   1070 <strcspn@plt>
cltq
lea    (%rax,%r13,1),%rcx
xor    %edi,%edi
cmpb   $0x3a,0x0(%r13,%rax,1)
mov    %r15,%r13
mov    %r12,%r15
mov    %r14,%r12
mov    0x10(%rsp),%r14
sete   %dil
add    %rcx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtoul@plt>
xor    %ecx,%ecx
cmp    $0xf,%eax
setne  %cl
add    %ecx,%r14d
jmp    1220 <checkk8+0x80>
test   %r14d,%r14d
jne    12fa <checkk8+0x15a>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd2a(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"vendor_id\00"
@.str.3 = [4 x i8] c"AMD\00"
@.str.4 = [11 x i8] c"cpu family\00"
@.str.5 = [2 x i8] c":\00"
@.str.6 = [19 x i8] c"not a opteron cpu\0A\00"
define void @checkk8() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i8* null, i8** %1
store i64 0, i64* %2
store i32 0, i32* %3
%7 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %0
br label %66
11: ; preds = %0
br label %12
12: ; preds = %54, %11
%13 = load i32*, i32** %4
%14 = call i64 @getline(i8** %1, i64* %2, i32* %13)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %55
16: ; preds = %12
%17 = load i8*, i8** %1
%18 = call i32 @strncmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %17, i32 9)
%19 = icmp ne i32 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %16
%21 = load i8*, i8** %1
%22 = call i32 @strstr(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %20
br label %28
28: ; preds = %27, %16
%29 = load i8*, i8** %1
%30 = call i32 @strncmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %29, i32 10)
%31 = icmp ne i32 %30, 0
br i1 %31, label %54, label %32
32: ; preds = %28
%33 = load i8*, i8** %1
%34 = load i8*, i8** %1
%35 = call i32 @strcspn(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
store i8* %37, i8** %5
%38 = load i8*, i8** %5
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 58
br i1 %41, label %42, label %45
42: ; preds = %32
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %5
br label %45
45: ; preds = %42, %32
%46 = load i8*, i8** %5
%47 = call i32 @strtoul(i8* %46, i32* null, i32 0)
store i32 %47, i32* %6
%48 = load i32, i32* %6
%49 = icmp ne i32 %48, 15
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %53
53: ; preds = %50, %45
br label %54
54: ; preds = %53, %28
br label %12
55: ; preds = %12
%56 = load i32, i32* %3
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %55
%62 = load i8*, i8** %1
%63 = call i32 @free(i8* %62)
%64 = load i32*, i32** %4
%65 = call i32 @fclose(i32* %64)
br label %66
66: ; preds = %61, %10
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/cpuinfo\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"vendor_id\00"
@.str.3 = [4 x i8] c"AMD\00"
@.str.4 = [11 x i8] c"cpu family\00"
@.str.5 = [2 x i8] c":\00"
@str = [18 x i8] c"not a opteron cpu\00"
define void @checkk8() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %52, label %7
7: ; preds = %0
%8 = call i64 @getline(i8** %1, i64* %2, i32* %5)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %48
10: ; preds = %7, %39
%11 = phi i32 [ %40, %39 ], [ 0, %7 ]
%12 = load i8*, i8** %1
%13 = call i32 @strncmp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %12, i32 9)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i8*, i8** %1
%17 = call i32 @strstr(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = add nsw i32 %11, %19
br label %21
21: ; preds = %15, %10
%22 = phi i32 [ %11, %10 ], [ %20, %15 ]
%23 = load i8*, i8** %1
%24 = call i32 @strncmp(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %23, i32 10)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %21
%27 = load i8*, i8** %1
%28 = call i32 @strcspn(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 58
%33 = zext i1 %32 to i64
%34 = getelementptr i8, i8* %30, i64 %33
%35 = call i32 @strtoul(i8* nocapture %34, i32* null, i32 0)
%36 = icmp ne i32 %35, 15
%37 = zext i1 %36 to i32
%38 = add nsw i32 %22, %37
br label %39
39: ; preds = %26, %21
%40 = phi i32 [ %22, %21 ], [ %38, %26 ]
%41 = call i64 @getline(i8** %1, i64* %2, i32* %5)
%42 = icmp sgt i64 %41, 0
br i1 %42, label %10, label %43
43: ; preds = %39
%44 = icmp eq i32 %40, 0
br i1 %44, label %48, label %45
45: ; preds = %43
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %7, %43
%49 = load i8*, i8** %1
%50 = call i32 @free(i8* %49)
%51 = call i32 @fclose(i32* %5)
br label %52
52: ; preds = %0, %48
ret void
}