#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, scalar_t__);
char *strtok(char *, char *);
long getEncMode(char o_encMode[20]) {
  FILE *EncFilePtr = NULL;
  char EncFile[500];
  char line[300];
  strcpy(o_encMode, "");
  if (getenv("TUXADM_ENC_FILE")) {
    sprintf(EncFile, "%s", getenv("TUXADM_ENC_FILE"));
  } else {
    sprintf(EncFile, "%s/rte_tlg/etc/config/encmode.data", getenv("HOME"));
  }
  if ((EncFilePtr = fopen(EncFile, "r")) == NULL) {
    printf("WARNING: Can not open file: %s.\n", EncFile);
    printf("MESSAGE: Set encryption to OFF.\n");
    strcpy(o_encMode, "OFF");
    return 0;
  }
  while (fgets(line, 300, EncFilePtr)) {
    if (!strncmp(line, "ENCRYPTION=", strlen("ENCRYPTION="))) {
      if (strlen(line) > strlen("ENCRYPTION=") + 1) {
        strtok(line, "=");
        strcpy(o_encMode, strtok(NULL, "\n"));
        break;
      }
    }
  }
  if (!strcmp(o_encMode, "")) {
    strcpy(o_encMode, "OFF");
  }
  fclose(EncFilePtr);
  return 0;
}


x86 assembly (clang, -O0):
<getEncMode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x370,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1050 <strcpy@plt>
lea    0xe22(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1222 <getEncMode+0x72>
lea    -0x210(%rbp),%rax
mov    %rax,-0x348(%rbp)
lea    0xdfe(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x348(%rbp),%rdi
mov    %rax,%rdx
lea    0xdf8(%rip),%rsi
call   10d0 <sprintf@plt>
jmp    1252 <getEncMode+0xa2>
lea    -0x210(%rbp),%rax
mov    %rax,-0x350(%rbp)
lea    0xdff(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x350(%rbp),%rdi
mov    %rax,%rdx
lea    0xdc6(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x210(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12b3 <getEncMode+0x103>
lea    -0x210(%rbp),%rsi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1050 <strcpy@plt>
movq   $0x0,-0x8(%rbp)
jmp    13cc <getEncMode+0x21c>
jmp    12b8 <getEncMode+0x108>
lea    -0x340(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x12c,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1392 <getEncMode+0x1e2>
lea    -0x340(%rbp),%rax
mov    %rax,-0x358(%rbp)
lea    0xd97(%rip),%rdi
call   1070 <strlen@plt>
mov    -0x358(%rbp),%rdi
mov    %rax,%rdx
lea    0xd81(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    138d <getEncMode+0x1dd>
lea    -0x340(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,-0x360(%rbp)
lea    0xd59(%rip),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x360(%rbp),%rax
add    $0x1,%rcx
cmp    %rcx,%rax
jle    1388 <getEncMode+0x1d8>
lea    -0x340(%rbp),%rdi
lea    0xd39(%rip),%rsi
call   10c0 <strtok@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x368(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd0e(%rip),%rsi
call   10c0 <strtok@plt>
mov    -0x368(%rbp),%rdi
mov    %rax,%rsi
call   1050 <strcpy@plt>
jmp    1392 <getEncMode+0x1e2>
jmp    138d <getEncMode+0x1dd>
jmp    12b8 <getEncMode+0x108>
mov    -0x10(%rbp),%rdi
lea    0xce1(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    13bb <getEncMode+0x20b>
mov    -0x10(%rbp),%rdi
lea    0xcc9(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getEncMode>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x330,%rsp
mov    %rdi,%r14
lea    0xea0(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xe3a(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11e2 <getEncMode+0x42>
lea    0x130(%rsp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
jmp    1205 <getEncMode+0x65>
lea    0xe4a(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe1b(%rip),%rsi
lea    0x130(%rsp),%rdi
mov    %rax,%rdx
call   10c0 <sprintf@plt>
lea    0xe2c(%rip),%rsi
lea    0x130(%rsp),%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12de <getEncMode+0x13e>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x12c,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12bf <getEncMode+0x11f>
movabs $0x4954505952434e45,%r12
50 54 49
movabs $0x3d4e4f4954505952,%r13
4f 4e 3d
mov    %rsp,%rbx
jmp    1275 <getEncMode+0xd5>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x12c,%esi
mov    %r15,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12bf <getEncMode+0x11f>
mov    (%rsp),%rax
xor    %r12,%rax
mov    0x3(%rsp),%rcx
xor    %r13,%rcx
or     %rax,%rcx
jne    1260 <getEncMode+0xc0>
mov    %rbx,%rdi
call   1070 <strlen@plt>
cmp    $0xd,%rax
jl     1260 <getEncMode+0xc0>
lea    0xdcb(%rip),%rsi
mov    %rsp,%rdi
call   10b0 <strtok@plt>
lea    0xdac(%rip),%rsi
xor    %edi,%edi
call   10b0 <strtok@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
cmpb   $0x0,(%r14)
jne    12d4 <getEncMode+0x134>
lea    0xd8f(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
jmp    130f <getEncMode+0x16f>
lea    0xd55(%rip),%rdi
lea    0x130(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd70(%rip),%rdi
call   1050 <puts@plt>
lea    0xd54(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
xor    %eax,%eax
add    $0x330,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [16 x i8] c"TUXADM_ENC_FILE\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [35 x i8] c"%s/rte_tlg/etc/config/encmode.data\00"
@.str.4 = [5 x i8] c"HOME\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [33 x i8] c"WARNING: Can not open file: %s.\0A\00"
@.str.7 = [33 x i8] c"MESSAGE: Set encryption to OFF.\0A\00"
@.str.8 = [4 x i8] c"OFF\00"
@.str.9 = [12 x i8] c"ENCRYPTION=\00"
@.str.10 = [2 x i8] c"=\00"
@.str.11 = [2 x i8] c"\0A\00"
define i64 @getEncMode(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [500 x i8]
%6 = alloca [300 x i8]
store i8* %0, i8** %3
store i32* null, i32** %4
%7 = load i8*, i8** %3
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%13 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %19
15: ; preds = %1
%16 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%17 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %15, %11
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %21, i32** %4
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%27 = load i8*, i8** %3
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
store i64 0, i64* %2
br label %64
29: ; preds = %19
br label %30
30: ; preds = %53, %29
%31 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%32 = load i32*, i32** %4
%33 = call i64 @fgets(i8* %31, i32 300, i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %54
35: ; preds = %30
%36 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%37 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%38 = call i32 @strncmp(i8* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i64 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %53, label %40
40: ; preds = %35
%41 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%42 = call i64 @strlen(i8* %41)
%43 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%44 = add nsw i64 %43, 1
%45 = icmp sgt i64 %42, %44
br i1 %45, label %46, label %52
46: ; preds = %40
%47 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%48 = call i8* @strtok(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%49 = load i8*, i8** %3
%50 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%51 = call i32 @strcpy(i8* %49, i8* %50)
br label %54
52: ; preds = %40
br label %53
53: ; preds = %52, %35
br label %30
54: ; preds = %46, %30
%55 = load i8*, i8** %3
%56 = call i32 @strcmp(i8* %55, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%57 = icmp ne i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %54
%59 = load i8*, i8** %3
%60 = call i32 @strcpy(i8* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %61
61: ; preds = %58, %54
%62 = load i32*, i32** %4
%63 = call i32 @fclose(i32* %62)
store i64 0, i64* %2
br label %64
64: ; preds = %61, %23
%65 = load i64, i64* %2
ret i64 %65
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [16 x i8] c"TUXADM_ENC_FILE\00"
@.str.3 = [35 x i8] c"%s/rte_tlg/etc/config/encmode.data\00"
@.str.4 = [5 x i8] c"HOME\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [33 x i8] c"WARNING: Can not open file: %s.\0A\00"
@.str.8 = [4 x i8] c"OFF\00"
@.str.9 = [12 x i8] c"ENCRYPTION=\00"
@.str.10 = [2 x i8] c"=\00"
@.str.11 = [2 x i8] c"\0A\00"
@str = [32 x i8] c"MESSAGE: Set encryption to OFF.\00"
define i64 @getEncMode(i8* %0) {
%2 = alloca [500 x i8]
%3 = alloca [300 x i8]
%4 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i8* bitcast (i32 (i8*, i8*)* @strcpy to i8* (i8*, i8*)*)(i8* %4, i8* %7)
br label %14
11: ; preds = %1
%12 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %9
%15 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = call i64 @fgets(i8* %5, i32 300, i32* %15)
%19 = icmp eq i64 %18, 0
br i1 %19, label %37, label %24
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%23 = call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %44
24: ; preds = %17, %34
%25 = call i32 @bcmp(i8* dereferenceable(11) %5, i8* dereferenceable(11) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i64 11)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = call i64 @strlen(i8* %5)
%29 = icmp sgt i64 %28, 12
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%33 = call i32 @strcpy(i8* %0, i8* %32)
br label %37
34: ; preds = %27, %24
%35 = call i64 @fgets(i8* %5, i32 300, i32* %15)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %24
37: ; preds = %34, %17, %30
%38 = load i8, i8* %0
%39 = icmp eq i8 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
%43 = call i32 @fclose(i32* %15)
br label %44
44: ; preds = %42, %20
ret i64 0
}