#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 */

/* Variables and functions */
int /*<<< orphan*/ child(char *);
scalar_t__ fork();
char *getenv(char *);
int /*<<< orphan*/ mq_unlink(char *);
int /*<<< orphan*/ parent(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char **argv) {
  char mqname[256];
  char *user = getenv("USER");
  sprintf(mqname, "/dmtcp-mq-%s", user == NULL ? "" : user);
  mq_unlink(mqname);
  if (fork() == 0) {
    child(mqname);
  } else {
    parent(mqname);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x120(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    11bb <main+0x5b>
lea    0xe55(%rip),%rax
mov    %rax,-0x128(%rbp)
jmp    11c9 <main+0x69>
mov    -0x118(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rdx
lea    0xe27(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1070 <mq_unlink@plt>
mov    $0x0,%al
call   1080 <fork@plt>
cmp    $0x0,%rax
jne    1211 <main+0xb1>
lea    -0x110(%rbp),%rdi
call   1040 <child@plt>
jmp    121d <main+0xbd>
lea    -0x110(%rbp),%rdi
call   1050 <parent@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xe91(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xe86(%rip),%rdx
cmovne %rax,%rdx
lea    0xe7c(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <mq_unlink@plt>
xor    %eax,%eax
call   1080 <fork@plt>
mov    %rsp,%rdi
test   %rax,%rax
je     11b2 <main+0x52>
call   1050 <parent@plt>
jmp    11b7 <main+0x57>
call   1040 <child@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"USER\00"
@.str.1 = [13 x i8] c"/dmtcp-mq-%s\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %7
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%10 = load i8*, i8** %7
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
br label %15
13: ; preds = %2
%14 = load i8*, i8** %7
br label %15
15: ; preds = %13, %12
%16 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %12 ], [ %14, %13 ]
%17 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%19 = call i32 @mq_unlink(i8* %18)
%20 = call i64 (...) @fork()
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%24 = call i32 @child(i8* %23)
br label %28
25: ; preds = %15
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%27 = call i32 @parent(i8* %26)
br label %28
28: ; preds = %25, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"USER\00"
@.str.1 = [13 x i8] c"/dmtcp-mq-%s\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %5
%8 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 @mq_unlink(i8* %4)
%10 = call i64 (...) @fork()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @child(i8* %4)
br label %16
14: ; preds = %2
%15 = call i32 @parent(i8* %4)
br label %16
16: ; preds = %14, %12
ret i32 0
}