#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);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
void current_session(char *filePath) {
  FILE *file = NULL;
  if ((file = fopen(filePath, "r")) == NULL) {
    perror("Error_fopen");
    exit(-1);
  }
  char buf[128];
  if (fgets(buf, 127, file) == NULL) {
    perror("Error_fgets");
    exit(-1);
  }
  buf[511] = '\0';
  printf("%s", buf);
  if (fclose(file) != 0) {
    perror("Error_fclose");
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<current_session>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11ab <current_session+0x4b>
lea    0xe66(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x7f,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    11e0 <current_session+0x80>
lea    0xe3d(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
movb   $0x0,0x16f(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     1223 <current_session+0xc3>
lea    0xe09(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<current_session>:
push   %rbx
sub    $0x80,%rsp
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11be <current_session+0x5e>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x7f,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11c7 <current_session+0x67>
movb   $0x0,0x1ff(%rsp)
lea    0xe7a(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %rax,%rax
jne    11d0 <current_session+0x70>
add    $0x80,%rsp
pop    %rbx
ret
lea    0xe3d(%rip),%rdi
jmp    11d7 <current_session+0x77>
lea    0xe40(%rip),%rdi
jmp    11d7 <current_session+0x77>
lea    0xe46(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"Error_fopen\00"
@.str.2 = [12 x i8] c"Error_fgets\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [13 x i8] c"Error_fclose\00"
define void @current_session(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [128 x i8]
store i8* %0, i8** %2
store i32* null, i32** %3
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %1
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%13 = load i32*, i32** %3
%14 = call i32* @fgets(i8* %12, i32 127, i32* %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %11
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 511
store i8 0, i8* %20
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = load i32*, i32** %3
%24 = call i64 @fclose(i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"Error_fopen\00"
@.str.2 = [12 x i8] c"Error_fgets\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [13 x i8] c"Error_fclose\00"
define void @current_session(i8* nocapture %0) {
%2 = alloca [128 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %1
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = call i32* @fgets(i8* %9, i32 127, i32* %3)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %8
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 511
store i8 0, i8* %16
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%18 = call i64 @fclose(i32* %3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %15
ret void
}