#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*/ _exit(int);
int execvp(char *, char **);
char *getpid();
int /*<<< orphan*/ unused(char *, char *);
__attribute__((noreturn)) void exec_socat(char *address) {
  char *args[4];
  args[0] = "socat";
  args[1] = "STDIO";
  args[2] = address;
  args[3] = NULL;
  do {
    unused("exec socat, pid=%i", getpid());
  } while (0);
  if (execvp(args[0], args) == -1) {
    do {
      unused("execvp(%s) failed", args[0]);
    } while (0);
    goto _fail;
  }
_fail:
  _exit(1);
}


x86 assembly (clang, -O0):
<exec_socat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,%rsi
lea    0xe89(%rip),%rdi
call   1050 <unused@plt>
mov    -0x30(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <execvp@plt>
cmp    $0xffffffff,%eax
jne    11b8 <exec_socat+0x78>
jmp    11a3 <exec_socat+0x63>
mov    -0x30(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1050 <unused@plt>
jmp    11bd <exec_socat+0x7d>
jmp    11bd <exec_socat+0x7d>
mov    $0x1,%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<exec_socat>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rbx
mov    %rbx,(%rsp)
lea    0xeaf(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %rdi,0x10(%rsp)
movq   $0x0,0x18(%rsp)
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe94(%rip),%rdi
mov    %rax,%rsi
call   1050 <unused@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <execvp@plt>
cmp    $0xffffffff,%eax
jne    11a0 <exec_socat+0x60>
mov    (%rsp),%rsi
lea    0xe84(%rip),%rdi
call   1050 <unused@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"socat\00"
@.str.1 = [6 x i8] c"STDIO\00"
@.str.2 = [19 x i8] c"exec socat, pid=%i\00"
@.str.3 = [18 x i8] c"execvp(%s) failed\00"
define void @exec_socat(i8* %0) {
%2 = alloca i8*
%3 = alloca [4 x i8*]
store i8* %0, i8** %2
%4 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = load i8*, i8** %2
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 2
store i8* %6, i8** %7
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 3
store i8* null, i8** %8
br label %9
9: ; preds = %1
%10 = call i8* (...) @getpid()
%11 = call i32 @unused(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%14 = load i8*, i8** %13
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%16 = call i32 @execvp(i8* %14, i8** %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %12
br label %19
19: ; preds = %18
%20 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @unused(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19
br label %25
24: ; preds = %12
br label %25
25: ; preds = %24, %23
%26 = call i32 @_exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"socat\00"
@.str.1 = [6 x i8] c"STDIO\00"
@.str.2 = [19 x i8] c"exec socat, pid=%i\00"
@.str.3 = [18 x i8] c"execvp(%s) failed\00"
define void @exec_socat(i8* %0) {
%2 = alloca [4 x i8*]
%3 = bitcast [4 x i8*]* %2 to i8*
%4 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 2
store i8* %0, i8** %6
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 3
store i8* null, i8** %7
%8 = tail call i8* (...) @getpid()
%9 = tail call i32 @unused(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = call i32 @execvp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %4
%14 = call i32 @unused(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %1, %12
%16 = call i32 @_exit(i32 1)
unreachable
}