#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*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int sProperty(char *file, char *name, char *val, int vlen, char *_default) {
  char buff[256];
  char *next;
  char *v;
  int lv;
  int lname = strlen(name);
  strncpy(val, _default, vlen);
  FILE *fp = fopen(file, "r");
  if (fp == NULL) {
    return -1;
  }
  while (1) {
    next = fgets(buff, 256, fp);
    if (next == NULL)
      break;
    if (!strncmp(next, name, lname)) {
      v = buff + lname;
      while (*v == ' ' || *v == '\t' || *v == '=')
        ++v;
      lv = strlen(v);
      if (v[lv - 1] == '\n')
        v[lv - 1] = 0;
      strncpy(val, v, vlen);
      break;
    }
  }
  fclose(fp);
  return next != NULL;
}


x86 assembly (clang, -O0):
<sProperty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x148(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x150(%rbp)
cmpq   $0x0,-0x150(%rbp)
jne    11ce <sProperty+0x6e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1337 <sProperty+0x1d7>
jmp    11d3 <sProperty+0x73>
lea    -0x130(%rbp),%rdi
mov    -0x150(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
jne    1205 <sProperty+0xa5>
jmp    1318 <sProperty+0x1b8>
mov    -0x138(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x148(%rbp),%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1313 <sProperty+0x1b3>
lea    -0x130(%rbp),%rax
movslq -0x148(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x140(%rbp)
mov    -0x140(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x151(%rbp)
je     1288 <sProperty+0x128>
mov    -0x140(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x151(%rbp)
je     1288 <sProperty+0x128>
mov    -0x140(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
sete   %al
mov    %al,-0x151(%rbp)
mov    -0x151(%rbp),%al
test   $0x1,%al
jne    129b <sProperty+0x13b>
jmp    12b2 <sProperty+0x152>
mov    -0x140(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x140(%rbp)
jmp    123c <sProperty+0xdc>
mov    -0x140(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x144(%rbp)
mov    -0x140(%rbp),%rax
mov    -0x144(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12fb <sProperty+0x19b>
mov    -0x140(%rbp),%rax
mov    -0x144(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    -0x140(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
jmp    1318 <sProperty+0x1b8>
jmp    11d3 <sProperty+0x73>
mov    -0x150(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x138(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sProperty>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r8,%r12
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,0xc(%rsp)
mov    %ebx,%edx
call   1030 <strncpy@plt>
lea    0xe5f(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1216 <sProperty+0xb6>
mov    %rax,%r12
lea    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1242 <sProperty+0xe2>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    11c0 <sProperty+0x60>
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rbp
add    $0x10,%rbp
movabs $0x2000000100000200,%rax
xchg   %ax,%ax
movzbl 0x0(%rbp),%ecx
cmp    $0x3d,%rcx
ja     121d <sProperty+0xbd>
bt     %rcx,%rax
jae    121d <sProperty+0xbd>
add    $0x1,%rbp
jmp    1200 <sProperty+0xa0>
mov    $0xffffffff,%ebp
jmp    1253 <sProperty+0xf3>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbp,1)
jne    1233 <sProperty+0xd3>
movb   $0x0,-0x1(%rbp,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
mov    0xc(%rsp),%edx
call   1030 <strncpy@plt>
xor    %ebp,%ebp
test   %rbx,%rbx
setne  %bpl
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @sProperty(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca [256 x i8]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%18 = load i8*, i8** %8
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %16
%20 = load i8*, i8** %9
%21 = load i8*, i8** %11
%22 = load i32, i32* %10
%23 = call i32 @strncpy(i8* %20, i8* %21, i32 %22)
%24 = load i8*, i8** %7
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %17
%26 = load i32*, i32** %17
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %29
28: ; preds = %5
store i32 -1, i32* %6
br label %97
29: ; preds = %5
br label %30
30: ; preds = %29, %90
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%32 = load i32*, i32** %17
%33 = call i8* @fgets(i8* %31, i32 256, i32* %32)
store i8* %33, i8** %13
%34 = load i8*, i8** %13
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %37
36: ; preds = %30
br label %91
37: ; preds = %30
%38 = load i8*, i8** %13
%39 = load i8*, i8** %8
%40 = load i32, i32* %16
%41 = call i32 @strncmp(i8* %38, i8* %39, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %90, label %43
43: ; preds = %37
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%45 = load i32, i32* %16
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8* %47, i8** %14
br label %48
48: ; preds = %65, %43
%49 = load i8*, i8** %14
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 32
br i1 %52, label %63, label %53
53: ; preds = %48
%54 = load i8*, i8** %14
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 9
br i1 %57, label %63, label %58
58: ; preds = %53
%59 = load i8*, i8** %14
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 61
br label %63
63: ; preds = %58, %53, %48
%64 = phi i1 [ true, %53 ], [ true, %48 ], [ %62, %58 ]
br i1 %64, label %65, label %68
65: ; preds = %63
%66 = load i8*, i8** %14
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %14
br label %48
68: ; preds = %63
%69 = load i8*, i8** %14
%70 = call i32 @strlen(i8* %69)
store i32 %70, i32* %15
%71 = load i8*, i8** %14
%72 = load i32, i32* %15
%73 = sub nsw i32 %72, 1
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %71, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 10
br i1 %78, label %79, label %85
79: ; preds = %68
%80 = load i8*, i8** %14
%81 = load i32, i32* %15
%82 = sub nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %80, i64 %83
store i8 0, i8* %84
br label %85
85: ; preds = %79, %68
%86 = load i8*, i8** %9
%87 = load i8*, i8** %14
%88 = load i32, i32* %10
%89 = call i32 @strncpy(i8* %86, i8* %87, i32 %88)
br label %91
90: ; preds = %37
br label %30
91: ; preds = %85, %36
%92 = load i32*, i32** %17
%93 = call i32 @fclose(i32* %92)
%94 = load i8*, i8** %13
%95 = icmp ne i8* %94, null
%96 = zext i1 %95 to i32
store i32 %96, i32* %6
br label %97
97: ; preds = %91, %28
%98 = load i32, i32* %6
ret i32 %98
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @sProperty(i8* nocapture %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @strncpy(i8* %2, i8* %4, i32 %3)
%10 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %40, label %12
12: ; preds = %5, %15
%13 = call i8* @fgets(i8* %7, i32 256, i32* %10)
%14 = icmp eq i8* %13, null
br i1 %14, label %36, label %15
15: ; preds = %12
%16 = call i32 @strncmp(i8* %13, i8* %1, i32 %8)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %12
18: ; preds = %15
%19 = sext i32 %8 to i64
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %19
br label %21
21: ; preds = %24, %18
%22 = phi i8* [ %20, %18 ], [ %25, %24 ]
%23 = load i8, i8* %22
switch i8 %23, label %26 [
i8 32, label %24
i8 9, label %24
i8 61, label %24
]
24: ; preds = %21, %21, %21
%25 = getelementptr inbounds i8, i8* %22, i64 1
br label %21
26: ; preds = %21
%27 = call i32 @strlen(i8* %22)
%28 = add nsw i32 %27, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %22, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 10
br i1 %32, label %33, label %34
33: ; preds = %26
store i8 0, i8* %30
br label %34
34: ; preds = %33, %26
%35 = call i32 @strncpy(i8* %2, i8* %22, i32 %3)
br label %36
36: ; preds = %12, %34
%37 = xor i1 %14, true
%38 = call i32 @fclose(i32* %10)
%39 = zext i1 %37 to i32
br label %40
40: ; preds = %5, %36
%41 = phi i32 [ %39, %36 ], [ -1, %5 ]
ret i32 %41
}