#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*/ buf;
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*/ free(char *);
char *getenv(char *);
scalar_t__ isspace(char);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *DWBhome(void) {
  FILE *fp;
  char *ptr;
  char *path;
  int len;
  char buf[200];
  char *home = NULL;
  if ((fp = fopen("/dev/null", "r")) != NULL) {
    len = strlen("DWBHOME");
    while (fgets(buf, sizeof(buf), fp) != NULL) {
      for (ptr = buf; isspace(*ptr); ptr++)
        ;
      if (strncmp(ptr, "DWBHOME", len) == 0 && *(ptr + len) == '=') {
        path = ptr + len + 1;
        for (ptr = path; !isspace(*ptr) && *ptr != ';'; ptr++)
          ;
        *ptr = '\0';
        if (home != NULL)
          free(home);
        if ((home = malloc(strlen(path) + 1)) != NULL)
          strcpy(home, path);
      }
    }
    fclose(fp);
  }
  if (home == NULL) {
    if ((home = getenv("DWBHOME")) == NULL) {
      if ((home = "") == NULL || *home == '\0' || *home == ' ')
        home = NULL;
    }
  }
  while (home && *home == '/' && *(home + 1) == '/')
    home++;
  return (home);
}


x86 assembly (clang, -O0):
<DWBhome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movq   $0x0,-0xf8(%rbp)
lea    0xe43(%rip),%rdi
lea    0xe46(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     134e <DWBhome+0x1ae>
lea    0xe2e(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0xc8,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1345 <DWBhome+0x1a5>
lea    -0xf0(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1090 <isspace@plt>
cmp    $0x0,%rax
je     123c <DWBhome+0x9c>
jmp    122b <DWBhome+0x8b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1210 <DWBhome+0x70>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xdc2(%rip),%rsi
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    1340 <DWBhome+0x1a0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1340 <DWBhome+0x1a0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1090 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xf9(%rbp)
jne    12bd <DWBhome+0x11d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
setne  %al
mov    %al,-0xf9(%rbp)
mov    -0xf9(%rbp),%al
test   $0x1,%al
jne    12d0 <DWBhome+0x130>
jmp    12e6 <DWBhome+0x146>
jmp    12d5 <DWBhome+0x135>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1289 <DWBhome+0xe9>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0xf8(%rbp)
je     1307 <DWBhome+0x167>
mov    -0xf8(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0xf8(%rbp)
cmp    $0x0,%rax
je     133b <DWBhome+0x19b>
mov    -0xf8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcpy@plt>
jmp    1340 <DWBhome+0x1a0>
jmp    11e6 <DWBhome+0x46>
mov    -0x8(%rbp),%rdi
call   1070 <fclose@plt>
cmpq   $0x0,-0xf8(%rbp)
jne    13cc <DWBhome+0x22c>
lea    0xca9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0xf8(%rbp)
cmp    $0x0,%rax
jne    13c7 <DWBhome+0x227>
lea    0xc93(%rip),%rax
mov    %rax,-0xf8(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    13b7 <DWBhome+0x217>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13b7 <DWBhome+0x217>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    13c2 <DWBhome+0x222>
movq   $0x0,-0xf8(%rbp)
jmp    13c7 <DWBhome+0x227>
jmp    13cc <DWBhome+0x22c>
jmp    13d1 <DWBhome+0x231>
xor    %eax,%eax
cmpq   $0x0,-0xf8(%rbp)
mov    %al,-0xfa(%rbp)
je     1419 <DWBhome+0x279>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0xfa(%rbp)
jne    1419 <DWBhome+0x279>
mov    -0xf8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
sete   %al
mov    %al,-0xfa(%rbp)
mov    -0xfa(%rbp),%al
test   $0x1,%al
jne    142c <DWBhome+0x28c>
jmp    1443 <DWBhome+0x2a3>
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    13d1 <DWBhome+0x231>
mov    -0xf8(%rbp),%rax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DWBhome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xe48(%rip),%rdi
lea    0xe4b(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1304 <DWBhome+0x164>
mov    %rax,%r13
lea    0xe35(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,%ebp
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %r13,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     12fc <DWBhome+0x15c>
movslq %ebp,%rax
lea    (%rsp,%rax,1),%r12
xor    %r14d,%r14d
jmp    1239 <DWBhome+0x99>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <strcpy@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %r13,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     12ed <DWBhome+0x14d>
lea    -0x1(%rsp),%r15
mov    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%r15),%edi
add    $0x1,%r15
call   1090 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1250 <DWBhome+0xb0>
mov    %r15,%rdi
lea    0xd9b(%rip),%rsi
mov    %ebp,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    1220 <DWBhome+0x80>
cmpb   $0x3d,-0x1(%rbx)
jne    1220 <DWBhome+0x80>
mov    %ebp,%r15d
movsbl (%rbx),%edi
call   1090 <isspace@plt>
mov    %rbx,%rbp
test   %rax,%rax
jne    12b8 <DWBhome+0x118>
mov    %rbx,%rbp
nopl   0x0(%rax)
cmpb   $0x3b,0x0(%rbp)
je     12b8 <DWBhome+0x118>
movsbl 0x1(%rbp),%edi
add    $0x1,%rbp
call   1090 <isspace@plt>
test   %rax,%rax
je     12a0 <DWBhome+0x100>
movb   $0x0,0x0(%rbp)
test   %r14,%r14
je     12c9 <DWBhome+0x129>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%edi
call   10b0 <malloc@plt>
test   %rax,%rax
mov    %r15d,%ebp
jne    1203 <DWBhome+0x63>
xor    %r14d,%r14d
jmp    1220 <DWBhome+0x80>
mov    %r13,%rdi
call   1070 <fclose@plt>
test   %r14,%r14
jne    1320 <DWBhome+0x180>
jmp    1304 <DWBhome+0x164>
mov    %r13,%rdi
call   1070 <fclose@plt>
lea    0xd01(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %r14,%r14
je     133a <DWBhome+0x19a>
mov    %r14,%rax
cmpb   $0x2f,(%r14)
jne    133c <DWBhome+0x19c>
lea    0x1(%rax),%r14
cmpb   $0x2f,0x1(%rax)
je     1320 <DWBhome+0x180>
jmp    133c <DWBhome+0x19c>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/null\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"DWBHOME\00"
@.str.3 = [1 x i8] zeroinitializer
define i8* @DWBhome() {
%1 = alloca i32*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [200 x i8]
%6 = alloca i8*
store i8* null, i8** %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %1
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %85
9: ; preds = %0
%10 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 %10, i32* %4
br label %11
11: ; preds = %81, %9
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%13 = load i32*, i32** %1
%14 = call i32* @fgets(i8* %12, i32 200, i32* %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %82
16: ; preds = %11
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
store i8* %17, i8** %2
br label %18
18: ; preds = %24, %16
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = call i64 @isspace(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %18
br label %24
24: ; preds = %23
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %2
br label %18
27: ; preds = %18
%28 = load i8*, i8** %2
%29 = load i32, i32* %4
%30 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %81
32: ; preds = %27
%33 = load i8*, i8** %2
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 61
br i1 %39, label %40, label %81
40: ; preds = %32
%41 = load i8*, i8** %2
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = getelementptr inbounds i8, i8* %44, i64 1
store i8* %45, i8** %3
%46 = load i8*, i8** %3
store i8* %46, i8** %2
br label %47
47: ; preds = %60, %40
%48 = load i8*, i8** %2
%49 = load i8, i8* %48
%50 = call i64 @isspace(i8 signext %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %47
%53 = load i8*, i8** %2
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 59
br label %57
57: ; preds = %52, %47
%58 = phi i1 [ false, %47 ], [ %56, %52 ]
br i1 %58, label %59, label %63
59: ; preds = %57
br label %60
60: ; preds = %59
%61 = load i8*, i8** %2
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %2
br label %47
63: ; preds = %57
%64 = load i8*, i8** %2
store i8 0, i8* %64
%65 = load i8*, i8** %6
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = load i8*, i8** %6
%69 = call i32 @free(i8* %68)
br label %70
70: ; preds = %67, %63
%71 = load i8*, i8** %3
%72 = call i32 @strlen(i8* %71)
%73 = add nsw i32 %72, 1
%74 = call i8* @malloc(i32 %73)
store i8* %74, i8** %6
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %80
76: ; preds = %70
%77 = load i8*, i8** %6
%78 = load i8*, i8** %3
%79 = call i32 @strcpy(i8* %77, i8* %78)
br label %80
80: ; preds = %76, %70
br label %81
81: ; preds = %80, %32, %27
br label %11
82: ; preds = %11
%83 = load i32*, i32** %1
%84 = call i32 @fclose(i32* %83)
br label %85
85: ; preds = %82, %0
%86 = load i8*, i8** %6
%87 = icmp eq i8* %86, null
br i1 %87, label %88, label %105
88: ; preds = %85
%89 = call i8* @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i8* %89, i8** %6
%90 = icmp eq i8* %89, null
br i1 %90, label %91, label %104
91: ; preds = %88
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8** %6
br i1 false, label %102, label %92
92: ; preds = %91
%93 = load i8*, i8** %6
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 0
br i1 %96, label %102, label %97
97: ; preds = %92
%98 = load i8*, i8** %6
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 32
br i1 %101, label %102, label %103
102: ; preds = %97, %92, %91
store i8* null, i8** %6
br label %103
103: ; preds = %102, %97
br label %104
104: ; preds = %103, %88
br label %105
105: ; preds = %104, %85
br label %106
106: ; preds = %122, %105
%107 = load i8*, i8** %6
%108 = icmp ne i8* %107, null
br i1 %108, label %109, label %120
109: ; preds = %106
%110 = load i8*, i8** %6
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 47
br i1 %113, label %114, label %120
114: ; preds = %109
%115 = load i8*, i8** %6
%116 = getelementptr inbounds i8, i8* %115, i64 1
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = icmp eq i32 %118, 47
br label %120
120: ; preds = %114, %109, %106
%121 = phi i1 [ false, %109 ], [ false, %106 ], [ %119, %114 ]
br i1 %121, label %122, label %125
122: ; preds = %120
%123 = load i8*, i8** %6
%124 = getelementptr inbounds i8, i8* %123, i32 1
store i8* %124, i8** %6
br label %106
125: ; preds = %120
%126 = load i8*, i8** %6
ret i8* %126
}

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