#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 */
struct statfs {
  scalar_t__ f_bfree;
};
struct stat {
  int dummy;
};
struct passwd {
  char *pw_dir;
  char *pw_name;
};

/* Variables and functions */
int EEXIST;
int chown(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ create_real_link(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getgid();
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int mkdir(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int snprintf(char *, int, char *, char *, ...);
int stat(char *, struct stat *);
scalar_t__ statfs(char *, struct statfs *);
int strlen(char *);
int symlink(char *, char *);
int main(int argc, char **argv) {
  struct passwd *pw;
  struct stat buf;
  int ret, printed;
  struct statfs user1, user2;
  char *realhome, *fakehome, nfsuser1[1024], nfsuser2[1024], errormsg[2048];
  pw = getpwuid(getuid());
  if ((ret = stat(pw->pw_dir, &buf)) == 0) {
    exit(1);
  }
  printed = snprintf(nfsuser1, 1024, "%s/%s", "/nfs/user1", pw->pw_name);
  if (printed < (strlen("/nfs/user1/") + strlen(pw->pw_name))) {
    printf("Problem constructing path %s (%d vs %ld) - please report to "
           "help@vpac.org !\n",
           nfsuser1, printed, (strlen("/nfs/user1/") + strlen(pw->pw_name)));
    exit(-1);
  }
  printed = snprintf(nfsuser2, 1024, "%s/%s", "/nfs/user2", pw->pw_name);
  if (printed < (strlen("/nfs/user2/") + strlen(pw->pw_name))) {
    printf("Problem constructing path %s (%d vs %ld) - please report to "
           "help@vpac.org !\n",
           nfsuser2, printed, (strlen("/nfs/user2/") + strlen(pw->pw_name)));
    exit(-1);
  }
  if (!stat(nfsuser1, &buf)) {
    printf(
        "Your home directory already exists, just creating the /home link\n");
    create_real_link(nfsuser1, pw->pw_dir);
    exit(3);
  }
  if (!stat(nfsuser2, &buf)) {
    printf(
        "Your home directory already exists, just creating the /home link\n");
    create_real_link(nfsuser2, pw->pw_dir);
    exit(3);
  }
  if (statfs("/nfs/user1", &user1)) {
    perror("statfs of /nfs/user1 failed - please report to help@vpac.org");
    exit(-1);
  }
  if (statfs("/nfs/user2", &user2)) {
    perror("statfs of /nfs/user2 failed - please report to help@vpac.org");
    exit(-1);
  }
  realhome = (user1.f_bfree > user2.f_bfree) ? nfsuser1 : nfsuser2;
  fakehome = (user1.f_bfree > user2.f_bfree) ? nfsuser2 : nfsuser1;
  ret = mkdir(realhome, 0777);
  if ((ret) && (ret != EEXIST)) {
    snprintf(errormsg, 2048,
             "Failed to create %s, please report to help@vpac.org", realhome);
    perror(errormsg);
    exit(-1);
  }
  ret = chown(realhome, -1, getgid());
  if (ret) {
    snprintf(errormsg, 2048,
             "Failed to set ownership of %s, please report to help@vpac.org",
             realhome);
    perror(errormsg);
    exit(-1);
  }
  create_real_link(realhome, pw->pw_dir);
  ret = symlink(realhome, fakehome);
  if (ret) {
    snprintf(
        errormsg, 2048,
        "Failed to make link from %s to %s, please report to help@vpac.org",
        fakehome, realhome);
    perror(errormsg);
    exit(-1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <getuid@plt>
mov    %eax,%edi
call   1050 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
call   10b0 <stat@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jne    1231 <main+0x51>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x450(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r8
mov    $0x400,%esi
lea    0xdb4(%rip),%rdx
lea    0xdb3(%rip),%rcx
mov    $0x0,%al
call   10a0 <snprintf@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x1054(%rbp)
lea    0xda4(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1058(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x1058(%rbp),%ecx
mov    %eax,%edx
mov    -0x1054(%rbp),%eax
add    %edx,%ecx
cmp    %ecx,%eax
jge    1300 <main+0x120>
lea    -0x450(%rbp),%rax
mov    %rax,-0x1068(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x105c(%rbp)
lea    0xd56(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x106c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x106c(%rbp),%ecx
mov    -0x1068(%rbp),%rsi
mov    -0x105c(%rbp),%edx
add    %eax,%ecx
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    -0x850(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r8
mov    $0x400,%esi
lea    0xce5(%rip),%rdx
lea    0xd48(%rip),%rcx
mov    $0x0,%al
call   10a0 <snprintf@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x1070(%rbp)
lea    0xd39(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1074(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x1074(%rbp),%ecx
mov    %eax,%edx
mov    -0x1070(%rbp),%eax
add    %edx,%ecx
cmp    %ecx,%eax
jge    13cf <main+0x1ef>
lea    -0x850(%rbp),%rax
mov    %rax,-0x1080(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x1078(%rbp)
lea    0xceb(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1084(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x1084(%rbp),%ecx
mov    -0x1080(%rbp),%rsi
mov    -0x1078(%rbp),%edx
add    %eax,%ecx
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    -0x450(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%eax
jne    1413 <main+0x233>
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x450(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <create_real_link@plt>
mov    $0x3,%edi
call   1100 <exit@plt>
lea    -0x850(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%eax
jne    1457 <main+0x277>
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x850(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <create_real_link@plt>
mov    $0x3,%edi
call   1100 <exit@plt>
lea    0xba8(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <statfs@plt>
cmp    $0x0,%rax
je     1487 <main+0x2a7>
lea    0xc4b(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
lea    0xbdc(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <statfs@plt>
cmp    $0x0,%rax
je     14b7 <main+0x2d7>
lea    0xc58(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jle    14d8 <main+0x2f8>
lea    -0x450(%rbp),%rax
mov    %rax,-0x1090(%rbp)
jmp    14e6 <main+0x306>
lea    -0x850(%rbp),%rax
mov    %rax,-0x1090(%rbp)
mov    -0x1090(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jle    1512 <main+0x332>
lea    -0x850(%rbp),%rax
mov    %rax,-0x1098(%rbp)
jmp    1520 <main+0x340>
lea    -0x450(%rbp),%rax
mov    %rax,-0x1098(%rbp)
mov    -0x1098(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     158c <main+0x3ac>
mov    -0x24(%rbp),%eax
mov    0x2a90(%rip),%rcx
cmp    (%rcx),%eax
je     158c <main+0x3ac>
lea    -0x1050(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0x800,%esi
lea    0xbce(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
lea    -0x1050(%rbp),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x10a0(%rbp)
mov    $0x0,%al
call   10c0 <getgid@plt>
mov    -0x10a0(%rbp),%rdi
mov    %eax,%edx
mov    $0xffffffff,%esi
call   10e0 <chown@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     15f2 <main+0x412>
lea    -0x1050(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0x800,%esi
lea    0xb9c(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
lea    -0x1050(%rbp),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1030 <create_real_link@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1090 <symlink@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1654 <main+0x474>
lea    -0x1050(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    $0x800,%esi
lea    0xb78(%rip),%rdx
mov    $0x0,%al
call   10a0 <snprintf@plt>
lea    -0x1050(%rbp),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>
xor    %edi,%edi
call   1100 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1020,%rsp
xor    %eax,%eax
call   1080 <getuid@plt>
mov    %eax,%edi
call   1060 <getpwuid@plt>
mov    %rax,%r12
mov    (%rax),%rdi
lea    0x8(%rsp),%rsi
call   10c0 <stat@plt>
test   %eax,%eax
jne    122b <main+0x3b>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x8(%r12),%r8
lea    0xdc9(%rip),%rdx
lea    0xdc8(%rip),%rcx
lea    0x420(%rsp),%rdi
mov    $0x400,%esi
xor    %eax,%eax
call   10b0 <snprintf@plt>
mov    %eax,%ebp
lea    0xdb6(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%r12),%rdi
call   1070 <strlen@plt>
add    %ebx,%eax
cmp    %eax,%ebp
jge    129d <main+0xad>
lea    0xd98(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%r12),%rdi
call   1070 <strlen@plt>
add    %eax,%ebx
lea    0xd8a(%rip),%rdi
lea    0x420(%rsp),%rsi
jmp    1307 <main+0x117>
mov    0x8(%r12),%r8
lea    0xd57(%rip),%rdx
lea    0xdba(%rip),%rcx
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
xor    %eax,%eax
call   10b0 <snprintf@plt>
mov    %eax,%ebp
lea    0xdab(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%r12),%rdi
call   1070 <strlen@plt>
add    %ebx,%eax
cmp    %eax,%ebp
jge    131c <main+0x12c>
lea    0xd8d(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%r12),%rdi
call   1070 <strlen@plt>
add    %eax,%ebx
lea    0xd1b(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
lea    0x420(%rsp),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   10c0 <stat@plt>
test   %eax,%eax
jne    134f <main+0x15f>
lea    0xe73(%rip),%rdi
call   1050 <puts@plt>
mov    (%r12),%rsi
lea    0x420(%rsp),%rdi
jmp    137a <main+0x18a>
lea    0x20(%rsp),%rbp
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   10c0 <stat@plt>
test   %eax,%eax
jne    1389 <main+0x199>
lea    0xe43(%rip),%rdi
call   1050 <puts@plt>
mov    (%r12),%rsi
lea    0x20(%rsp),%rdi
call   1030 <create_real_link@plt>
mov    $0x3,%edi
call   1110 <exit@plt>
lea    0xc76(%rip),%rdi
lea    0x18(%rsp),%rsi
call   10e0 <statfs@plt>
test   %rax,%rax
jne    13ef <main+0x1ff>
lea    0xcc4(%rip),%rdi
lea    0x10(%rsp),%rsi
call   10e0 <statfs@plt>
test   %rax,%rax
jne    13f8 <main+0x208>
mov    0x18(%rsp),%rax
cmp    0x10(%rsp),%rax
mov    %rbp,%r15
cmovg  %r14,%r15
cmovg  %rbp,%r14
mov    %r15,%rdi
mov    $0x1ff,%esi
call   1040 <mkdir@plt>
test   %eax,%eax
je     1401 <main+0x211>
mov    0x2bfe(%rip),%rcx
cmp    (%rcx),%eax
je     1401 <main+0x211>
lea    0xd0e(%rip),%rdx
jmp    1444 <main+0x254>
lea    0xc8b(%rip),%rdi
jmp    1461 <main+0x271>
lea    0xcbf(%rip),%rdi
jmp    1461 <main+0x271>
xor    %eax,%eax
call   10d0 <getgid@plt>
mov    %r15,%rdi
mov    $0xffffffff,%esi
mov    %eax,%edx
call   10f0 <chown@plt>
test   %eax,%eax
jne    143d <main+0x24d>
mov    (%r12),%rsi
mov    %r15,%rdi
call   1030 <create_real_link@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <symlink@plt>
test   %eax,%eax
jne    1470 <main+0x280>
xor    %edi,%edi
call   1110 <exit@plt>
lea    0xceb(%rip),%rdx
lea    0x820(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x800,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   10b0 <snprintf@plt>
mov    %rbx,%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
lea    0xcf6(%rip),%rdx
lea    0x820(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x800,%esi
mov    %r14,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   10b0 <snprintf@plt>
jmp    145e <main+0x26e>

LLVM IR (-O0):
%struct.passwd = type { i8*, i8* }
%struct.stat = type { i32 }
%struct.statfs = type { i64 }
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [11 x i8] c"/nfs/user1\00"
@.str.2 = [12 x i8] c"/nfs/user1/\00"
@.str.3 = [77 x i8] c"Problem constructing path %s (%d vs %ld) - please report to help@vpac.org !\0A\00"
@.str.4 = [11 x i8] c"/nfs/user2\00"
@.str.5 = [12 x i8] c"/nfs/user2/\00"
@.str.6 = [66 x i8] c"Your home directory already exists, just creating the /home link\0A\00"
@.str.7 = [61 x i8] c"statfs of /nfs/user1 failed - please report to help@vpac.org\00"
@.str.8 = [61 x i8] c"statfs of /nfs/user2 failed - please report to help@vpac.org\00"
@EEXIST = global i32 0
@.str.9 = [52 x i8] c"Failed to create %s, please report to help@vpac.org\00"
@.str.10 = [62 x i8] c"Failed to set ownership of %s, please report to help@vpac.org\00"
@.str.11 = [66 x i8] c"Failed to make link from %s to %s, please report to help@vpac.org\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.statfs
%11 = alloca %struct.statfs
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca [1024 x i8]
%15 = alloca [1024 x i8]
%16 = alloca [2048 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = call i32 (...) @getuid()
%18 = call %struct.passwd* @getpwuid(i32 %17)
store %struct.passwd* %18, %struct.passwd** %6
%19 = load %struct.passwd*, %struct.passwd** %6
%20 = getelementptr inbounds %struct.passwd, %struct.passwd* %19, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = call i32 @stat(i8* %21, %struct.stat* %7)
store i32 %22, i32* %8
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%28 = load %struct.passwd*, %struct.passwd** %6
%29 = getelementptr inbounds %struct.passwd, %struct.passwd* %28, i32 0, i32 1
%30 = load i8*, i8** %29
%31 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %27, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%34 = load %struct.passwd*, %struct.passwd** %6
%35 = getelementptr inbounds %struct.passwd, %struct.passwd* %34, i32 0, i32 1
%36 = load i8*, i8** %35
%37 = call i32 @strlen(i8* %36)
%38 = add nsw i32 %33, %37
%39 = icmp slt i32 %32, %38
br i1 %39, label %40, label %51
40: ; preds = %26
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%42 = load i32, i32* %9
%43 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%44 = load %struct.passwd*, %struct.passwd** %6
%45 = getelementptr inbounds %struct.passwd, %struct.passwd* %44, i32 0, i32 1
%46 = load i8*, i8** %45
%47 = call i32 @strlen(i8* %46)
%48 = add nsw i32 %43, %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), i8* %41, i32 %42, i32 %48)
%50 = call i32 @exit(i32 -1)
unreachable
51: ; preds = %26
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%53 = load %struct.passwd*, %struct.passwd** %6
%54 = getelementptr inbounds %struct.passwd, %struct.passwd* %53, i32 0, i32 1
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %52, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %55)
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%59 = load %struct.passwd*, %struct.passwd** %6
%60 = getelementptr inbounds %struct.passwd, %struct.passwd* %59, i32 0, i32 1
%61 = load i8*, i8** %60
%62 = call i32 @strlen(i8* %61)
%63 = add nsw i32 %58, %62
%64 = icmp slt i32 %57, %63
br i1 %64, label %65, label %76
65: ; preds = %51
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%67 = load i32, i32* %9
%68 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%69 = load %struct.passwd*, %struct.passwd** %6
%70 = getelementptr inbounds %struct.passwd, %struct.passwd* %69, i32 0, i32 1
%71 = load i8*, i8** %70
%72 = call i32 @strlen(i8* %71)
%73 = add nsw i32 %68, %72
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), i8* %66, i32 %67, i32 %73)
%75 = call i32 @exit(i32 -1)
unreachable
76: ; preds = %51
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%78 = call i32 @stat(i8* %77, %struct.stat* %7)
%79 = icmp ne i32 %78, 0
br i1 %79, label %88, label %80
80: ; preds = %76
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.6, i64 0, i64 0))
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%83 = load %struct.passwd*, %struct.passwd** %6
%84 = getelementptr inbounds %struct.passwd, %struct.passwd* %83, i32 0, i32 0
%85 = load i8*, i8** %84
%86 = call i32 @create_real_link(i8* %82, i8* %85)
%87 = call i32 @exit(i32 3)
unreachable
88: ; preds = %76
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%90 = call i32 @stat(i8* %89, %struct.stat* %7)
%91 = icmp ne i32 %90, 0
br i1 %91, label %100, label %92
92: ; preds = %88
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.6, i64 0, i64 0))
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%95 = load %struct.passwd*, %struct.passwd** %6
%96 = getelementptr inbounds %struct.passwd, %struct.passwd* %95, i32 0, i32 0
%97 = load i8*, i8** %96
%98 = call i32 @create_real_link(i8* %94, i8* %97)
%99 = call i32 @exit(i32 3)
unreachable
100: ; preds = %88
%101 = call i64 @statfs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %struct.statfs* %10)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %100
%104 = call i32 @perror(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
%105 = call i32 @exit(i32 -1)
unreachable
106: ; preds = %100
%107 = call i64 @statfs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), %struct.statfs* %11)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = call i32 @perror(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0))
%111 = call i32 @exit(i32 -1)
unreachable
112: ; preds = %106
%113 = getelementptr inbounds %struct.statfs, %struct.statfs* %10, i32 0, i32 0
%114 = load i64, i64* %113
%115 = getelementptr inbounds %struct.statfs, %struct.statfs* %11, i32 0, i32 0
%116 = load i64, i64* %115
%117 = icmp sgt i64 %114, %116
br i1 %117, label %118, label %120
118: ; preds = %112
%119 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
br label %122
120: ; preds = %112
%121 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
br label %122
122: ; preds = %120, %118
%123 = phi i8* [ %119, %118 ], [ %121, %120 ]
store i8* %123, i8** %12
%124 = getelementptr inbounds %struct.statfs, %struct.statfs* %10, i32 0, i32 0
%125 = load i64, i64* %124
%126 = getelementptr inbounds %struct.statfs, %struct.statfs* %11, i32 0, i32 0
%127 = load i64, i64* %126
%128 = icmp sgt i64 %125, %127
br i1 %128, label %129, label %131
129: ; preds = %122
%130 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
br label %133
131: ; preds = %122
%132 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
br label %133
133: ; preds = %131, %129
%134 = phi i8* [ %130, %129 ], [ %132, %131 ]
store i8* %134, i8** %13
%135 = load i8*, i8** %12
%136 = call i32 @mkdir(i8* %135, i32 511)
store i32 %136, i32* %8
%137 = load i32, i32* %8
%138 = icmp ne i32 %137, 0
br i1 %138, label %139, label %150
139: ; preds = %133
%140 = load i32, i32* %8
%141 = load i32, i32* @EEXIST
%142 = icmp ne i32 %140, %141
br i1 %142, label %143, label %150
143: ; preds = %139
%144 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%145 = load i8*, i8** %12
%146 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %144, i32 2048, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i8* %145)
%147 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%148 = call i32 @perror(i8* %147)
%149 = call i32 @exit(i32 -1)
unreachable
150: ; preds = %139, %133
%151 = load i8*, i8** %12
%152 = call i32 (...) @getgid()
%153 = call i32 @chown(i8* %151, i32 -1, i32 %152)
store i32 %153, i32* %8
%154 = load i32, i32* %8
%155 = icmp ne i32 %154, 0
br i1 %155, label %156, label %163
156: ; preds = %150
%157 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%158 = load i8*, i8** %12
%159 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %157, i32 2048, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.10, i64 0, i64 0), i8* %158)
%160 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%161 = call i32 @perror(i8* %160)
%162 = call i32 @exit(i32 -1)
unreachable
163: ; preds = %150
%164 = load i8*, i8** %12
%165 = load %struct.passwd*, %struct.passwd** %6
%166 = getelementptr inbounds %struct.passwd, %struct.passwd* %165, i32 0, i32 0
%167 = load i8*, i8** %166
%168 = call i32 @create_real_link(i8* %164, i8* %167)
%169 = load i8*, i8** %12
%170 = load i8*, i8** %13
%171 = call i32 @symlink(i8* %169, i8* %170)
store i32 %171, i32* %8
%172 = load i32, i32* %8
%173 = icmp ne i32 %172, 0
br i1 %173, label %174, label %182
174: ; preds = %163
%175 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%176 = load i8*, i8** %13
%177 = load i8*, i8** %12
%178 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %175, i32 2048, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.11, i64 0, i64 0), i8* %176, i8* %177)
%179 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%180 = call i32 @perror(i8* %179)
%181 = call i32 @exit(i32 -1)
unreachable
182: ; preds = %163
%183 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.statfs = type { i64 }
%struct.passwd = type { i8*, i8* }
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [11 x i8] c"/nfs/user1\00"
@.str.2 = [12 x i8] c"/nfs/user1/\00"
@.str.3 = [77 x i8] c"Problem constructing path %s (%d vs %ld) - please report to help@vpac.org !\0A\00"
@.str.4 = [11 x i8] c"/nfs/user2\00"
@.str.5 = [12 x i8] c"/nfs/user2/\00"
@.str.7 = [61 x i8] c"statfs of /nfs/user1 failed - please report to help@vpac.org\00"
@.str.8 = [61 x i8] c"statfs of /nfs/user2 failed - please report to help@vpac.org\00"
@EEXIST = global i32 0
@.str.9 = [52 x i8] c"Failed to create %s, please report to help@vpac.org\00"
@.str.10 = [62 x i8] c"Failed to set ownership of %s, please report to help@vpac.org\00"
@.str.11 = [66 x i8] c"Failed to make link from %s to %s, please report to help@vpac.org\00"
@str.12 = [65 x i8] c"Your home directory already exists, just creating the /home link\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.statfs
%5 = alloca %struct.statfs
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [2048 x i8]
%9 = bitcast %struct.stat* %3 to i8*
%10 = bitcast %struct.statfs* %4 to i8*
%11 = bitcast %struct.statfs* %5 to i8*
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %8, i64 0, i64 0
%15 = tail call i32 (...) @getuid()
%16 = tail call %struct.passwd* @getpwuid(i32 %15)
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %16, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = call i32 @stat(i8* %18, %struct.stat* %3)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = getelementptr inbounds %struct.passwd, %struct.passwd* %16, i64 0, i32 1
%25 = load i8*, i8** %24
%26 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %12, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%28 = load i8*, i8** %24
%29 = call i32 @strlen(i8* %28)
%30 = add nsw i32 %29, %27
%31 = icmp slt i32 %26, %30
br i1 %31, label %32, label %39
32: ; preds = %23
%33 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%34 = load i8*, i8** %24
%35 = call i32 @strlen(i8* %34)
%36 = add nsw i32 %35, %33
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), i8* %12, i32 %26, i32 %36)
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %23
%40 = load i8*, i8** %24
%41 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %13, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %40)
%42 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%43 = load i8*, i8** %24
%44 = call i32 @strlen(i8* %43)
%45 = add nsw i32 %44, %42
%46 = icmp slt i32 %41, %45
br i1 %46, label %47, label %54
47: ; preds = %39
%48 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%49 = load i8*, i8** %24
%50 = call i32 @strlen(i8* %49)
%51 = add nsw i32 %50, %48
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), i8* %13, i32 %41, i32 %51)
%53 = call i32 @exit(i32 -1)
unreachable
54: ; preds = %39
%55 = call i32 @stat(i8* %12, %struct.stat* %3)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.12, i64 0, i64 0))
%59 = load i8*, i8** %17
%60 = call i32 @create_real_link(i8* %12, i8* %59)
%61 = call i32 @exit(i32 3)
unreachable
62: ; preds = %54
%63 = call i32 @stat(i8* %13, %struct.stat* %3)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %62
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.12, i64 0, i64 0))
%67 = load i8*, i8** %17
%68 = call i32 @create_real_link(i8* %13, i8* %67)
%69 = call i32 @exit(i32 3)
unreachable
70: ; preds = %62
%71 = call i64 @statfs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %struct.statfs* %4)
%72 = icmp eq i64 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = call i32 @perror(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
%75 = call i32 @exit(i32 -1)
unreachable
76: ; preds = %70
%77 = call i64 @statfs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), %struct.statfs* %5)
%78 = icmp eq i64 %77, 0
br i1 %78, label %82, label %79
79: ; preds = %76
%80 = call i32 @perror(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0))
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %76
%83 = getelementptr inbounds %struct.statfs, %struct.statfs* %4, i64 0, i32 0
%84 = load i64, i64* %83
%85 = getelementptr inbounds %struct.statfs, %struct.statfs* %5, i64 0, i32 0
%86 = load i64, i64* %85
%87 = icmp sgt i64 %84, %86
%88 = select i1 %87, i8* %12, i8* %13
%89 = select i1 %87, i8* %13, i8* %12
%90 = call i32 @mkdir(i8* %88, i32 511)
%91 = icmp eq i32 %90, 0
%92 = load i32, i32* @EEXIST
%93 = icmp eq i32 %90, %92
%94 = select i1 %91, i1 true, i1 %93
br i1 %94, label %99, label %95
95: ; preds = %82
%96 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 2048, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i8* %88)
%97 = call i32 @perror(i8* %14)
%98 = call i32 @exit(i32 -1)
unreachable
99: ; preds = %82
%100 = call i32 (...) @getgid()
%101 = call i32 @chown(i8* %88, i32 -1, i32 %100)
%102 = icmp eq i32 %101, 0
br i1 %102, label %107, label %103
103: ; preds = %99
%104 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 2048, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.10, i64 0, i64 0), i8* %88)
%105 = call i32 @perror(i8* %14)
%106 = call i32 @exit(i32 -1)
unreachable
107: ; preds = %99
%108 = load i8*, i8** %17
%109 = call i32 @create_real_link(i8* %88, i8* %108)
%110 = call i32 @symlink(i8* %88, i8* %89)
%111 = icmp eq i32 %110, 0
br i1 %111, label %116, label %112
112: ; preds = %107
%113 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %14, i32 2048, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.11, i64 0, i64 0), i8* %89, i8* %88)
%114 = call i32 @perror(i8* %14)
%115 = call i32 @exit(i32 -1)
unreachable
116: ; preds = %107
%117 = call i32 @exit(i32 0)
unreachable
}