#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*/ uint8_t;
typedef int uint32_t;
struct stat {
  int dummy;
};
typedef int int32_t;

/* Variables and functions */
scalar_t__ ENOENT;
int MAXPATHLEN;
int /*<<< orphan*/ close_master_conn(int);
scalar_t__ errno;
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int get32bit(int /*<<< orphan*/ const **);
char get8bit(int /*<<< orphan*/ const **);
char *getcwd(char *, int);
int /*<<< orphan*/ *malloc(int);
char *mfsstrerr(int /*<<< orphan*/ const);
int open_master_conn(char const *, int *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *, int /*<<< orphan*/,
                     int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ put32bit(int /*<<< orphan*/ **, int);
int /*<<< orphan*/ putchar(char);
scalar_t__ stat(char const *, struct stat *);
int strtoul(char const *, int /*<<< orphan*/ *, int);
int tcptoread(int, int /*<<< orphan*/ *, int, int);
int tcptowrite(int, int /*<<< orphan*/ *, int, int);
int file_paths(const char *fname) {
  uint8_t reqbuff[16], *wptr, *buff;
  const uint8_t *rptr;
  const char *p;
  struct stat st;
  char cwdbuff[MAXPATHLEN];
  uint32_t arginode;
  uint32_t cmd, leng, inode;
  uint32_t pleng;
  int fd;
  p = fname;
  while (*p >= '0' && *p <= '9') {
    p++;
  }
  if (*p == '\0' && stat(fname, &st) < 0 && errno == ENOENT) {
    arginode = strtoul(fname, NULL, 10);
    p = getcwd(cwdbuff, MAXPATHLEN);
    fd = open_master_conn(p, &inode, NULL, NULL, 0, 0);
    inode = arginode;
  } else {
    fd = open_master_conn(fname, &inode, NULL, NULL, 0, 0);
  }
  if (fd < 0) {
    return -1;
  }
  wptr = reqbuff;
  put32bit(&wptr, (0 + 486));
  put32bit(&wptr, 8);
  put32bit(&wptr, 0);
  put32bit(&wptr, inode);
  if (tcptowrite(fd, reqbuff, 16, 10000) != 16) {
    printf("%s: master query: send error\n", fname);
    close_master_conn(1);
    return -1;
  }
  if (tcptoread(fd, reqbuff, 8, 10000) != 8) {
    printf("%s: master query: receive error\n", fname);
    close_master_conn(1);
    return -1;
  }
  rptr = reqbuff;
  cmd = get32bit(&rptr);
  leng = get32bit(&rptr);
  if (cmd != (0 + 487)) {
    printf("%s: master query: wrong answer (type)\n", fname);
    close_master_conn(1);
    return -1;
  }
  buff = malloc(leng);
  if (tcptoread(fd, buff, leng, 10000) != (int32_t)leng) {
    printf("%s: master query: receive error\n", fname);
    free(buff);
    close_master_conn(1);
    return -1;
  }
  close_master_conn(0);
  rptr = buff;
  cmd = get32bit(&rptr);
  if (cmd != 0) {
    printf("%s: master query: wrong answer (queryid)\n", fname);
    free(buff);
    return -1;
  }
  leng -= 4;
  if (leng == 1) {
    printf("%s: %s\n", fname, mfsstrerr(*rptr));
    free(buff);
    return -1;
  }
  printf("%s:\n", fname);
  while (leng >= 4) {
    pleng = get32bit(&rptr);
    leng -= 4;
    if (leng >= pleng) {
      while (pleng) {
        putchar(get8bit(&rptr));
        pleng--;
        leng--;
      }
      putchar('\n');
    } else {
      leng = 0;
    }
  }
  free(buff);
  return 0;
}


x86 assembly (clang, -O0):
<file_paths>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0xb1(%rbp)
jl     1264 <file_paths+0x74>
mov    -0x70(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    1277 <file_paths+0x87>
jmp    1288 <file_paths+0x98>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    1239 <file_paths+0x49>
mov    -0x70(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    132e <file_paths+0x13e>
mov    -0x10(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   10c0 <stat@plt>
cmp    $0x0,%rax
jge    132e <file_paths+0x13e>
mov    0x2d22(%rip),%rax
mov    (%rax),%rax
mov    0x2d08(%rip),%rcx
cmp    (%rcx),%rax
jne    132e <file_paths+0x13e>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1100 <strtoul@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,-0x8c(%rbp)
mov    0x2cf9(%rip),%rax
mov    (%rax),%esi
call   10a0 <getcwd@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
lea    -0x98(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r9d,%r9d
mov    %rcx,%rdx
mov    %r9d,%r8d
call   1110 <open_master_conn@plt>
mov    %eax,-0xa0(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x98(%rbp)
jmp    1351 <file_paths+0x161>
mov    -0x10(%rbp),%rdi
lea    -0x98(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r9d,%r9d
mov    %rcx,%rdx
mov    %r9d,%r8d
call   1110 <open_master_conn@plt>
mov    %eax,-0xa0(%rbp)
cmpl   $0x0,-0xa0(%rbp)
jge    1374 <file_paths+0x184>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    16c4 <file_paths+0x4d4>
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x58(%rbp),%rdi
mov    $0x1e6,%esi
call   10e0 <put32bit@plt>
lea    -0x58(%rbp),%rdi
mov    $0x8,%esi
call   10e0 <put32bit@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
call   10e0 <put32bit@plt>
mov    -0x98(%rbp),%esi
lea    -0x58(%rbp),%rdi
call   10e0 <put32bit@plt>
mov    -0xa0(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x10,%edx
mov    $0x2710,%ecx
call   10f0 <tcptowrite@plt>
cmp    $0x10,%eax
je     1406 <file_paths+0x216>
mov    -0x10(%rbp),%rsi
lea    0xc21(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1070 <close_master_conn@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    16c4 <file_paths+0x4d4>
mov    -0xa0(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
mov    $0x2710,%ecx
call   10b0 <tcptoread@plt>
cmp    $0x8,%eax
je     145a <file_paths+0x26a>
mov    -0x10(%rbp),%rsi
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1070 <close_master_conn@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    16c4 <file_paths+0x4d4>
lea    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x68(%rbp),%rdi
call   1060 <get32bit@plt>
mov    %eax,-0x90(%rbp)
lea    -0x68(%rbp),%rdi
call   1060 <get32bit@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x1e7,-0x90(%rbp)
je     14c2 <file_paths+0x2d2>
mov    -0x10(%rbp),%rsi
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1070 <close_master_conn@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    16c4 <file_paths+0x4d4>
mov    -0x94(%rbp),%edi
call   10d0 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0xa0(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x94(%rbp),%edx
mov    $0x2710,%ecx
call   10b0 <tcptoread@plt>
cmp    -0x94(%rbp),%eax
je     1532 <file_paths+0x342>
mov    -0x10(%rbp),%rsi
lea    0xb1c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1070 <close_master_conn@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    16c4 <file_paths+0x4d4>
xor    %edi,%edi
call   1070 <close_master_conn@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x68(%rbp),%rdi
call   1060 <get32bit@plt>
mov    %eax,-0x90(%rbp)
cmpl   $0x0,-0x90(%rbp)
je     158e <file_paths+0x39e>
mov    -0x10(%rbp),%rsi
lea    0xafe(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    16c4 <file_paths+0x4d4>
mov    -0x94(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x94(%rbp)
cmpl   $0x1,-0x94(%rbp)
jne    15f7 <file_paths+0x407>
mov    -0x10(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%edi
call   1050 <mfsstrerr@plt>
mov    -0xc0(%rbp),%rsi
mov    %rax,%rdx
lea    0xabf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
jmp    16c4 <file_paths+0x4d4>
mov    -0x10(%rbp),%rsi
lea    0xa96(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
cmpl   $0x4,-0x94(%rbp)
jl     16aa <file_paths+0x4ba>
lea    -0x68(%rbp),%rdi
call   1060 <get32bit@plt>
mov    %eax,-0x9c(%rbp)
mov    -0x94(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jl     169b <file_paths+0x4ab>
jmp    164b <file_paths+0x45b>
cmpl   $0x0,-0x9c(%rbp)
je     168c <file_paths+0x49c>
lea    -0x68(%rbp),%rdi
call   1090 <get8bit@plt>
movsbl %al,%edi
call   1040 <putchar@plt>
mov    -0x9c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x94(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x94(%rbp)
jmp    164b <file_paths+0x45b>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    16a5 <file_paths+0x4b5>
movl   $0x0,-0x94(%rbp)
jmp    1609 <file_paths+0x419>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_paths>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdi,%r12
mov    %rsp,-0x30(%rbp)
mov    0x2dd9(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
movzbl (%rax),%ecx
lea    -0x30(%rcx),%edx
add    $0x1,%rax
cmp    $0xa,%dl
jb     1230 <file_paths+0x40>
test   %cl,%cl
jne    12a6 <file_paths+0xb6>
lea    -0x50(%rbp),%rsi
mov    %r12,%rdi
call   10c0 <stat@plt>
test   %rax,%rax
jns    12a6 <file_paths+0xb6>
mov    0x2d7d(%rip),%rax
mov    (%rax),%rax
mov    0x2d63(%rip),%rcx
cmp    (%rcx),%rax
jne    12a6 <file_paths+0xb6>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1100 <strtoul@plt>
mov    %eax,%r14d
mov    (%r15),%esi
mov    %rbx,%rdi
call   10a0 <getcwd@plt>
lea    -0x34(%rbp),%rsi
mov    %rax,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1110 <open_master_conn@plt>
mov    %eax,%r13d
mov    %r14d,-0x34(%rbp)
jmp    12bf <file_paths+0xcf>
lea    -0x34(%rbp),%rsi
mov    %r12,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1110 <open_master_conn@plt>
mov    %eax,%r13d
mov    $0xffffffff,%r14d
test   %r13d,%r13d
js     13f4 <file_paths+0x204>
lea    -0xa0(%rbp),%r15
mov    %r15,-0x58(%rbp)
lea    -0x58(%rbp),%rbx
mov    %rbx,%rdi
mov    $0x1e6,%esi
call   10e0 <put32bit@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   10e0 <put32bit@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   10e0 <put32bit@plt>
mov    -0x34(%rbp),%esi
mov    %rbx,%rdi
call   10e0 <put32bit@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x10,%edx
mov    $0x2710,%ecx
call   10f0 <tcptowrite@plt>
cmp    $0x10,%eax
jne    13c7 <file_paths+0x1d7>
lea    -0xa0(%rbp),%r15
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x8,%edx
mov    $0x2710,%ecx
call   10b0 <tcptoread@plt>
cmp    $0x8,%eax
jne    13d0 <file_paths+0x1e0>
mov    %r15,-0x40(%rbp)
lea    -0x40(%rbp),%r15
mov    %r15,%rdi
call   1060 <get32bit@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1060 <get32bit@plt>
cmp    $0x1e7,%ebx
jne    13d9 <file_paths+0x1e9>
mov    %eax,%r15d
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
mov    %r13d,%edi
mov    %rax,%rsi
mov    %r15d,%edx
mov    $0x2710,%ecx
call   10b0 <tcptoread@plt>
cmp    %r15d,%eax
jne    140d <file_paths+0x21d>
xor    %edi,%edi
call   1070 <close_master_conn@plt>
mov    %rbx,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
call   1060 <get32bit@plt>
test   %eax,%eax
je     1428 <file_paths+0x238>
lea    0xcb1(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
jmp    14ce <file_paths+0x2de>
lea    0xc32(%rip),%rdi
jmp    13e0 <file_paths+0x1f0>
lea    0xc47(%rip),%rdi
jmp    13e0 <file_paths+0x1f0>
lea    0xc5f(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   1070 <close_master_conn@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc0a(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    13ea <file_paths+0x1fa>
lea    -0x4(%r15),%r13d
cmp    $0x1,%r13d
jne    1456 <file_paths+0x266>
mov    -0x40(%rbp),%rax
mov    (%rax),%edi
call   1050 <mfsstrerr@plt>
lea    0xc4c(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
jmp    14ce <file_paths+0x2de>
mov    %rbx,-0x48(%rbp)
lea    0xc37(%rip),%rdi
xor    %r14d,%r14d
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0x8,%r15d
jl     14ca <file_paths+0x2da>
lea    -0x40(%rbp),%r12
jmp    148a <file_paths+0x29a>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmp    $0x3,%r13d
jle    14ca <file_paths+0x2da>
mov    %r12,%rdi
call   1060 <get32bit@plt>
add    $0xfffffffc,%r13d
mov    %r13d,%r15d
sub    %eax,%r15d
jl     14ca <file_paths+0x2da>
mov    %eax,%ebx
test   %eax,%eax
je     147a <file_paths+0x28a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
call   1090 <get8bit@plt>
movsbl %al,%edi
call   1040 <putchar@plt>
add    $0xffffffff,%ebx
jne    14b0 <file_paths+0x2c0>
mov    %r15d,%r13d
jmp    147a <file_paths+0x28a>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    13f4 <file_paths+0x204>

LLVM IR (-O0):
%struct.stat = type { i32 }
@MAXPATHLEN = global i32 0
@errno = global i64 0
@ENOENT = global i64 0
@.str = [30 x i8] c"%s: master query: send error\0A\00"
@.str.1 = [33 x i8] c"%s: master query: receive error\0A\00"
@.str.2 = [39 x i8] c"%s: master query: wrong answer (type)\0A\00"
@.str.3 = [42 x i8] c"%s: master query: wrong answer (queryid)\0A\00"
@.str.4 = [8 x i8] c"%s: %s\0A\00"
@.str.5 = [5 x i8] c"%s:\0A\00"
define i32 @file_paths(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [16 x i32]
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca %struct.stat
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %3
%19 = load i32, i32* @MAXPATHLEN
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %10
%22 = alloca i8, i64 %20
store i64 %20, i64* %11
%23 = load i8*, i8** %3
store i8* %23, i8** %8
br label %24
24: ; preds = %36, %1
%25 = load i8*, i8** %8
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp sge i32 %27, 48
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i8*, i8** %8
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp sle i32 %32, 57
br label %34
34: ; preds = %29, %24
%35 = phi i1 [ false, %24 ], [ %33, %29 ]
br i1 %35, label %36, label %39
36: ; preds = %34
%37 = load i8*, i8** %8
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %8
br label %24
39: ; preds = %34
%40 = load i8*, i8** %8
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %60
44: ; preds = %39
%45 = load i8*, i8** %3
%46 = call i64 @stat(i8* %45, %struct.stat* %9)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %60
48: ; preds = %44
%49 = load i64, i64* @errno
%50 = load i64, i64* @ENOENT
%51 = icmp eq i64 %49, %50
br i1 %51, label %52, label %60
52: ; preds = %48
%53 = load i8*, i8** %3
%54 = call i32 @strtoul(i8* %53, i32* null, i32 10)
store i32 %54, i32* %12
%55 = load i32, i32* @MAXPATHLEN
%56 = call i8* @getcwd(i8* %22, i32 %55)
store i8* %56, i8** %8
%57 = load i8*, i8** %8
%58 = call i32 @open_master_conn(i8* %57, i32* %15, i32* null, i32* null, i32 0, i32 0)
store i32 %58, i32* %17
%59 = load i32, i32* %12
store i32 %59, i32* %15
br label %63
60: ; preds = %48, %44, %39
%61 = load i8*, i8** %3
%62 = call i32 @open_master_conn(i8* %61, i32* %15, i32* null, i32* null, i32 0, i32 0)
store i32 %62, i32* %17
br label %63
63: ; preds = %60, %52
%64 = load i32, i32* %17
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %63
store i32 -1, i32* %2
store i32 1, i32* %18
br label %171
67: ; preds = %63
%68 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
store i32* %68, i32** %5
%69 = call i32 @put32bit(i32** %5, i32 486)
%70 = call i32 @put32bit(i32** %5, i32 8)
%71 = call i32 @put32bit(i32** %5, i32 0)
%72 = load i32, i32* %15
%73 = call i32 @put32bit(i32** %5, i32 %72)
%74 = load i32, i32* %17
%75 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%76 = call i32 @tcptowrite(i32 %74, i32* %75, i32 16, i32 10000)
%77 = icmp ne i32 %76, 16
br i1 %77, label %78, label %82
78: ; preds = %67
%79 = load i8*, i8** %3
%80 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %79)
%81 = call i32 @close_master_conn(i32 1)
store i32 -1, i32* %2
store i32 1, i32* %18
br label %171
82: ; preds = %67
%83 = load i32, i32* %17
%84 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%85 = call i32 @tcptoread(i32 %83, i32* %84, i32 8, i32 10000)
%86 = icmp ne i32 %85, 8
br i1 %86, label %87, label %91
87: ; preds = %82
%88 = load i8*, i8** %3
%89 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %88)
%90 = call i32 @close_master_conn(i32 1)
store i32 -1, i32* %2
store i32 1, i32* %18
br label %171
91: ; preds = %82
%92 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
store i32* %92, i32** %7
%93 = call i32 @get32bit(i32** %7)
store i32 %93, i32* %13
%94 = call i32 @get32bit(i32** %7)
store i32 %94, i32* %14
%95 = load i32, i32* %13
%96 = icmp ne i32 %95, 487
br i1 %96, label %97, label %101
97: ; preds = %91
%98 = load i8*, i8** %3
%99 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %98)
%100 = call i32 @close_master_conn(i32 1)
store i32 -1, i32* %2
store i32 1, i32* %18
br label %171
101: ; preds = %91
%102 = load i32, i32* %14
%103 = call i32* @malloc(i32 %102)
store i32* %103, i32** %6
%104 = load i32, i32* %17
%105 = load i32*, i32** %6
%106 = load i32, i32* %14
%107 = call i32 @tcptoread(i32 %104, i32* %105, i32 %106, i32 10000)
%108 = load i32, i32* %14
%109 = icmp ne i32 %107, %108
br i1 %109, label %110, label %116
110: ; preds = %101
%111 = load i8*, i8** %3
%112 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %111)
%113 = load i32*, i32** %6
%114 = call i32 @free(i32* %113)
%115 = call i32 @close_master_conn(i32 1)
store i32 -1, i32* %2
store i32 1, i32* %18
br label %171
116: ; preds = %101
%117 = call i32 @close_master_conn(i32 0)
%118 = load i32*, i32** %6
store i32* %118, i32** %7
%119 = call i32 @get32bit(i32** %7)
store i32 %119, i32* %13
%120 = load i32, i32* %13
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %127
122: ; preds = %116
%123 = load i8*, i8** %3
%124 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %123)
%125 = load i32*, i32** %6
%126 = call i32 @free(i32* %125)
store i32 -1, i32* %2
store i32 1, i32* %18
br label %171
127: ; preds = %116
%128 = load i32, i32* %14
%129 = sub nsw i32 %128, 4
store i32 %129, i32* %14
%130 = load i32, i32* %14
%131 = icmp eq i32 %130, 1
br i1 %131, label %132, label %140
132: ; preds = %127
%133 = load i8*, i8** %3
%134 = load i32*, i32** %7
%135 = load i32, i32* %134
%136 = call i8* @mfsstrerr(i32 %135)
%137 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %133, i8* %136)
%138 = load i32*, i32** %6
%139 = call i32 @free(i32* %138)
store i32 -1, i32* %2
store i32 1, i32* %18
br label %171
140: ; preds = %127
%141 = load i8*, i8** %3
%142 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %141)
br label %143
143: ; preds = %167, %140
%144 = load i32, i32* %14
%145 = icmp sge i32 %144, 4
br i1 %145, label %146, label %168
146: ; preds = %143
%147 = call i32 @get32bit(i32** %7)
store i32 %147, i32* %16
%148 = load i32, i32* %14
%149 = sub nsw i32 %148, 4
store i32 %149, i32* %14
%150 = load i32, i32* %14
%151 = load i32, i32* %16
%152 = icmp sge i32 %150, %151
br i1 %152, label %153, label %166
153: ; preds = %146
br label %154
154: ; preds = %157, %153
%155 = load i32, i32* %16
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %164
157: ; preds = %154
%158 = call signext i8 @get8bit(i32** %7)
%159 = call i32 @putchar(i8 signext %158)
%160 = load i32, i32* %16
%161 = add nsw i32 %160, -1
store i32 %161, i32* %16
%162 = load i32, i32* %14
%163 = add nsw i32 %162, -1
store i32 %163, i32* %14
br label %154
164: ; preds = %154
%165 = call i32 @putchar(i8 signext 10)
br label %167
166: ; preds = %146
store i32 0, i32* %14
br label %167
167: ; preds = %166, %164
br label %143
168: ; preds = %143
%169 = load i32*, i32** %6
%170 = call i32 @free(i32* %169)
store i32 0, i32* %2
store i32 1, i32* %18
br label %171
171: ; preds = %168, %132, %122, %110, %97, %87, %78, %66
%172 = load i8*, i8** %10
%173 = load i32, i32* %2
ret i32 %173
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@MAXPATHLEN = global i32 0
@errno = global i64 0
@ENOENT = global i64 0
@.str = [30 x i8] c"%s: master query: send error\0A\00"
@.str.1 = [33 x i8] c"%s: master query: receive error\0A\00"
@.str.2 = [39 x i8] c"%s: master query: wrong answer (type)\0A\00"
@.str.3 = [42 x i8] c"%s: master query: wrong answer (queryid)\0A\00"
@.str.4 = [8 x i8] c"%s: %s\0A\00"
@.str.5 = [5 x i8] c"%s:\0A\00"
define i32 @file_paths(i8* %0) {
%2 = alloca [16 x i32]
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.stat
%6 = alloca i32
%7 = bitcast [16 x i32]* %2 to i8*
%8 = bitcast i32** %3 to i8*
%9 = bitcast i32** %4 to i8*
%10 = bitcast %struct.stat* %5 to i8*
%11 = load i32, i32* @MAXPATHLEN
%12 = zext i32 %11 to i64
%13 = tail call i8* @llvm.stacksave()
%14 = alloca i8, i64 %12
%15 = bitcast i32* %6 to i8*
br label %16
16: ; preds = %16, %1
%17 = phi i8* [ %0, %1 ], [ %21, %16 ]
%18 = load i8, i8* %17
%19 = add i8 %18, -48
%20 = icmp ult i8 %19, 10
%21 = getelementptr inbounds i8, i8* %17, i64 1
br i1 %20, label %16, label %22
22: ; preds = %16
%23 = icmp eq i8 %18, 0
br i1 %23, label %24, label %36
24: ; preds = %22
%25 = call i64 @stat(i8* %0, %struct.stat* %5)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i64, i64* @errno
%29 = load i64, i64* @ENOENT
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = call i32 @strtoul(i8* nocapture %0, i32* null, i32 10)
%33 = load i32, i32* @MAXPATHLEN
%34 = call i8* @getcwd(i8* %14, i32 %33)
%35 = call i32 @open_master_conn(i8* %34, i32* %6, i32* null, i32* null, i32 0, i32 0)
store i32 %32, i32* %6
br label %38
36: ; preds = %27, %24, %22
%37 = call i32 @open_master_conn(i8* %0, i32* %6, i32* null, i32* null, i32 0, i32 0)
br label %38
38: ; preds = %36, %31
%39 = phi i32 [ %35, %31 ], [ %37, %36 ]
%40 = icmp slt i32 %39, 0
br i1 %40, label %114, label %41
41: ; preds = %38
%42 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
store i32* %42, i32** %3
%43 = call i32 @put32bit(i32** %3, i32 486)
%44 = call i32 @put32bit(i32** %3, i32 8)
%45 = call i32 @put32bit(i32** %3, i32 0)
%46 = load i32, i32* %6
%47 = call i32 @put32bit(i32** %3, i32 %46)
%48 = call i32 @tcptowrite(i32 %39, i32* %42, i32 16, i32 10000)
%49 = icmp eq i32 %48, 16
br i1 %49, label %53, label %50
50: ; preds = %41
%51 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0)
%52 = call i32 @close_master_conn(i32 1)
br label %114
53: ; preds = %41
%54 = call i32 @tcptoread(i32 %39, i32* %42, i32 8, i32 10000)
%55 = icmp eq i32 %54, 8
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%58 = call i32 @close_master_conn(i32 1)
br label %114
59: ; preds = %53
store i32* %42, i32** %4
%60 = call i32 @get32bit(i32** %4)
%61 = call i32 @get32bit(i32** %4)
%62 = icmp eq i32 %60, 487
br i1 %62, label %66, label %63
63: ; preds = %59
%64 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%65 = call i32 @close_master_conn(i32 1)
br label %114
66: ; preds = %59
%67 = call i32* @malloc(i32 %61)
%68 = call i32 @tcptoread(i32 %39, i32* %67, i32 %61, i32 10000)
%69 = icmp eq i32 %68, %61
br i1 %69, label %74, label %70
70: ; preds = %66
%71 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%72 = call i32 @free(i32* %67)
%73 = call i32 @close_master_conn(i32 1)
br label %114
74: ; preds = %66
%75 = call i32 @close_master_conn(i32 0)
store i32* %67, i32** %4
%76 = call i32 @get32bit(i32** %4)
%77 = icmp eq i32 %76, 0
br i1 %77, label %81, label %78
78: ; preds = %74
%79 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%80 = call i32 @free(i32* %67)
br label %114
81: ; preds = %74
%82 = add nsw i32 %61, -4
%83 = icmp eq i32 %82, 1
br i1 %83, label %84, label %90
84: ; preds = %81
%85 = load i32*, i32** %4
%86 = load i32, i32* %85
%87 = call i8* @mfsstrerr(i32 %86)
%88 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %87)
%89 = call i32 @free(i32* %67)
br label %114
90: ; preds = %81
%91 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%92 = icmp sgt i32 %61, 7
br i1 %92, label %93, label %112
93: ; preds = %90, %108
%94 = phi i32 [ %109, %108 ], [ %82, %90 ]
%95 = call i32 @get32bit(i32** %4)
%96 = add nsw i32 %94, -4
%97 = icmp slt i32 %96, %95
br i1 %97, label %112, label %98
98: ; preds = %93
%99 = icmp eq i32 %95, 0
br i1 %99, label %108, label %100
100: ; preds = %98, %100
%101 = phi i32 [ %104, %100 ], [ %95, %98 ]
%102 = call signext i8 @get8bit(i32** %4)
%103 = call i32 @putchar(i8 signext %102)
%104 = add nsw i32 %101, -1
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %100
106: ; preds = %100
%107 = sub i32 %96, %95
br label %108
108: ; preds = %98, %106
%109 = phi i32 [ %96, %98 ], [ %107, %106 ]
%110 = call i32 @putchar(i8 signext 10)
%111 = icmp sgt i32 %109, 3
br i1 %111, label %93, label %112
112: ; preds = %93, %108, %90
%113 = call i32 @free(i32* %67)
br label %114
114: ; preds = %38, %112, %84, %78, %70, %63, %56, %50
%115 = phi i32 [ -1, %50 ], [ -1, %56 ], [ -1, %63 ], [ -1, %70 ], [ -1, %78 ], [ -1, %84 ], [ 0, %112 ], [ -1, %38 ]
ret i32 %115
}