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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *fp;
  char c;
  if ((fp = fopen("/proc/sys/crypto/fips_enabled", "r")) == NULL) {
    printf("The OS doesn't support kernel crypto module!\n");
    return (EXIT_FAILURE);
  }
  if (fread(&c, sizeof(c), 1, fp) <= 0) {
    printf("failed to read from: %s\n", "/proc/sys/crypto/fips_enabled");
    fclose(fp);
    return (EXIT_FAILURE);
  }
  printf("FIPS_MODE: %c\n", c);
  fclose(fp);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1196 <main+0x56>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    120a <main+0xca>
mov    -0x18(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
jg     11e3 <main+0xa3>
lea    0xe93(%rip),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    120a <main+0xca>
movsbl -0x19(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b0 <main+0x60>
mov    %rax,%rbx
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
test   %rax,%rax
jle    11be <main+0x6e>
movsbl 0xf(%rsp),%esi
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2e2a(%rip),%rax
jmp    11e2 <main+0x92>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
jmp    11db <main+0x8b>
lea    0xe5b(%rip),%rdi
lea    0xe34(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"/proc/sys/crypto/fips_enabled\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [46 x i8] c"The OS doesn't support kernel crypto module!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [25 x i8] c"failed to read from: %s\0A\00"
@.str.4 = [15 x i8] c"FIPS_MODE: %c\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %3
br label %29
13: ; preds = %2
%14 = load i32*, i32** %6
%15 = call i64 @fread(i8* %7, i32 1, i32 1, i32* %14)
%16 = icmp sle i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%19 = load i32*, i32** %6
%20 = call i32 @fclose(i32* %19)
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %29
22: ; preds = %13
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %6
%27 = call i32 @fclose(i32* %26)
%28 = load i32, i32* @EXIT_SUCCESS
store i32 %28, i32* %3
br label %29
29: ; preds = %22, %17, %10
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [30 x i8] c"/proc/sys/crypto/fips_enabled\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [25 x i8] c"failed to read from: %s\0A\00"
@.str.4 = [15 x i8] c"FIPS_MODE: %c\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [45 x i8] c"The OS doesn't support kernel crypto module!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %19
8: ; preds = %2
%9 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %4)
%10 = icmp slt i64 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @fclose(i32* %4)
br label %19
14: ; preds = %8
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = tail call i32 @fclose(i32* %4)
br label %19
19: ; preds = %14, %11, %6
%20 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %11 ], [ @EXIT_SUCCESS, %14 ]
%21 = load i32, i32* %20
ret i32 %21
}