#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 atoi(char *);
int connect_to_pm(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *getenv(char *);
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int n, pmi_rank, pmi_port, pmi_sock;
  char *p, msg_to_send[1024], msg_recvd[1024], pmi_host_port[1024], kvsname[80];
  setbuf(stdout, NULL);
  pmi_rank = atoi(getenv("PMI_RANK"));
  strcpy(pmi_host_port, getenv("PMI_PORT"));
  printf("%d: pmi_rank=%d pmi_host_port=%s\n", getpid(), pmi_rank,
         pmi_host_port);
  p = strchr(pmi_host_port, ':');
  pmi_port = atoi(p + 1);
  *p = '\0';
  pmi_sock = connect_to_pm(pmi_host_port, pmi_port);
  if (argc > 1) {
    printf("%d: I must have been spawned with arg1=:%s:\n", getpid(), argv[1]);
    exit(0);
  }
  strcpy(msg_to_send, "cmd=init pmi_version=1 pmi_subversion=1\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent init\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  strcpy(msg_to_send, "cmd=get_maxes\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent get_maxes\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  strcpy(msg_to_send, "cmd=get_my_kvsname\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent get_my_kvsname\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  strcpy(kvsname, &msg_recvd[23]);
  kvsname[strlen(kvsname) - 1] = '\0';
  printf("kvsname = :%s:\n", kvsname);
  sprintf(msg_to_send, "cmd=put kvsname=%s key=ralph value=butler\n", kvsname);
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent key=ralph\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  strcpy(msg_to_send, "cmd=barrier_in\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent barrier_in\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  sprintf(msg_to_send, "cmd=get_universe_size\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent get for universe size\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  sprintf(msg_to_send, "cmd=get kvsname=%s key=ralph\n", kvsname);
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent get for key ralph\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  sprintf(msg_to_send, "cmd=publish_name service=rmb port=9999\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent publish_name\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  sprintf(msg_to_send, "cmd=lookup_name service=rmb\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent lookup_name\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  sprintf(msg_to_send, "cmd=unpublish_name service=rmb\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
  printf("sent unpublish_name\n");
  n = read(pmi_sock, msg_recvd, 1024);
  if (n >= 0)
    msg_recvd[n] = '\0';
  printf("%d: recvd msg=:%s:\n", pmi_rank, msg_recvd);
  strcpy(msg_to_send, "cmd=finalize\n");
  write(pmi_sock, msg_to_send, strlen(msg_to_send));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <setbuf@plt>
lea    0xdfe(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0xc30(%rbp),%rax
mov    %rax,-0xc88(%rbp)
lea    0xde2(%rip),%rdi
call   1030 <getenv@plt>
mov    -0xc88(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
mov    -0x18(%rbp),%edx
lea    -0xc30(%rbp),%rcx
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0xc30(%rbp),%rdi
mov    $0x3a,%esi
call   1090 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xc30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10d0 <connect_to_pm@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12ca <main+0xfa>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    -0x430(%rbp),%rdi
lea    0xd89(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xc94(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xc90(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xc94(%rbp),%edi
mov    -0xc90(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     134f <main+0x17f>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0xd34(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xca4(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xca0(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xca4(%rbp),%edi
mov    -0xca0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     13ec <main+0x21c>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0xc98(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0xcb6(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xcb4(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xcb0(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xcb4(%rbp),%edi
mov    -0xcb0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xc87(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1489 <main+0x2b9>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0xc80(%rbp),%rdi
lea    -0x830(%rbp),%rsi
add    $0x17,%rsi
call   1040 <strcpy@plt>
lea    -0xc80(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xc80(%rbp,%rax,1)
lea    -0xc80(%rbp),%rsi
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    -0xc80(%rbp),%rdx
lea    0xc06(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xcc4(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xcc0(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xcc4(%rbp),%edi
mov    -0xcc0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xbec(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1574 <main+0x3a4>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0xb10(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0xba2(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xcd4(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xcd0(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xcd4(%rbp),%edi
mov    -0xcd0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xb6f(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1611 <main+0x441>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0xa73(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0xb26(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xce4(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xce0(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xce4(%rbp),%edi
mov    -0xce0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xaf8(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     16b0 <main+0x4e0>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0x9d4(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    -0xc80(%rbp),%rdx
lea    0xab3(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xcf4(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xcf0(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xcf4(%rbp),%edi
mov    -0xcf0(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xa8c(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1756 <main+0x586>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0x92e(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0xa4a(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xd04(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xd00(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xd04(%rbp),%edi
mov    -0xd00(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0xa2d(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     17f5 <main+0x625>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0x88f(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0x9e6(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xd14(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xd10(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xd14(%rbp),%edi
mov    -0xd10(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0x9be(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1894 <main+0x6c4>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0x7f0(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0x976(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xd24(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xd20(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xd24(%rbp),%edi
mov    -0xd20(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    0x951(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0x400,%edx
call   10b0 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1933 <main+0x763>
movslq -0x14(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x18(%rbp),%esi
lea    -0x830(%rbp),%rdx
lea    0x751(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0x90c(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0xd34(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0xd30(%rbp)
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xd34(%rbp),%edi
mov    -0xd30(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x4(%rbp),%eax
add    $0xd40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc58,%rsp
mov    %rsi,%r14
mov    %edi,%r12d
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1090 <setbuf@plt>
lea    0xdf2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rdi
call   10d0 <atoi@plt>
mov    %eax,%r15d
lea    0xde4(%rip),%rdi
call   1030 <getenv@plt>
lea    0x850(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xdc7(%rip),%rdi
mov    %eax,%esi
mov    %r15d,%edx
mov    %rbp,%rcx
xor    %eax,%eax
call   10b0 <printf@plt>
mov    %rbp,%rdi
mov    $0x3a,%esi
call   10a0 <strchr@plt>
mov    %rax,%rbx
lea    0x1(%rax),%rdi
call   10d0 <atoi@plt>
movb   $0x0,(%rbx)
mov    %rbp,%rdi
mov    %eax,%esi
call   10e0 <connect_to_pm@plt>
cmp    $0x2,%r12d
jge    178f <main+0x5af>
mov    %eax,%r13d
lea    0xdcd(%rip),%rsi
lea    0x450(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xef4(%rip),%rdi
call   1050 <puts@plt>
lea    0x50(%rsp),%rsi
mov    %r13d,%edi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     12e2 <main+0x102>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xda1(%rip),%rdi
lea    0x50(%rsp),%r14
mov    %r15d,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0xd9c(%rip),%rsi
lea    0x450(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xe90(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     134e <main+0x16e>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xd35(%rip),%rdi
lea    0x50(%rsp),%r14
mov    %r15d,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0xd3f(%rip),%rsi
lea    0x450(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xe33(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     13ba <main+0x1da>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xcc9(%rip),%rdi
lea    0x50(%rsp),%r14
mov    %r15d,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0x67(%rsp),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xcc8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0xcc7(%rip),%rsi
lea    0x450(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xda6(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     145b <main+0x27b>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xc28(%rip),%rdi
lea    0x50(%rsp),%rbx
mov    %r15d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0xc81(%rip),%rsi
lea    0x450(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xd49(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     14c7 <main+0x2e7>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xbbc(%rip),%rdi
lea    0x50(%rsp),%rbx
mov    %r15d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
movabs $0xa657a69735f65,%rax
mov    %rax,0x45f(%rsp)
movups 0xc13(%rip),%xmm0
movaps %xmm0,0x450(%rsp)
lea    0x450(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xcdb(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     1545 <main+0x365>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xb3e(%rip),%rdi
lea    0x50(%rsp),%rbx
mov    %r15d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0xbbe(%rip),%rsi
lea    0x450(%rsp),%rbp
mov    %rsp,%rdx
mov    %rbp,%rdi
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xc85(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     15b6 <main+0x3d6>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xacd(%rip),%rdi
lea    0x50(%rsp),%rbx
mov    %r15d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
movabs $0xa393939393d74,%rax
mov    %rax,0x470(%rsp)
movups 0xb59(%rip),%xmm0
movaps %xmm0,0x450(%rsp)
movups 0xb5a(%rip),%xmm0
movaps %xmm0,0x460(%rsp)
lea    0x450(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xc0f(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     1643 <main+0x463>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0xa40(%rip),%rdi
lea    0x50(%rsp),%rbx
mov    %r15d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
movups 0xb06(%rip),%xmm0
movaps %xmm0,0x450(%rsp)
movups 0xb04(%rip),%xmm0
movups %xmm0,0x45d(%rsp)
lea    0x450(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xba6(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     16be <main+0x4de>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0x9c5(%rip),%rdi
lea    0x50(%rsp),%rbx
mov    %r15d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   10b0 <printf@plt>
movups 0xaa8(%rip),%xmm0
movaps %xmm0,0x450(%rsp)
movups 0xaa9(%rip),%xmm0
movaps %xmm0,0x460(%rsp)
lea    0x450(%rsp),%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
lea    0xb3c(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   10c0 <read@plt>
test   %eax,%eax
js     1739 <main+0x559>
mov    %eax,%eax
movb   $0x0,0x50(%rsp,%rax,1)
lea    0x94a(%rip),%rdi
lea    0x50(%rsp),%rdx
mov    %r15d,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
lea    0xa50(%rip),%rsi
lea    0x450(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <write@plt>
xor    %eax,%eax
add    $0xc58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1070 <getpid@plt>
mov    0x8(%r14),%rdx
lea    0x893(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [9 x i8] c"PMI_RANK\00"
@.str.1 = [9 x i8] c"PMI_PORT\00"
@.str.2 = [34 x i8] c"%d: pmi_rank=%d pmi_host_port=%s\0A\00"
@.str.3 = [45 x i8] c"%d: I must have been spawned with arg1=:%s:\0A\00"
@.str.4 = [41 x i8] c"cmd=init pmi_version=1 pmi_subversion=1\0A\00"
@.str.5 = [11 x i8] c"sent init\0A\00"
@.str.6 = [20 x i8] c"%d: recvd msg=:%s:\0A\00"
@.str.7 = [15 x i8] c"cmd=get_maxes\0A\00"
@.str.8 = [16 x i8] c"sent get_maxes\0A\00"
@.str.9 = [20 x i8] c"cmd=get_my_kvsname\0A\00"
@.str.10 = [21 x i8] c"sent get_my_kvsname\0A\00"
@.str.11 = [16 x i8] c"kvsname = :%s:\0A\00"
@.str.12 = [43 x i8] c"cmd=put kvsname=%s key=ralph value=butler\0A\00"
@.str.13 = [16 x i8] c"sent key=ralph\0A\00"
@.str.14 = [16 x i8] c"cmd=barrier_in\0A\00"
@.str.15 = [17 x i8] c"sent barrier_in\0A\00"
@.str.16 = [23 x i8] c"cmd=get_universe_size\0A\00"
@.str.17 = [28 x i8] c"sent get for universe size\0A\00"
@.str.18 = [30 x i8] c"cmd=get kvsname=%s key=ralph\0A\00"
@.str.19 = [24 x i8] c"sent get for key ralph\0A\00"
@.str.20 = [40 x i8] c"cmd=publish_name service=rmb port=9999\0A\00"
@.str.21 = [19 x i8] c"sent publish_name\0A\00"
@.str.22 = [29 x i8] c"cmd=lookup_name service=rmb\0A\00"
@.str.23 = [18 x i8] c"sent lookup_name\0A\00"
@.str.24 = [32 x i8] c"cmd=unpublish_name service=rmb\0A\00"
@.str.25 = [21 x i8] c"sent unpublish_name\0A\00"
@.str.26 = [14 x i8] c"cmd=finalize\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca [1024 x i8]
%12 = alloca [1024 x i8]
%13 = alloca [1024 x i8]
%14 = alloca [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* @stdout
%16 = call i32 @setbuf(i32 %15, i32* null)
%17 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %7
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%20 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = call i32 (...) @getpid()
%23 = load i32, i32* %7
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23, i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%27 = call i8* @strchr(i8* %26, i8 signext 58)
store i8* %27, i8** %10
%28 = load i8*, i8** %10
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %8
%31 = load i8*, i8** %10
store i8 0, i8* %31
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%33 = load i32, i32* %8
%34 = call i32 @connect_to_pm(i8* %32, i32 %33)
store i32 %34, i32* %9
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %44
37: ; preds = %2
%38 = call i32 (...) @getpid()
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %38, i8* %41)
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %2
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%46 = call i32 @strcpy(i8* %45, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* %9
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%50 = call i32 @strlen(i8* %49)
%51 = call i32 @write(i32 %47, i8* %48, i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32, i32* %9
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%55 = call i32 @read(i32 %53, i8* %54, i32 1024)
store i32 %55, i32* %6
%56 = load i32, i32* %6
%57 = icmp sge i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %44
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %60
store i8 0, i8* %61
br label %62
62: ; preds = %58, %44
%63 = load i32, i32* %7
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %63, i8* %64)
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%67 = call i32 @strcpy(i8* %66, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%68 = load i32, i32* %9
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%71 = call i32 @strlen(i8* %70)
%72 = call i32 @write(i32 %68, i8* %69, i32 %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%74 = load i32, i32* %9
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%76 = call i32 @read(i32 %74, i8* %75, i32 1024)
store i32 %76, i32* %6
%77 = load i32, i32* %6
%78 = icmp sge i32 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %62
%80 = load i32, i32* %6
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %81
store i8 0, i8* %82
br label %83
83: ; preds = %79, %62
%84 = load i32, i32* %7
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %84, i8* %85)
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%88 = call i32 @strcpy(i8* %87, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%89 = load i32, i32* %9
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%92 = call i32 @strlen(i8* %91)
%93 = call i32 @write(i32 %89, i8* %90, i32 %92)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%95 = load i32, i32* %9
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%97 = call i32 @read(i32 %95, i8* %96, i32 1024)
store i32 %97, i32* %6
%98 = load i32, i32* %6
%99 = icmp sge i32 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %83
%101 = load i32, i32* %6
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %102
store i8 0, i8* %103
br label %104
104: ; preds = %100, %83
%105 = load i32, i32* %7
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %105, i8* %106)
%108 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 23
%110 = call i32 @strcpy(i8* %108, i8* %109)
%111 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%112 = call i32 @strlen(i8* %111)
%113 = sub nsw i32 %112, 1
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 %114
store i8 0, i8* %115
%116 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* %116)
%118 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%119 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%120 = call i32 (i8*, i8*, ...) @sprintf(i8* %118, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8* %119)
%121 = load i32, i32* %9
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%124 = call i32 @strlen(i8* %123)
%125 = call i32 @write(i32 %121, i8* %122, i32 %124)
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
%127 = load i32, i32* %9
%128 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%129 = call i32 @read(i32 %127, i8* %128, i32 1024)
store i32 %129, i32* %6
%130 = load i32, i32* %6
%131 = icmp sge i32 %130, 0
br i1 %131, label %132, label %136
132: ; preds = %104
%133 = load i32, i32* %6
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %134
store i8 0, i8* %135
br label %136
136: ; preds = %132, %104
%137 = load i32, i32* %7
%138 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %137, i8* %138)
%140 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%141 = call i32 @strcpy(i8* %140, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
%142 = load i32, i32* %9
%143 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%144 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%145 = call i32 @strlen(i8* %144)
%146 = call i32 @write(i32 %142, i8* %143, i32 %145)
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.15, i64 0, i64 0))
%148 = load i32, i32* %9
%149 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%150 = call i32 @read(i32 %148, i8* %149, i32 1024)
store i32 %150, i32* %6
%151 = load i32, i32* %6
%152 = icmp sge i32 %151, 0
br i1 %152, label %153, label %157
153: ; preds = %136
%154 = load i32, i32* %6
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %155
store i8 0, i8* %156
br label %157
157: ; preds = %153, %136
%158 = load i32, i32* %7
%159 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %158, i8* %159)
%161 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%162 = call i32 (i8*, i8*, ...) @sprintf(i8* %161, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
%163 = load i32, i32* %9
%164 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%165 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%166 = call i32 @strlen(i8* %165)
%167 = call i32 @write(i32 %163, i8* %164, i32 %166)
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
%169 = load i32, i32* %9
%170 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%171 = call i32 @read(i32 %169, i8* %170, i32 1024)
store i32 %171, i32* %6
%172 = load i32, i32* %6
%173 = icmp sge i32 %172, 0
br i1 %173, label %174, label %178
174: ; preds = %157
%175 = load i32, i32* %6
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %176
store i8 0, i8* %177
br label %178
178: ; preds = %174, %157
%179 = load i32, i32* %7
%180 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %179, i8* %180)
%182 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%183 = getelementptr inbounds [80 x i8], [80 x i8]* %14, i64 0, i64 0
%184 = call i32 (i8*, i8*, ...) @sprintf(i8* %182, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i64 0, i64 0), i8* %183)
%185 = load i32, i32* %9
%186 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%187 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%188 = call i32 @strlen(i8* %187)
%189 = call i32 @write(i32 %185, i8* %186, i32 %188)
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.19, i64 0, i64 0))
%191 = load i32, i32* %9
%192 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%193 = call i32 @read(i32 %191, i8* %192, i32 1024)
store i32 %193, i32* %6
%194 = load i32, i32* %6
%195 = icmp sge i32 %194, 0
br i1 %195, label %196, label %200
196: ; preds = %178
%197 = load i32, i32* %6
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %198
store i8 0, i8* %199
br label %200
200: ; preds = %196, %178
%201 = load i32, i32* %7
%202 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %201, i8* %202)
%204 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%205 = call i32 (i8*, i8*, ...) @sprintf(i8* %204, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.20, i64 0, i64 0))
%206 = load i32, i32* %9
%207 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%208 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%209 = call i32 @strlen(i8* %208)
%210 = call i32 @write(i32 %206, i8* %207, i32 %209)
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.21, i64 0, i64 0))
%212 = load i32, i32* %9
%213 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%214 = call i32 @read(i32 %212, i8* %213, i32 1024)
store i32 %214, i32* %6
%215 = load i32, i32* %6
%216 = icmp sge i32 %215, 0
br i1 %216, label %217, label %221
217: ; preds = %200
%218 = load i32, i32* %6
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %219
store i8 0, i8* %220
br label %221
221: ; preds = %217, %200
%222 = load i32, i32* %7
%223 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %222, i8* %223)
%225 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%226 = call i32 (i8*, i8*, ...) @sprintf(i8* %225, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0))
%227 = load i32, i32* %9
%228 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%229 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%230 = call i32 @strlen(i8* %229)
%231 = call i32 @write(i32 %227, i8* %228, i32 %230)
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.23, i64 0, i64 0))
%233 = load i32, i32* %9
%234 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%235 = call i32 @read(i32 %233, i8* %234, i32 1024)
store i32 %235, i32* %6
%236 = load i32, i32* %6
%237 = icmp sge i32 %236, 0
br i1 %237, label %238, label %242
238: ; preds = %221
%239 = load i32, i32* %6
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %240
store i8 0, i8* %241
br label %242
242: ; preds = %238, %221
%243 = load i32, i32* %7
%244 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %243, i8* %244)
%246 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%247 = call i32 (i8*, i8*, ...) @sprintf(i8* %246, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.24, i64 0, i64 0))
%248 = load i32, i32* %9
%249 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%250 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%251 = call i32 @strlen(i8* %250)
%252 = call i32 @write(i32 %248, i8* %249, i32 %251)
%253 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.25, i64 0, i64 0))
%254 = load i32, i32* %9
%255 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%256 = call i32 @read(i32 %254, i8* %255, i32 1024)
store i32 %256, i32* %6
%257 = load i32, i32* %6
%258 = icmp sge i32 %257, 0
br i1 %258, label %259, label %263
259: ; preds = %242
%260 = load i32, i32* %6
%261 = sext i32 %260 to i64
%262 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %261
store i8 0, i8* %262
br label %263
263: ; preds = %259, %242
%264 = load i32, i32* %7
%265 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%266 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %264, i8* %265)
%267 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%268 = call i32 @strcpy(i8* %267, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.26, i64 0, i64 0))
%269 = load i32, i32* %9
%270 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%271 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%272 = call i32 @strlen(i8* %271)
%273 = call i32 @write(i32 %269, i8* %270, i32 %272)
%274 = load i32, i32* %3
ret i32 %274
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [9 x i8] c"PMI_RANK\00"
@.str.1 = [9 x i8] c"PMI_PORT\00"
@.str.2 = [34 x i8] c"%d: pmi_rank=%d pmi_host_port=%s\0A\00"
@.str.3 = [45 x i8] c"%d: I must have been spawned with arg1=:%s:\0A\00"
@.str.4 = [41 x i8] c"cmd=init pmi_version=1 pmi_subversion=1\0A\00"
@.str.6 = [20 x i8] c"%d: recvd msg=:%s:\0A\00"
@.str.7 = [15 x i8] c"cmd=get_maxes\0A\00"
@.str.9 = [20 x i8] c"cmd=get_my_kvsname\0A\00"
@.str.11 = [16 x i8] c"kvsname = :%s:\0A\00"
@.str.12 = [43 x i8] c"cmd=put kvsname=%s key=ralph value=butler\0A\00"
@.str.14 = [16 x i8] c"cmd=barrier_in\0A\00"
@.str.16 = [23 x i8] c"cmd=get_universe_size\0A\00"
@.str.18 = [30 x i8] c"cmd=get kvsname=%s key=ralph\0A\00"
@.str.20 = [40 x i8] c"cmd=publish_name service=rmb port=9999\0A\00"
@.str.22 = [29 x i8] c"cmd=lookup_name service=rmb\0A\00"
@.str.24 = [32 x i8] c"cmd=unpublish_name service=rmb\0A\00"
@.str.26 = [14 x i8] c"cmd=finalize\0A\00"
@str = [10 x i8] c"sent init\00"
@str.27 = [15 x i8] c"sent get_maxes\00"
@str.28 = [20 x i8] c"sent get_my_kvsname\00"
@str.29 = [15 x i8] c"sent key=ralph\00"
@str.30 = [16 x i8] c"sent barrier_in\00"
@str.31 = [27 x i8] c"sent get for universe size\00"
@str.32 = [23 x i8] c"sent get for key ralph\00"
@str.33 = [18 x i8] c"sent publish_name\00"
@str.34 = [17 x i8] c"sent lookup_name\00"
@str.35 = [20 x i8] c"sent unpublish_name\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [80 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* @stdout
%12 = tail call i32 @setbuf(i32 %11, i32* null)
%13 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @atoi(i8* %13)
%15 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @strcpy(i8* %9, i8* %15)
%17 = call i32 (...) @getpid()
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %14, i8* %9)
%19 = call i8* @strchr(i8* %9, i8 signext 58)
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i32 @atoi(i8* %20)
store i8 0, i8* %19
%22 = call i32 @connect_to_pm(i8* %9, i32 %21)
%23 = icmp sgt i32 %0, 1
br i1 %23, label %24, label %30
24: ; preds = %2
%25 = call i32 (...) @getpid()
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %25, i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %2
%31 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 @strlen(i8* %7)
%33 = call i32 @write(i32 %22, i8* %7, i32 %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%35 = call i32 @read(i32 %22, i8* %8, i32 1024)
%36 = icmp sgt i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = zext i32 %35 to i64
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %37, %30
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%42 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%43 = call i32 @strlen(i8* %7)
%44 = call i32 @write(i32 %22, i8* %7, i32 %43)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.27, i64 0, i64 0))
%46 = call i32 @read(i32 %22, i8* %8, i32 1024)
%47 = icmp sgt i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %40
%49 = zext i32 %46 to i64
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %49
store i8 0, i8* %50
br label %51
51: ; preds = %48, %40
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%53 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%54 = call i32 @strlen(i8* %7)
%55 = call i32 @write(i32 %22, i8* %7, i32 %54)
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.28, i64 0, i64 0))
%57 = call i32 @read(i32 %22, i8* %8, i32 1024)
%58 = icmp sgt i32 %57, -1
br i1 %58, label %59, label %62
59: ; preds = %51
%60 = zext i32 %57 to i64
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %60
store i8 0, i8* %61
br label %62
62: ; preds = %59, %51
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 23
%65 = call i32 @strcpy(i8* %10, i8* %64)
%66 = call i32 @strlen(i8* %10)
%67 = add nsw i32 %66, -1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 %68
store i8 0, i8* %69
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* %10)
%71 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8* %10)
%72 = call i32 @strlen(i8* %7)
%73 = call i32 @write(i32 %22, i8* %7, i32 %72)
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.29, i64 0, i64 0))
%75 = call i32 @read(i32 %22, i8* %8, i32 1024)
%76 = icmp sgt i32 %75, -1
br i1 %76, label %77, label %80
77: ; preds = %62
%78 = zext i32 %75 to i64
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %78
store i8 0, i8* %79
br label %80
80: ; preds = %77, %62
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%82 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
%83 = call i32 @strlen(i8* %7)
%84 = call i32 @write(i32 %22, i8* %7, i32 %83)
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.30, i64 0, i64 0))
%86 = call i32 @read(i32 %22, i8* %8, i32 1024)
%87 = icmp sgt i32 %86, -1
br i1 %87, label %88, label %91
88: ; preds = %80
%89 = zext i32 %86 to i64
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %89
store i8 0, i8* %90
br label %91
91: ; preds = %88, %80
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%93 = call i32 @strlen(i8* %7)
%94 = call i32 @write(i32 %22, i8* %7, i32 %93)
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.31, i64 0, i64 0))
%96 = call i32 @read(i32 %22, i8* %8, i32 1024)
%97 = icmp sgt i32 %96, -1
br i1 %97, label %98, label %101
98: ; preds = %91
%99 = zext i32 %96 to i64
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %99
store i8 0, i8* %100
br label %101
101: ; preds = %98, %91
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%103 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i64 0, i64 0), i8* %10)
%104 = call i32 @strlen(i8* %7)
%105 = call i32 @write(i32 %22, i8* %7, i32 %104)
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.32, i64 0, i64 0))
%107 = call i32 @read(i32 %22, i8* %8, i32 1024)
%108 = icmp sgt i32 %107, -1
br i1 %108, label %109, label %112
109: ; preds = %101
%110 = zext i32 %107 to i64
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %110
store i8 0, i8* %111
br label %112
112: ; preds = %109, %101
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%114 = call i32 @strlen(i8* %7)
%115 = call i32 @write(i32 %22, i8* %7, i32 %114)
%116 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.33, i64 0, i64 0))
%117 = call i32 @read(i32 %22, i8* %8, i32 1024)
%118 = icmp sgt i32 %117, -1
br i1 %118, label %119, label %122
119: ; preds = %112
%120 = zext i32 %117 to i64
%121 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %120
store i8 0, i8* %121
br label %122
122: ; preds = %119, %112
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%124 = call i32 @strlen(i8* %7)
%125 = call i32 @write(i32 %22, i8* %7, i32 %124)
%126 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.34, i64 0, i64 0))
%127 = call i32 @read(i32 %22, i8* %8, i32 1024)
%128 = icmp sgt i32 %127, -1
br i1 %128, label %129, label %132
129: ; preds = %122
%130 = zext i32 %127 to i64
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %130
store i8 0, i8* %131
br label %132
132: ; preds = %129, %122
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%134 = call i32 @strlen(i8* %7)
%135 = call i32 @write(i32 %22, i8* %7, i32 %134)
%136 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.35, i64 0, i64 0))
%137 = call i32 @read(i32 %22, i8* %8, i32 1024)
%138 = icmp sgt i32 %137, -1
br i1 %138, label %139, label %142
139: ; preds = %132
%140 = zext i32 %137 to i64
%141 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %140
store i8 0, i8* %141
br label %142
142: ; preds = %139, %132
%143 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %14, i8* %8)
%144 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.26, i64 0, i64 0))
%145 = call i32 @strlen(i8* %7)
%146 = call i32 @write(i32 %22, i8* %7, i32 %145)
ret i32 0
}