#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 in_addr {
  int dummy;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execlp(char const *, char const *, int /*<<< orphan*/,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ inet_ntoa(struct in_addr);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ vfork();
void launch_callmgr(struct in_addr inetaddr, int argc, char **argv,
                    char **envp) {
  pid_t pid;
  int status;
  const char *callmgr = "/bin/pptp_callmgr";
  switch (pid = vfork()) {
  case -1:
    ({
      fprintf(stderr, "callmgr vfork failed: %s", strerror(errno));
      fprintf(stderr, "\n");
    });
    break;
  case 0: {
    execlp(callmgr, callmgr, inet_ntoa(inetaddr), NULL);
    ({
      fprintf(stderr, "execlp() of call manager [%s] failed: %s", callmgr,
              strerror(errno));
      fprintf(stderr, "\n");
    });
    exit(1);
  }
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<launch_callmgr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x30(%rbp)
call   1050 <vfork@plt>
mov    %eax,-0x24(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x3c(%rbp)
sub    $0xffffffff,%eax
je     11ac <launch_callmgr+0x4c>
jmp    119c <launch_callmgr+0x3c>
mov    -0x3c(%rbp),%eax
test   %eax,%eax
je     11f9 <launch_callmgr+0x99>
jmp    1282 <launch_callmgr+0x122>
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xe3f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    %eax,-0x34(%rbp)
jmp    1287 <launch_callmgr+0x127>
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <execlp@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    %eax,-0x38(%rbp)
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1287 <launch_callmgr+0x127>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<launch_callmgr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1050 <vfork@plt>
cmp    $0xffffffff,%eax
je     11e3 <launch_callmgr+0x83>
test   %eax,%eax
jne    1223 <launch_callmgr+0xc3>
mov    %ebx,%edi
call   1030 <inet_ntoa@plt>
lea    0xe77(%rip),%r14
xor    %ebx,%ebx
mov    %ebx,%ecx
mov    %r14,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1070 <execlp@plt>
mov    0x2e3f(%rip),%r15
mov    (%r15),%ebp
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe74(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
mov    %ebx,%eax
call   1040 <fprintf@plt>
mov    (%r15),%edi
lea    0xe59(%rip),%rsi
mov    %ebx,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2df6(%rip),%r14
mov    (%r14),%ebp
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe10(%rip),%rsi
xor    %ecx,%ecx
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %rax,%rdx
mov    %ecx,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xe0f(%rip),%rsi
mov    %ebx,%eax
call   1040 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [18 x i8] c"/bin/pptp_callmgr\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"callmgr vfork failed: %s\00"
@errno = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [41 x i8] c"execlp() of call manager [%s] failed: %s\00"
define void @launch_callmgr(i32 %0, i32 %1, i8** %2, i8** %3) {
%5 = alloca %struct.in_addr
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %5, i32 0, i32 0
store i32 %0, i32* %14
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %11
%15 = call i32 @vfork()
store i32 %15, i32* %9
switch i32 %15, label %40 [
i32 -1, label %16
i32 0, label %24
]
16: ; preds = %4
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = call i8* @strerror(i32 %18)
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 %22, i32* %12
%23 = load i32, i32* %12
br label %41
24: ; preds = %4
%25 = load i8*, i8** %11
%26 = load i8*, i8** %11
%27 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %5, i32 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 @inet_ntoa(i32 %28)
%30 = call i32 @execlp(i8* %25, i8* %26, i32 %29, i32* null)
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %11
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %32, i8* %34)
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 %37, i32* %13
%38 = load i32, i32* %13
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %4
br label %41
41: ; preds = %40, %16
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"/bin/pptp_callmgr\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"callmgr vfork failed: %s\00"
@errno = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [41 x i8] c"execlp() of call manager [%s] failed: %s\00"
define void @launch_callmgr(i32 %0, i32 %1, i8** nocapture readnone %2, i8** nocapture readnone %3) {
%5 = call i32 @vfork()
switch i32 %5, label %23 [
i32 -1, label %6
i32 0, label %13
]
6: ; preds = %4
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = call i8* @strerror(i32 %8)
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %23
13: ; preds = %4
%14 = call i32 @inet_ntoa(i32 %0)
%15 = call i32 @execlp(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %14, i32* null)
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %4, %6
ret void
}