#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*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int get_value(const char *dir_name, const char *base_name, char *value,
              int max_value_len) {
  char buff[516];
  FILE *f;
  int len;
  if ((NULL == dir_name) && (NULL == base_name))
    return 0;
  if (dir_name) {
    strcpy(buff, dir_name);
    if (base_name && (strlen(base_name) > 0)) {
      strcat(buff, "/");
      strcat(buff, base_name);
    }
  } else
    strcpy(buff, base_name);
  if (NULL == (f = fopen(buff, "r"))) {
    return 0;
  }
  if (NULL == fgets(value, max_value_len, f)) {
    fclose(f);
    return 0;
  }
  len = strlen(value);
  if ((len > 0) && (value[len - 1] == '\n'))
    value[len - 1] = '\0';
  fclose(f);
  return 1;
}


x86 assembly (clang, -O0):
<get_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    119e <get_value+0x3e>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    119e <get_value+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    12db <get_value+0x17b>
cmpq   $0x0,-0x10(%rbp)
je     11fe <get_value+0x9e>
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x18(%rbp)
je     11f9 <get_value+0x99>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    11f9 <get_value+0x99>
lea    -0x230(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1080 <strcat@plt>
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcat@plt>
jmp    120e <get_value+0xae>
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x230(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x238(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1242 <get_value+0xe2>
movl   $0x0,-0x4(%rbp)
jmp    12db <get_value+0x17b>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x238(%rbp),%rdx
call   1060 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    127b <get_value+0x11b>
mov    -0x238(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    12db <get_value+0x17b>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x23c(%rbp)
cmpl   $0x0,-0x23c(%rbp)
jle    12c8 <get_value+0x168>
mov    -0x20(%rbp),%rax
mov    -0x23c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12c8 <get_value+0x168>
mov    -0x20(%rbp),%rax
mov    -0x23c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x238(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_value>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x210,%rsp
mov    %rsi,%rbp
xor    %ebx,%ebx
mov    %rdi,%rax
or     %rsi,%rax
je     1224 <get_value+0xc4>
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rdi,%rsi
mov    %rsp,%rdi
test   %rsi,%rsi
je     11c6 <get_value+0x66>
call   1030 <strcpy@plt>
test   %rbp,%rbp
je     11ce <get_value+0x6e>
mov    %rbp,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11ce <get_value+0x6e>
lea    0xe52(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
call   1080 <strcat@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1080 <strcat@plt>
jmp    11ce <get_value+0x6e>
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0xe2d(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     1224 <get_value+0xc4>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     121a <get_value+0xba>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    $0x1,%ebx
test   %eax,%eax
jle    121c <get_value+0xbc>
add    $0xffffffff,%eax
cmpb   $0xa,(%r14,%rax,1)
jne    121c <get_value+0xbc>
movb   $0x0,(%r14,%rax,1)
jmp    121c <get_value+0xbc>
xor    %ebx,%ebx
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %ebx,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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