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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
const char *GetOSVersion() {
  static char buffer[1024];
  FILE *os_release = fopen("/etc/os-release", "r");
  if (os_release != NULL) {
    while (fgets(buffer, sizeof(buffer), os_release)) {
      if (strncmp(buffer, "PRETTY_NAME=", 12) == 0) {
        char *pretty_name = buffer + 12;
        while (pretty_name[0] == ' ' || pretty_name[0] == '\t' ||
               pretty_name[0] == ':' || pretty_name[0] == '\'' ||
               pretty_name[0] == '\"') {
          pretty_name++;
        }
        int last = strlen(pretty_name) - 1;
        while (last >= 0 &&
               (pretty_name[last] == '\n' || pretty_name[last] == '\'' ||
                pretty_name[last] == '\"')) {
          pretty_name[last--] = '\0';
        }
        return pretty_name;
      }
    }
    fclose(os_release);
  }
  return "Linux";
}


x86 assembly (clang, -O0):
<GetOSVersion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1307 <GetOSVersion+0x1b7>
jmp    117f <GetOSVersion+0x2f>
mov    -0x10(%rbp),%rdx
lea    0x2ed6(%rip),%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12fe <GetOSVersion+0x1ae>
lea    0x2ebb(%rip),%rdi
lea    0xe66(%rip),%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12f9 <GetOSVersion+0x1a9>
lea    0x2e99(%rip),%rax
add    $0xc,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1d(%rbp)
je     1233 <GetOSVersion+0xe3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x1d(%rbp)
je     1233 <GetOSVersion+0xe3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x3a,%ecx
mov    %al,-0x1d(%rbp)
je     1233 <GetOSVersion+0xe3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x27,%ecx
mov    %al,-0x1d(%rbp)
je     1233 <GetOSVersion+0xe3>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1243 <GetOSVersion+0xf3>
jmp    1254 <GetOSVersion+0x104>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11cf <GetOSVersion+0x7f>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x1e(%rbp)
jl     12c1 <GetOSVersion+0x171>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x1f(%rbp)
je     12bb <GetOSVersion+0x16b>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x27,%ecx
mov    %al,-0x1f(%rbp)
je     12bb <GetOSVersion+0x16b>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
sete   %al
mov    %al,-0x1f(%rbp)
mov    -0x1f(%rbp),%al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    12d1 <GetOSVersion+0x181>
jmp    12ec <GetOSVersion+0x19c>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1263 <GetOSVersion+0x113>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1312 <GetOSVersion+0x1c2>
jmp    117f <GetOSVersion+0x2f>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd11(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetOSVersion>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1070 <fopen@plt>
lea    0xead(%rip),%rbx
test   %rax,%rax
je     1233 <GetOSVersion+0xe3>
mov    %rax,%r14
lea    0x2edb(%rip),%r15
lea    0xe86(%rip),%r12
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e5 <GetOSVersion+0x95>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <GetOSVersion+0x40>
lea    0x2eab(%rip),%rbx
movabs $0x400008500000200,%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%ecx
cmp    $0x3a,%rcx
ja     11ef <GetOSVersion+0x9f>
bt     %rcx,%rax
jae    11ef <GetOSVersion+0x9f>
add    $0x1,%rbx
jmp    11d0 <GetOSVersion+0x80>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    1233 <GetOSVersion+0xe3>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1233 <GetOSVersion+0xe3>
mov    %eax,%ecx
add    $0x1,%rcx
add    $0xffffffff,%eax
movabs $0x8400000400,%rdx
xchg   %ax,%ax
mov    %eax,%eax
movzbl (%rbx,%rax,1),%esi
cmp    $0x27,%rsi
ja     1233 <GetOSVersion+0xe3>
bt     %rsi,%rdx
jae    1233 <GetOSVersion+0xe3>
movb   $0x0,(%rbx,%rax,1)
add    $0xffffffffffffffff,%rcx
add    $0xffffffff,%eax
cmp    $0x1,%rcx
ja     1210 <GetOSVersion+0xc0>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@GetOSVersion.buffer = internal global [1024 x i8] zeroinitializer
@.str = [16 x i8] c"/etc/os-release\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"PRETTY_NAME=\00"
@.str.3 = [6 x i8] c"Linux\00"
define i8* @GetOSVersion() {
%1 = alloca i8*
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
%5 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %99
8: ; preds = %0
br label %9
9: ; preds = %95, %8
%10 = load i32*, i32** %2
%11 = call i64 @fgets(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @GetOSVersion.buffer, i64 0, i64 0), i32 1024, i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %96
13: ; preds = %9
%14 = call i64 @strncmp(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @GetOSVersion.buffer, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 12)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %95
16: ; preds = %13
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @GetOSVersion.buffer, i64 0, i64 12), i8** %3
br label %17
17: ; preds = %49, %16
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 32
br i1 %22, label %47, label %23
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 9
br i1 %28, label %47, label %29
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 58
br i1 %34, label %47, label %35
35: ; preds = %29
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 39
br i1 %40, label %47, label %41
41: ; preds = %35
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 0
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 34
br label %47
47: ; preds = %41, %35, %29, %23, %17
%48 = phi i1 [ true, %35 ], [ true, %29 ], [ true, %23 ], [ true, %17 ], [ %46, %41 ]
br i1 %48, label %49, label %52
49: ; preds = %47
%50 = load i8*, i8** %3
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %3
br label %17
52: ; preds = %47
%53 = load i8*, i8** %3
%54 = call i32 @strlen(i8* %53)
%55 = sub nsw i32 %54, 1
store i32 %55, i32* %4
br label %56
56: ; preds = %87, %52
%57 = load i32, i32* %4
%58 = icmp sge i32 %57, 0
br i1 %58, label %59, label %85
59: ; preds = %56
%60 = load i8*, i8** %3
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 10
br i1 %66, label %83, label %67
67: ; preds = %59
%68 = load i8*, i8** %3
%69 = load i32, i32* %4
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 39
br i1 %74, label %83, label %75
75: ; preds = %67
%76 = load i8*, i8** %3
%77 = load i32, i32* %4
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 34
br label %83
83: ; preds = %75, %67, %59
%84 = phi i1 [ true, %67 ], [ true, %59 ], [ %82, %75 ]
br label %85
85: ; preds = %83, %56
%86 = phi i1 [ false, %56 ], [ %84, %83 ]
br i1 %86, label %87, label %93
87: ; preds = %85
%88 = load i8*, i8** %3
%89 = load i32, i32* %4
%90 = add nsw i32 %89, -1
store i32 %90, i32* %4
%91 = sext i32 %89 to i64
%92 = getelementptr inbounds i8, i8* %88, i64 %91
store i8 0, i8* %92
br label %56
93: ; preds = %85
%94 = load i8*, i8** %3
store i8* %94, i8** %1
br label %100
95: ; preds = %13
br label %9
96: ; preds = %9
%97 = load i32*, i32** %2
%98 = call i32 @fclose(i32* %97)
br label %99
99: ; preds = %96, %0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %100
100: ; preds = %99, %93
%101 = load i8*, i8** %1
ret i8* %101
}

LLVM IR (-O2):
@GetOSVersion.buffer = internal global [1024 x i8] zeroinitializer
@.str = [16 x i8] c"/etc/os-release\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"PRETTY_NAME=\00"
@.str.3 = [6 x i8] c"Linux\00"
define i8* @GetOSVersion() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %29, label %3
3: ; preds = %0, %6
%4 = tail call i64 @fgets(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @GetOSVersion.buffer, i64 0, i64 0), i32 1024, i32* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %27, label %6
6: ; preds = %3
%7 = tail call i64 @strncmp(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @GetOSVersion.buffer, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 12)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %3
9: ; preds = %6, %12
%10 = phi i8* [ %13, %12 ], [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @GetOSVersion.buffer, i64 0, i64 12), %6 ]
%11 = load i8, i8* %10
switch i8 %11, label %14 [
i8 32, label %12
i8 9, label %12
i8 58, label %12
i8 39, label %12
i8 34, label %12
]
12: ; preds = %9, %9, %9, %9, %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
br label %9
14: ; preds = %9
%15 = tail call i32 @strlen(i8* %10)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = zext i32 %15 to i64
br label %19
19: ; preds = %17, %25
%20 = phi i64 [ %18, %17 ], [ %21, %25 ]
%21 = add nsw i64 %20, -1
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds i8, i8* %10, i64 %22
%24 = load i8, i8* %23
switch i8 %24, label %29 [
i8 10, label %25
i8 39, label %25
i8 34, label %25
]
25: ; preds = %19, %19, %19
store i8 0, i8* %23
%26 = icmp ugt i64 %20, 1
br i1 %26, label %19, label %29
27: ; preds = %3
%28 = tail call i32 @fclose(i32* %1)
br label %29
29: ; preds = %19, %25, %14, %0, %27
%30 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %27 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %0 ], [ %10, %14 ], [ %10, %25 ], [ %10, %19 ]
ret i8* %30
}