#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 passwd {
  int dummy;
};

/* Variables and functions */
char *getenv(char *);
struct passwd *getpwnam(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int main(void) {
  struct passwd *pwd;
  char *domain = getenv("TEST_WORKGROUP");
  char long_name[65535];
  int failed = 0;
  sprintf(
      long_name, "%s/%s", domain,
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  pwd = getpwnam(long_name);
  printf("%s\n", !pwd ? "PASS" : "FAIL");
  return pwd == NULL;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10030,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10024(%rbp)
lea    -0x10020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe91(%rip),%rsi
lea    0xe90(%rip),%rcx
call   1060 <sprintf@plt>
lea    -0x10020(%rbp),%rdi
call   1050 <getpwnam@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %cl
xor    $0xff,%cl
lea    0x1673(%rip),%rsi
lea    0x1667(%rip),%rax
test   $0x1,%cl
cmovne %rax,%rsi
lea    0x1655(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10000,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <getenv@plt>
lea    0xeb4(%rip),%rsi
lea    0xeb3(%rip),%rcx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <getpwnam@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
lea    0x1693(%rip),%rax
lea    0x1691(%rip),%rsi
cmove  %rax,%rsi
lea    0x167d(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.passwd = type { i32 }
@.str = [15 x i8] c"TEST_WORKGROUP\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [2049 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [5 x i8] c"PASS\00"
@.str.5 = [5 x i8] c"FAIL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.passwd*
%3 = alloca i8*
%4 = alloca [65535 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
store i32 0, i32* %5
%7 = getelementptr inbounds [65535 x i8], [65535 x i8]* %4, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* getelementptr inbounds ([2049 x i8], [2049 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [65535 x i8], [65535 x i8]* %4, i64 0, i64 0
%11 = call %struct.passwd* @getpwnam(i8* %10)
store %struct.passwd* %11, %struct.passwd** %2
%12 = load %struct.passwd*, %struct.passwd** %2
%13 = icmp ne %struct.passwd* %12, null
%14 = xor i1 %13, true
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = load %struct.passwd*, %struct.passwd** %2
%19 = icmp eq %struct.passwd* %18, null
%20 = zext i1 %19 to i32
ret i32 %20
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@.str = [15 x i8] c"TEST_WORKGROUP\00"
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [2049 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [5 x i8] c"PASS\00"
@.str.5 = [5 x i8] c"FAIL\00"
define i32 @main() {
%1 = alloca [65535 x i8]
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [65535 x i8], [65535 x i8]* %1, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([2049 x i8], [2049 x i8]* @.str.2, i64 0, i64 0))
%5 = call %struct.passwd* @getpwnam(i8* %3)
%6 = icmp eq %struct.passwd* %5, null
%7 = select i1 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%9 = zext i1 %6 to i32
ret i32 %9
}