#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 */
struct js_event {
  int type;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int JS_EVENT_INIT;
int atoi(char *);
int /*<<< orphan*/ ewc(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int read(int, struct js_event *, int);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
void read_configuration(int joyfd, struct js_event *joystick, char jsbuttons,
                        char jsaxes, char *jsname, char *confile, char *buttons,
                        char *axes, char *reversed) {
  char tempLine[4];
  FILE *conFile;
  if ((conFile = fopen(confile, "r")) == NULL)
    ewc(EXIT_FAILURE, "Unable to open the configuration file.");
  fprintf(stdout, "%s\n", "Press any button on the joystick to begin...");
  int temp_stat;
  while ((temp_stat = read(joyfd, joystick, sizeof(struct js_event))) >= 0 &&
         (joystick->type & JS_EVENT_INIT) != 0)
    ;
  if (temp_stat < 0)
    ewc(EXIT_FAILURE, "Error while reading from the joystick.");
  if (read(joyfd, joystick, sizeof(struct js_event)) < 0)
    ewc(EXIT_FAILURE, "Error while reading from the joystick.");
  fprintf(stdout, "%s\n", "Reading configuration...");
  char file_jsname[1024];
  if (fgets(file_jsname, 1024, conFile) == NULL)
    ewc(EXIT_FAILURE, "Unexpected EOF. Is it an appropriate configuration "
                      "file? I am expecting a joystick's name here.");
  if (file_jsname[strlen(file_jsname) - 1] == '\n')
    file_jsname[strlen(file_jsname) - 1] = '\0';
  if (strcmp(jsname, file_jsname) != 0)
    ewc(EXIT_FAILURE,
        "Error: This configuration file wasn't made for that joystick.");
  short it;
  for (it = 0; it < jsbuttons; ++it) {
    if (fgets(tempLine, 4, conFile) == NULL)
      ewc(EXIT_FAILURE, "Unexpected EOF. Is it an appropriate configuration "
                        "file? I am expecting a button code number here.");
    if (atoi(tempLine) < -1 || atoi(tempLine) > 99)
      ewc(EXIT_FAILURE, "Inappropriate configuration file!");
    else
      buttons[it] = atoi(tempLine);
  }
  for (it = 0; it < jsaxes; ++it) {
    if (fgets(tempLine, 4, conFile) == NULL)
      ewc(EXIT_FAILURE, "Unexpected EOF. Is it an appropriate configuration "
                        "file? I am expecting an axis code number here.");
    if (atoi(tempLine) < -1 || atoi(tempLine) > 99)
      ewc(EXIT_FAILURE, "Inappropriate configuration file!");
    else
      axes[it] = atoi(tempLine);
  }
  for (it = 0; it < jsaxes; ++it) {
    if (fgets(tempLine, 4, conFile) == NULL)
      ewc(EXIT_FAILURE,
          "Unexpected EOF. Is it an appropriate configuration file? I am "
          "expecting an axis reversal information here.");
    if (atoi(tempLine) != -1 && atoi(tempLine) != 1)
      ewc(EXIT_FAILURE,
          "Inappropriate configuration file! Expecting either -1 or 1 here.");
    else
      reversed[it] = atoi(tempLine);
  }
  fprintf(stdout, "%s\n", "Configuration read successfully.");
  fclose(conFile);
}


x86 assembly (clang, -O0):
<read_configuration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    0x20(%rbp),%rdx
mov    0x18(%rbp),%rdx
mov    0x10(%rbp),%rdx
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %al,-0x12(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11f3 <read_configuration+0x63>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
call   1090 <ewc@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
lea    0xe23(%rip),%rdx
call   1080 <fprintf@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1050 <read@plt>
mov    %eax,%ecx
mov    %ecx,-0x3c(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x443(%rbp)
jl     1251 <read_configuration+0xc1>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2d95(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x443(%rbp)
mov    -0x443(%rbp),%al
test   $0x1,%al
jne    1264 <read_configuration+0xd4>
jmp    1269 <read_configuration+0xd9>
jmp    120f <read_configuration+0x7f>
cmpl   $0x0,-0x3c(%rbp)
jge    1288 <read_configuration+0xf8>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
call   1090 <ewc@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1050 <read@plt>
cmp    $0x0,%eax
jge    12b7 <read_configuration+0x127>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
call   1090 <ewc@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
lea    0xdb3(%rip),%rdx
call   1080 <fprintf@plt>
lea    -0x440(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1307 <read_configuration+0x177>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
call   1090 <ewc@plt>
lea    -0x440(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x440(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1342 <read_configuration+0x1b2>
lea    -0x440(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x440(%rbp,%rax,1)
mov    -0x20(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1371 <read_configuration+0x1e1>
mov    0x2c7d(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
call   1090 <ewc@plt>
movw   $0x0,-0x442(%rbp)
movswl -0x442(%rbp),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jge    1432 <read_configuration+0x2a2>
lea    -0x2c(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x4,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    13be <read_configuration+0x22e>
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
call   1090 <ewc@plt>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
cmp    $0xffffffff,%eax
jl     13e2 <read_configuration+0x252>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
cmp    $0x63,%eax
jle    13fc <read_configuration+0x26c>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
lea    0xda9(%rip),%rsi
call   1090 <ewc@plt>
jmp    1416 <read_configuration+0x286>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %al,%dl
mov    0x10(%rbp),%rax
movswq -0x442(%rbp),%rcx
ff
mov    %dl,(%rax,%rcx,1)
jmp    141b <read_configuration+0x28b>
mov    -0x442(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x442(%rbp)
jmp    137a <read_configuration+0x1ea>
movw   $0x0,-0x442(%rbp)
movswl -0x442(%rbp),%eax
movsbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    14f3 <read_configuration+0x363>
lea    -0x2c(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x4,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    147f <read_configuration+0x2ef>
mov    0x2b6f(%rip),%rax
mov    (%rax),%edi
lea    0xd43(%rip),%rsi
call   1090 <ewc@plt>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
cmp    $0xffffffff,%eax
jl     14a3 <read_configuration+0x313>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
cmp    $0x63,%eax
jle    14bd <read_configuration+0x32d>
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
call   1090 <ewc@plt>
jmp    14d7 <read_configuration+0x347>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %al,%dl
mov    0x18(%rbp),%rax
movswq -0x442(%rbp),%rcx
ff
mov    %dl,(%rax,%rcx,1)
jmp    14dc <read_configuration+0x34c>
mov    -0x442(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x442(%rbp)
jmp    143b <read_configuration+0x2ab>
movw   $0x0,-0x442(%rbp)
movswl -0x442(%rbp),%eax
movsbl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    15b4 <read_configuration+0x424>
lea    -0x2c(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x4,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1540 <read_configuration+0x3b0>
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
call   1090 <ewc@plt>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
cmp    $0xffffffff,%eax
je     157e <read_configuration+0x3ee>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
cmp    $0x1,%eax
je     157e <read_configuration+0x3ee>
mov    0x2a75(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
call   1090 <ewc@plt>
jmp    1598 <read_configuration+0x408>
lea    -0x2c(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %al,%dl
mov    0x20(%rbp),%rax
movswq -0x442(%rbp),%rcx
ff
mov    %dl,(%rax,%rcx,1)
jmp    159d <read_configuration+0x40d>
mov    -0x442(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x442(%rbp)
jmp    14fc <read_configuration+0x36c>
mov    0x2a15(%rip),%rax
mov    (%rax),%edi
lea    0xa65(%rip),%rsi
lea    0xd00(%rip),%rdx
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_configuration>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %r8,0x8(%rsp)
mov    %ecx,(%rsp)
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xe48(%rip),%rsi
mov    %r9,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
jne    11dd <read_configuration+0x4d>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
call   1090 <ewc@plt>
mov    0x2dec(%rip),%r12
mov    (%r12),%edi
lea    0xe3a(%rip),%rsi
lea    0xe37(%rip),%rdx
call   1080 <fprintf@plt>
mov    0x2dd6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
test   %eax,%eax
js     122d <read_configuration+0x9d>
mov    (%r14),%eax
test   %eax,0x0(%rbp)
jne    1210 <read_configuration+0x80>
jmp    1242 <read_configuration+0xb2>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
call   1090 <ewc@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
test   %eax,%eax
jns    126a <read_configuration+0xda>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
call   1090 <ewc@plt>
mov    (%r12),%edi
lea    0xdb4(%rip),%rsi
lea    0xe05(%rip),%rdx
call   1080 <fprintf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    12b0 <read_configuration+0x120>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    0xdef(%rip),%rsi
call   1090 <ewc@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    12d0 <read_configuration+0x140>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12f9 <read_configuration+0x169>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1090 <ewc@plt>
test   %r15b,%r15b
jle    1376 <read_configuration+0x1e6>
movzbl %r15b,%ebp
xor    %r12d,%r12d
lea    0x4(%rsp),%rbx
mov    0x2ccf(%rip),%r15
lea    0xe83(%rip),%r14
jmp    1335 <read_configuration+0x1a5>
nopw   0x0(%rax,%rax,1)
mov    0x450(%rsp),%rcx
mov    %al,(%rcx,%r12,1)
add    $0x1,%r12
cmp    %r12,%rbp
je     1376 <read_configuration+0x1e6>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1359 <read_configuration+0x1c9>
mov    (%r15),%edi
lea    0xde4(%rip),%rsi
call   1090 <ewc@plt>
mov    %rbx,%rdi
call   10b0 <atoi@plt>
lea    -0x64(%rax),%ecx
cmp    $0xffffff9a,%ecx
ja     1320 <read_configuration+0x190>
mov    (%r15),%edi
mov    %r14,%rsi
call   1090 <ewc@plt>
jmp    132c <read_configuration+0x19c>
mov    (%rsp),%eax
test   %al,%al
jle    1468 <read_configuration+0x2d8>
movsbl %al,%eax
movzwl %ax,%ebp
xor    %r15d,%r15d
lea    0x4(%rsp),%rbx
mov    0x2c4a(%rip),%r14
lea    0xdfe(%rip),%r12
jmp    13b5 <read_configuration+0x225>
nop
mov    0x458(%rsp),%rcx
mov    %al,(%rcx,%r15,1)
add    $0x1,%r15
cmp    %r15,%rbp
je     13f6 <read_configuration+0x266>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    13d9 <read_configuration+0x249>
mov    (%r14),%edi
lea    0xde9(%rip),%rsi
call   1090 <ewc@plt>
mov    %rbx,%rdi
call   10b0 <atoi@plt>
lea    -0x64(%rax),%ecx
cmp    $0xffffff9a,%ecx
ja     13a0 <read_configuration+0x210>
mov    (%r14),%edi
mov    %r12,%rsi
call   1090 <ewc@plt>
jmp    13ac <read_configuration+0x21c>
cmpb   $0x0,(%rsp)
jle    1468 <read_configuration+0x2d8>
xor    %r12d,%r12d
lea    0x4(%rsp),%rbx
lea    0xe14(%rip),%r15
jmp    1425 <read_configuration+0x295>
nopl   (%rax)
mov    0x460(%rsp),%rcx
mov    %al,(%rcx,%r12,1)
add    $0x1,%r12
cmp    %r12,%rbp
je     1468 <read_configuration+0x2d8>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    1445 <read_configuration+0x2b5>
mov    (%r14),%edi
mov    %r15,%rsi
call   1090 <ewc@plt>
mov    %rbx,%rdi
call   10b0 <atoi@plt>
cmp    $0xffffffff,%eax
je     1410 <read_configuration+0x280>
cmp    $0x1,%eax
je     1410 <read_configuration+0x280>
mov    (%r14),%edi
lea    0xe29(%rip),%rsi
call   1090 <ewc@plt>
jmp    141c <read_configuration+0x28c>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
lea    0xbb1(%rip),%rsi
lea    0xe4c(%rip),%rdx
call   1080 <fprintf@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.js_event = type { i32 }
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [39 x i8] c"Unable to open the configuration file.\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [45 x i8] c"Press any button on the joystick to begin...\00"
@JS_EVENT_INIT = global i32 0
@.str.4 = [39 x i8] c"Error while reading from the joystick.\00"
@.str.5 = [25 x i8] c"Reading configuration...\00"
@.str.6 = [96 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting a joystick's name here.\00"
@.str.7 = [62 x i8] c"Error: This configuration file wasn't made for that joystick.\00"
@.str.8 = [99 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting a button code number here.\00"
@.str.9 = [34 x i8] c"Inappropriate configuration file!\00"
@.str.10 = [98 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting an axis code number here.\00"
@.str.11 = [107 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting an axis reversal information here.\00"
@.str.12 = [65 x i8] c"Inappropriate configuration file! Expecting either -1 or 1 here.\00"
@.str.13 = [33 x i8] c"Configuration read successfully.\00"
define void @read_configuration(i32 %0, %struct.js_event* %1, i8 signext %2, i8 signext %3, i8* %4, i8* %5, i8* %6, i8* %7, i8* %8) {
%10 = alloca i32
%11 = alloca %struct.js_event*
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca [4 x i8]
%20 = alloca i32*
%21 = alloca i32
%22 = alloca [1024 x i8]
%23 = alloca i16
store i32 %0, i32* %10
store %struct.js_event* %1, %struct.js_event** %11
store i8 %2, i8* %12
store i8 %3, i8* %13
store i8* %4, i8** %14
store i8* %5, i8** %15
store i8* %6, i8** %16
store i8* %7, i8** %17
store i8* %8, i8** %18
%24 = load i8*, i8** %15
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %20
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %30
27: ; preds = %9
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @ewc(i32 %28, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %27, %9
%31 = load i32, i32* @stdout
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %47, %30
%34 = load i32, i32* %10
%35 = load %struct.js_event*, %struct.js_event** %11
%36 = call i32 @read(i32 %34, %struct.js_event* %35, i32 4)
store i32 %36, i32* %21
%37 = icmp sge i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %33
%39 = load %struct.js_event*, %struct.js_event** %11
%40 = getelementptr inbounds %struct.js_event, %struct.js_event* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = load i32, i32* @JS_EVENT_INIT
%43 = and i32 %41, %42
%44 = icmp ne i32 %43, 0
br label %45
45: ; preds = %38, %33
%46 = phi i1 [ false, %33 ], [ %44, %38 ]
br i1 %46, label %47, label %48
47: ; preds = %45
br label %33
48: ; preds = %45
%49 = load i32, i32* %21
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @ewc(i32 %52, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %51, %48
%55 = load i32, i32* %10
%56 = load %struct.js_event*, %struct.js_event** %11
%57 = call i32 @read(i32 %55, %struct.js_event* %56, i32 4)
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @ewc(i32 %60, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %59, %54
%63 = load i32, i32* @stdout
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 0
%66 = load i32*, i32** %20
%67 = call i32* @fgets(i8* %65, i32 1024, i32* %66)
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %72
69: ; preds = %62
%70 = load i32, i32* @EXIT_FAILURE
%71 = call i32 @ewc(i32 %70, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.6, i64 0, i64 0))
br label %72
72: ; preds = %69, %62
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 0
%74 = call i32 @strlen(i8* %73)
%75 = sub nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 10
br i1 %80, label %81, label %87
81: ; preds = %72
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 0
%83 = call i32 @strlen(i8* %82)
%84 = sub nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 %85
store i8 0, i8* %86
br label %87
87: ; preds = %81, %72
%88 = load i8*, i8** %14
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 0, i64 0
%90 = call i64 @strcmp(i8* %88, i8* %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %87
%93 = load i32, i32* @EXIT_FAILURE
%94 = call i32 @ewc(i32 %93, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0))
br label %95
95: ; preds = %92, %87
store i16 0, i16* %23
br label %96
96: ; preds = %130, %95
%97 = load i16, i16* %23
%98 = sext i16 %97 to i32
%99 = load i8, i8* %12
%100 = sext i8 %99 to i32
%101 = icmp slt i32 %98, %100
br i1 %101, label %102, label %133
102: ; preds = %96
%103 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%104 = load i32*, i32** %20
%105 = call i32* @fgets(i8* %103, i32 4, i32* %104)
%106 = icmp eq i32* %105, null
br i1 %106, label %107, label %110
107: ; preds = %102
%108 = load i32, i32* @EXIT_FAILURE
%109 = call i32 @ewc(i32 %108, i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.8, i64 0, i64 0))
br label %110
110: ; preds = %107, %102
%111 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%112 = call i32 @atoi(i8* %111)
%113 = icmp slt i32 %112, -1
br i1 %113, label %118, label %114
114: ; preds = %110
%115 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%116 = call i32 @atoi(i8* %115)
%117 = icmp sgt i32 %116, 99
br i1 %117, label %118, label %121
118: ; preds = %114, %110
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @ewc(i32 %119, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %129
121: ; preds = %114
%122 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%123 = call i32 @atoi(i8* %122)
%124 = trunc i32 %123 to i8
%125 = load i8*, i8** %16
%126 = load i16, i16* %23
%127 = sext i16 %126 to i64
%128 = getelementptr inbounds i8, i8* %125, i64 %127
store i8 %124, i8* %128
br label %129
129: ; preds = %121, %118
br label %130
130: ; preds = %129
%131 = load i16, i16* %23
%132 = add i16 %131, 1
store i16 %132, i16* %23
br label %96
133: ; preds = %96
store i16 0, i16* %23
br label %134
134: ; preds = %168, %133
%135 = load i16, i16* %23
%136 = sext i16 %135 to i32
%137 = load i8, i8* %13
%138 = sext i8 %137 to i32
%139 = icmp slt i32 %136, %138
br i1 %139, label %140, label %171
140: ; preds = %134
%141 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%142 = load i32*, i32** %20
%143 = call i32* @fgets(i8* %141, i32 4, i32* %142)
%144 = icmp eq i32* %143, null
br i1 %144, label %145, label %148
145: ; preds = %140
%146 = load i32, i32* @EXIT_FAILURE
%147 = call i32 @ewc(i32 %146, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.10, i64 0, i64 0))
br label %148
148: ; preds = %145, %140
%149 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%150 = call i32 @atoi(i8* %149)
%151 = icmp slt i32 %150, -1
br i1 %151, label %156, label %152
152: ; preds = %148
%153 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%154 = call i32 @atoi(i8* %153)
%155 = icmp sgt i32 %154, 99
br i1 %155, label %156, label %159
156: ; preds = %152, %148
%157 = load i32, i32* @EXIT_FAILURE
%158 = call i32 @ewc(i32 %157, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %167
159: ; preds = %152
%160 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%161 = call i32 @atoi(i8* %160)
%162 = trunc i32 %161 to i8
%163 = load i8*, i8** %17
%164 = load i16, i16* %23
%165 = sext i16 %164 to i64
%166 = getelementptr inbounds i8, i8* %163, i64 %165
store i8 %162, i8* %166
br label %167
167: ; preds = %159, %156
br label %168
168: ; preds = %167
%169 = load i16, i16* %23
%170 = add i16 %169, 1
store i16 %170, i16* %23
br label %134
171: ; preds = %134
store i16 0, i16* %23
br label %172
172: ; preds = %206, %171
%173 = load i16, i16* %23
%174 = sext i16 %173 to i32
%175 = load i8, i8* %13
%176 = sext i8 %175 to i32
%177 = icmp slt i32 %174, %176
br i1 %177, label %178, label %209
178: ; preds = %172
%179 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%180 = load i32*, i32** %20
%181 = call i32* @fgets(i8* %179, i32 4, i32* %180)
%182 = icmp eq i32* %181, null
br i1 %182, label %183, label %186
183: ; preds = %178
%184 = load i32, i32* @EXIT_FAILURE
%185 = call i32 @ewc(i32 %184, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.11, i64 0, i64 0))
br label %186
186: ; preds = %183, %178
%187 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%188 = call i32 @atoi(i8* %187)
%189 = icmp ne i32 %188, -1
br i1 %189, label %190, label %197
190: ; preds = %186
%191 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%192 = call i32 @atoi(i8* %191)
%193 = icmp ne i32 %192, 1
br i1 %193, label %194, label %197
194: ; preds = %190
%195 = load i32, i32* @EXIT_FAILURE
%196 = call i32 @ewc(i32 %195, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
br label %205
197: ; preds = %190, %186
%198 = getelementptr inbounds [4 x i8], [4 x i8]* %19, i64 0, i64 0
%199 = call i32 @atoi(i8* %198)
%200 = trunc i32 %199 to i8
%201 = load i8*, i8** %18
%202 = load i16, i16* %23
%203 = sext i16 %202 to i64
%204 = getelementptr inbounds i8, i8* %201, i64 %203
store i8 %200, i8* %204
br label %205
205: ; preds = %197, %194
br label %206
206: ; preds = %205
%207 = load i16, i16* %23
%208 = add i16 %207, 1
store i16 %208, i16* %23
br label %172
209: ; preds = %172
%210 = load i32, i32* @stdout
%211 = call i32 @fprintf(i32 %210, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0))
%212 = load i32*, i32** %20
%213 = call i32 @fclose(i32* %212)
ret void
}

LLVM IR (-O2):
%struct.js_event = type { i32 }
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [39 x i8] c"Unable to open the configuration file.\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [45 x i8] c"Press any button on the joystick to begin...\00"
@JS_EVENT_INIT = global i32 0
@.str.4 = [39 x i8] c"Error while reading from the joystick.\00"
@.str.5 = [25 x i8] c"Reading configuration...\00"
@.str.6 = [96 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting a joystick's name here.\00"
@.str.7 = [62 x i8] c"Error: This configuration file wasn't made for that joystick.\00"
@.str.8 = [99 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting a button code number here.\00"
@.str.9 = [34 x i8] c"Inappropriate configuration file!\00"
@.str.10 = [98 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting an axis code number here.\00"
@.str.11 = [107 x i8] c"Unexpected EOF. Is it an appropriate configuration file? I am expecting an axis reversal information here.\00"
@.str.12 = [65 x i8] c"Inappropriate configuration file! Expecting either -1 or 1 here.\00"
@.str.13 = [33 x i8] c"Configuration read successfully.\00"
define void @read_configuration(i32 %0, %struct.js_event* nocapture %1, i8 signext %2, i8 signext %3, i8* %4, i8* nocapture %5, i8* nocapture writeonly %6, i8* nocapture writeonly %7, i8* nocapture writeonly %8) {
%10 = alloca [4 x i8]
%11 = alloca [1024 x i8]
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%13 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @ewc(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %9
%19 = load i32, i32* @stdout
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%21 = getelementptr inbounds %struct.js_event, %struct.js_event* %1, i64 0, i32 0
br label %22
22: ; preds = %25, %18
%23 = tail call i32 @read(i32 %0, %struct.js_event* %1, i32 4)
%24 = icmp sgt i32 %23, -1
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* %21
%27 = load i32, i32* @JS_EVENT_INIT
%28 = and i32 %27, %26
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %22
30: ; preds = %22
%31 = load i32, i32* @EXIT_FAILURE
%32 = tail call i32 @ewc(i32 %31, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %25, %30
%34 = tail call i32 @read(i32 %0, %struct.js_event* %1, i32 4)
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* @EXIT_FAILURE
%38 = tail call i32 @ewc(i32 %37, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* @stdout
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%43 = call i32* @fgets(i8* %42, i32 1024, i32* %13)
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @ewc(i32 %46, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str.6, i64 0, i64 0))
br label %48
48: ; preds = %45, %39
%49 = call i32 @strlen(i8* %42)
%50 = add nsw i32 %49, -1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 10
br i1 %54, label %55, label %60
55: ; preds = %48
%56 = call i32 @strlen(i8* %42)
%57 = add nsw i32 %56, -1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %58
store i8 0, i8* %59
br label %60
60: ; preds = %55, %48
%61 = call i64 @strcmp(i8* %4, i8* %42)
%62 = icmp eq i64 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %60
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @ewc(i32 %64, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0))
br label %66
66: ; preds = %63, %60
%67 = icmp sgt i8 %2, 0
br i1 %67, label %68, label %70
68: ; preds = %66
%69 = zext i8 %2 to i64
br label %75
70: ; preds = %92, %66
%71 = sext i8 %3 to i16
%72 = icmp sgt i8 %3, 0
br i1 %72, label %73, label %136
73: ; preds = %70
%74 = zext i16 %71 to i64
br label %98
75: ; preds = %68, %92
%76 = phi i64 [ 0, %68 ], [ %93, %92 ]
%77 = call i32* @fgets(i8* %12, i32 4, i32* %13)
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @ewc(i32 %80, i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.8, i64 0, i64 0))
br label %82
82: ; preds = %79, %75
%83 = call i32 @atoi(i8* %12)
%84 = add i32 %83, -100
%85 = icmp ult i32 %84, -101
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = load i32, i32* @EXIT_FAILURE
%88 = call i32 @ewc(i32 %87, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %92
89: ; preds = %82
%90 = trunc i32 %83 to i8
%91 = getelementptr inbounds i8, i8* %6, i64 %76
store i8 %90, i8* %91
br label %92
92: ; preds = %86, %89
%93 = add nuw nsw i64 %76, 1
%94 = icmp eq i64 %93, %69
br i1 %94, label %70, label %75
95: ; preds = %115
br i1 %72, label %96, label %136
96: ; preds = %95
%97 = zext i16 %71 to i64
br label %118
98: ; preds = %73, %115
%99 = phi i64 [ 0, %73 ], [ %116, %115 ]
%100 = call i32* @fgets(i8* %12, i32 4, i32* %13)
%101 = icmp eq i32* %100, null
br i1 %101, label %102, label %105
102: ; preds = %98
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 @ewc(i32 %103, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.10, i64 0, i64 0))
br label %105
105: ; preds = %102, %98
%106 = call i32 @atoi(i8* %12)
%107 = add i32 %106, -100
%108 = icmp ult i32 %107, -101
br i1 %108, label %109, label %112
109: ; preds = %105
%110 = load i32, i32* @EXIT_FAILURE
%111 = call i32 @ewc(i32 %110, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %115
112: ; preds = %105
%113 = trunc i32 %106 to i8
%114 = getelementptr inbounds i8, i8* %7, i64 %99
store i8 %113, i8* %114
br label %115
115: ; preds = %109, %112
%116 = add nuw nsw i64 %99, 1
%117 = icmp eq i64 %116, %74
br i1 %117, label %95, label %98
118: ; preds = %96, %133
%119 = phi i64 [ 0, %96 ], [ %134, %133 ]
%120 = call i32* @fgets(i8* %12, i32 4, i32* %13)
%121 = icmp eq i32* %120, null
br i1 %121, label %122, label %125
122: ; preds = %118
%123 = load i32, i32* @EXIT_FAILURE
%124 = call i32 @ewc(i32 %123, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.11, i64 0, i64 0))
br label %125
125: ; preds = %122, %118
%126 = call i32 @atoi(i8* %12)
switch i32 %126, label %127 [
i32 -1, label %130
i32 1, label %130
]
127: ; preds = %125
%128 = load i32, i32* @EXIT_FAILURE
%129 = call i32 @ewc(i32 %128, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.12, i64 0, i64 0))
br label %133
130: ; preds = %125, %125
%131 = trunc i32 %126 to i8
%132 = getelementptr inbounds i8, i8* %8, i64 %119
store i8 %131, i8* %132
br label %133
133: ; preds = %127, %130
%134 = add nuw nsw i64 %119, 1
%135 = icmp eq i64 %134, %97
br i1 %135, label %136, label %118
136: ; preds = %133, %70, %95
%137 = load i32, i32* @stdout
%138 = call i32 @fprintf(i32 %137, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0))
%139 = call i32 @fclose(i32* %13)
ret void
}