#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);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isspace(char);
char *malloc(scalar_t__);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *strrchr(char *, char);
char *readconf(char *file) {
  FILE *f;
  char buf[16384], *p, *r, *s;
  r = NULL;
  if ((f = fopen(file, "r")) != NULL) {
    while (fgets(buf, sizeof buf, f) != NULL) {
      if (strncmp(buf, "queue", 5) == 0 && isspace(buf[5])) {
        if ((p = strrchr((char *)buf, '\n')) != NULL)
          *p = '\0';
        p = buf + 5;
        while (*p && isspace(*p))
          p++;
        if (*p != '\0')
          r = p;
        break;
      }
    }
    fclose(f);
  } else {
    printf("SYMPA internal error : unable to open %s", file);
    exit(-1);
  }
  if (r != NULL) {
    s = malloc(strlen(r) + 1);
    if (s != NULL)
      strcpy(s, r);
  }
  return s;
}


x86 assembly (clang, -O0):
<readconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4030,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x4020(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     131c <readconf+0x16c>
jmp    11ed <readconf+0x3d>
lea    -0x4010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x4000,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     130e <readconf+0x15e>
lea    -0x4010(%rbp),%rdi
lea    0xde8(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1309 <readconf+0x159>
movsbl -0x400b(%rbp),%edi
call   1090 <isspace@plt>
cmp    $0x0,%rax
je     1309 <readconf+0x159>
lea    -0x4010(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strrchr@plt>
mov    %rax,-0x4018(%rbp)
cmp    $0x0,%rax
je     1270 <readconf+0xc0>
mov    -0x4018(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x4010(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x4018(%rbp)
mov    -0x4018(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x4029(%rbp)
je     12b9 <readconf+0x109>
mov    -0x4018(%rbp),%rax
movsbl (%rax),%edi
call   1090 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x4029(%rbp)
mov    -0x4029(%rbp),%al
test   $0x1,%al
jne    12cc <readconf+0x11c>
jmp    12e3 <readconf+0x133>
mov    -0x4018(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x4018(%rbp)
jmp    1282 <readconf+0xd2>
mov    -0x4018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1304 <readconf+0x154>
mov    -0x4018(%rbp),%rax
mov    %rax,-0x4020(%rbp)
jmp    130e <readconf+0x15e>
jmp    11ed <readconf+0x3d>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1336 <readconf+0x186>
mov    -0x8(%rbp),%rsi
lea    0xce1(%rip),%rdi
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
cmpq   $0x0,-0x4020(%rbp)
je     1389 <readconf+0x1d9>
mov    -0x4020(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x4028(%rbp)
cmpq   $0x0,-0x4028(%rbp)
je     1384 <readconf+0x1d4>
mov    -0x4028(%rbp),%rdi
mov    -0x4020(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1389 <readconf+0x1d9>
mov    -0x4028(%rbp),%rax
add    $0x4030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readconf>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x4008,%rsp
mov    %rdi,%rbx
lea    0xe38(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     12dc <readconf+0x12c>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0x4000,%esi
mov    %rax,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     128a <readconf+0xda>
lea    0x5(%rsp),%r14
lea    0xe04(%rip),%r15
mov    %rsp,%rbx
jmp    1225 <readconf+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x4000,%esi
mov    %r12,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     128a <readconf+0xda>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1210 <readconf+0x60>
movsbl 0x5(%rsp),%edi
call   1090 <isspace@plt>
test   %rax,%rax
je     1210 <readconf+0x60>
mov    %rsp,%rdi
mov    $0xa,%esi
call   1080 <strrchr@plt>
test   %rax,%rax
je     125e <readconf+0xae>
movb   $0x0,(%rax)
mov    0x5(%rsp),%al
test   %al,%al
je     128a <readconf+0xda>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1090 <isspace@plt>
test   %rax,%rax
je     12a4 <readconf+0xf4>
movzbl 0x1(%r14),%eax
add    $0x1,%r14
test   %al,%al
jne    1270 <readconf+0xc0>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rax
add    $0x4008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
cmpb   $0x0,(%r14)
je     128a <readconf+0xda>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10b0 <malloc@plt>
test   %rax,%rax
je     12d8 <readconf+0x128>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
jmp    1292 <readconf+0xe2>
xor    %ebx,%ebx
jmp    1292 <readconf+0xe2>
lea    0xd25(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"queue\00"
@.str.2 = [41 x i8] c"SYMPA internal error : unable to open %s\00"
define i8* @readconf(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [16384 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %6
%8 = load i8*, i8** %2
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %62
11: ; preds = %1
br label %12
12: ; preds = %58, %11
%13 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%14 = load i32*, i32** %3
%15 = call i32* @fgets(i8* %13, i32 16384, i32* %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %59
17: ; preds = %12
%18 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %58
21: ; preds = %17
%22 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 5
%23 = load i8, i8* %22
%24 = call i64 @isspace(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %58
26: ; preds = %21
%27 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%28 = call i8* @strrchr(i8* %27, i8 signext 10)
store i8* %28, i8** %5
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i8*, i8** %5
store i8 0, i8* %31
br label %32
32: ; preds = %30, %26
%33 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%34 = getelementptr inbounds i8, i8* %33, i64 5
store i8* %34, i8** %5
br label %35
35: ; preds = %47, %32
%36 = load i8*, i8** %5
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = load i8*, i8** %5
%42 = load i8, i8* %41
%43 = call i64 @isspace(i8 signext %42)
%44 = icmp ne i64 %43, 0
br label %45
45: ; preds = %40, %35
%46 = phi i1 [ false, %35 ], [ %44, %40 ]
br i1 %46, label %47, label %50
47: ; preds = %45
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %5
br label %35
50: ; preds = %45
%51 = load i8*, i8** %5
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = load i8*, i8** %5
store i8* %56, i8** %6
br label %57
57: ; preds = %55, %50
br label %59
58: ; preds = %21, %17
br label %12
59: ; preds = %57, %12
%60 = load i32*, i32** %3
%61 = call i32 @fclose(i32* %60)
br label %66
62: ; preds = %1
%63 = load i8*, i8** %2
%64 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %63)
%65 = call i32 @exit(i32 -1)
unreachable
66: ; preds = %59
%67 = load i8*, i8** %6
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %81
69: ; preds = %66
%70 = load i8*, i8** %6
%71 = call i64 @strlen(i8* %70)
%72 = add nsw i64 %71, 1
%73 = call i8* @malloc(i64 %72)
store i8* %73, i8** %7
%74 = load i8*, i8** %7
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %80
76: ; preds = %69
%77 = load i8*, i8** %7
%78 = load i8*, i8** %6
%79 = call i32 @strcpy(i8* %77, i8* %78)
br label %80
80: ; preds = %76, %69
br label %81
81: ; preds = %80, %66
%82 = load i8*, i8** %7
ret i8* %82
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"queue\00"
@.str.2 = [41 x i8] c"SYMPA internal error : unable to open %s\00"
define i8* @readconf(i8* %0) {
%2 = alloca [16384 x i8]
%3 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %42, label %6
6: ; preds = %1
%7 = call i32* @fgets(i8* %3, i32 16384, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %40, label %9
9: ; preds = %6
%10 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 5
br label %11
11: ; preds = %9, %37
%12 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %37
14: ; preds = %11
%15 = load i8, i8* %10
%16 = call i64 @isspace(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %37, label %18
18: ; preds = %14
%19 = call i8* @strrchr(i8* %3, i8 signext 10)
%20 = icmp eq i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %18
store i8 0, i8* %19
br label %22
22: ; preds = %21, %18
%23 = load i8, i8* %10
%24 = icmp eq i8 %23, 0
br i1 %24, label %40, label %25
25: ; preds = %22, %30
%26 = phi i8 [ %32, %30 ], [ %23, %22 ]
%27 = phi i8* [ %31, %30 ], [ %10, %22 ]
%28 = call i64 @isspace(i8 signext %26)
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %25
%31 = getelementptr inbounds i8, i8* %27, i64 1
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %40, label %25
34: ; preds = %25
%35 = load i8, i8* %27
%36 = icmp eq i8 %35, 0
br i1 %36, label %40, label %45
37: ; preds = %14, %11
%38 = call i32* @fgets(i8* %3, i32 16384, i32* %4)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %11
40: ; preds = %37, %30, %6, %22, %34
%41 = call i32 @fclose(i32* %4)
br label %53
42: ; preds = %1
%43 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%44 = tail call i32 @exit(i32 -1)
unreachable
45: ; preds = %34
%46 = call i32 @fclose(i32* %4)
%47 = call i64 @strlen(i8* %27)
%48 = add nsw i64 %47, 1
%49 = call i8* @malloc(i64 %48)
%50 = icmp eq i8* %49, null
br i1 %50, label %53, label %51
51: ; preds = %45
%52 = call i32 @strcpy(i8* %49, i8* %27)
br label %53
53: ; preds = %40, %45, %51
%54 = phi i8* [ %49, %51 ], [ null, %45 ], [ undef, %40 ]
ret i8* %54
}