#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 SOCK_DGRAM;
int SOCK_STREAM;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
int socketopen(int, int, char *, char *, char *);
int /*<<< orphan*/ stderr;
int str2mode(char const *);
scalar_t__ strncmp(char *, char *, int);
long strtol(char *, char **, int);
unsigned long strtoul(char *, char **, int);
scalar_t__ usleep(long);
int devopen(const char *name, const char *mode) {
  int openfd;
  char *cp;
  char *ptr;
  int flag = 0;
  int len;
  int family;
  int protocol;
  char *hostname;
  char *hostnameslastcharp;
  char *localpname;
  char *localpnamelastcharp;
  flag = str2mode(mode);
  openfd = (-1);
  len = 6;
  cp = (char *)name + len;
  if (strncmp(cp, "tcp/", 4) == 0)
    protocol = SOCK_STREAM;
  else if (strncmp(cp, "udp/", 4) == 0)
    protocol = SOCK_DGRAM;
  else {
    protocol = SOCK_STREAM;
    fprintf(stderr, "no (known) protocol supplied in special filename `%s'",
            name);
    exit(1);
  }
  cp += 4;
  localpname = cp;
  while (*cp != '/' && *cp != '\0')
    cp++;
  if (*cp != '/' || cp == localpname) {
    fprintf(stderr, "special file name `%s' is incomplete", name);
    exit(1);
  }
  *cp = '\0';
  localpnamelastcharp = cp;
  cp++;
  hostname = cp;
  while (*cp != '/' && *cp != '\0')
    cp++;
  if (*cp != '/' || cp == hostname) {
    *localpnamelastcharp = '/';
    fprintf(stderr, "must supply a remote hostname to `/inet'");
    exit(1);
  }
  *cp = '\0';
  hostnameslastcharp = cp;
  cp++;
  if (*cp == '\0') {
    *localpnamelastcharp = '/';
    *hostnameslastcharp = '/';
    fprintf(stderr, "must supply a remote port to `/inet'");
    exit(1);
  }
  {
    static unsigned long def_retries = 20;
    static bool first_time = true;
    unsigned long retries = 0;
    static long msleep = 1000;
    if (first_time) {
      char *cp, *end;
      unsigned long count = 0;
      char *ms2;
      first_time = false;
      if ((cp = getenv("GAWK_SOCK_RETRIES")) != NULL) {
        count = strtoul(cp, &end, 10);
        if (end != cp && count > 0)
          def_retries = count;
      }
      if ((ms2 = getenv("GAWK_MSEC_SLEEP")) != NULL) {
        msleep = strtol(ms2, &end, 10);
        if (end == ms2 || msleep < 0)
          msleep = 1000;
        else
          msleep *= 1000;
      }
    }
    retries = def_retries;
    do {
      openfd = socketopen(family, protocol, localpname, cp, hostname);
      retries--;
    } while (openfd == (-1) && retries > 0 && usleep(msleep) == 0);
  }
  *localpnamelastcharp = '/';
  *hostnameslastcharp = '/';
  return openfd;
}


x86 assembly (clang, -O0):
<devopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <str2mode@plt>
mov    %eax,-0x2c(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x6,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe22(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1203 <devopen+0x73>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    1269 <devopen+0xd9>
mov    -0x20(%rbp),%rdi
lea    0xdf7(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1233 <devopen+0xa3>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
jmp    1264 <devopen+0xd4>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdb7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1269 <devopen+0xd9>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x81(%rbp)
je     12a8 <devopen+0x118>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    12bb <devopen+0x12b>
jmp    12cc <devopen+0x13c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    127d <devopen+0xed>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12ea <devopen+0x15a>
mov    -0x20(%rbp),%rax
cmp    -0x50(%rbp),%rax
jne    130f <devopen+0x17f>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2f,%ecx
mov    %al,-0x82(%rbp)
je     135d <devopen+0x1cd>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x82(%rbp)
mov    -0x82(%rbp),%al
test   $0x1,%al
jne    1370 <devopen+0x1e0>
jmp    1381 <devopen+0x1f1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1332 <devopen+0x1a2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    139f <devopen+0x20f>
mov    -0x20(%rbp),%rax
cmp    -0x40(%rbp),%rax
jne    13c7 <devopen+0x237>
mov    -0x58(%rbp),%rax
movb   $0x2f,(%rax)
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1421 <devopen+0x291>
mov    -0x58(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x48(%rbp),%rax
movb   $0x2f,(%rax)
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movq   $0x0,-0x60(%rbp)
cmpl   $0x0,0x2c40(%rip)
je     151c <devopen+0x38c>
movq   $0x0,-0x78(%rbp)
movl   $0x0,0x2c28(%rip)
lea    0xc64(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
je     14a1 <devopen+0x311>
mov    -0x68(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
cmp    -0x68(%rbp),%rax
je     149c <devopen+0x30c>
cmpq   $0x0,-0x78(%rbp)
jbe    149c <devopen+0x30c>
mov    -0x78(%rbp),%rax
mov    %rax,0x2bcc(%rip)
jmp    14a1 <devopen+0x311>
lea    0xc1d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x80(%rbp)
cmp    $0x0,%rax
je     1517 <devopen+0x387>
mov    -0x80(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,0x2ba4(%rip)
mov    -0x70(%rbp),%rax
cmp    -0x80(%rbp),%rax
je     14f0 <devopen+0x360>
cmpq   $0x0,0x2b8e(%rip)
jge    1500 <devopen+0x370>
movq   $0x3e8,0x2b7d(%rip)
jmp    1512 <devopen+0x382>
imul   $0x3e8,0x2b6d(%rip),%rax
mov    %rax,0x2b66(%rip)
jmp    1517 <devopen+0x387>
jmp    151c <devopen+0x38c>
mov    0x2b45(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0x50(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x40(%rbp),%r8
call   10a0 <socketopen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x60(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x60(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x14(%rbp)
mov    %al,-0x83(%rbp)
jne    158b <devopen+0x3fb>
xor    %eax,%eax
cmpq   $0x0,-0x60(%rbp)
mov    %al,-0x83(%rbp)
jbe    158b <devopen+0x3fb>
mov    0x2aff(%rip),%rdi
call   10b0 <usleep@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x83(%rbp)
mov    -0x83(%rbp),%al
test   $0x1,%al
jne    1527 <devopen+0x397>
mov    -0x58(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x48(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x14(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<devopen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <str2mode@plt>
lea    0x6(%rbx),%rbp
lea    0xe4f(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11e9 <devopen+0x59>
lea    0xe3b(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    13c5 <devopen+0x235>
mov    0x2e01(%rip),%rax
jmp    11f0 <devopen+0x60>
mov    0x2de0(%rip),%rax
mov    (%rax),%r14d
lea    0xa(%rbx),%r15
lea    0xc(%rbx),%r12
xor    %eax,%eax
nopl   (%rax)
movzbl -0x2(%r12),%ecx
test   %cl,%cl
je     1219 <devopen+0x89>
cmp    $0x2f,%cl
je     1219 <devopen+0x89>
add    $0x1,%r12
add    $0xffffffffffffffff,%rax
jmp    1200 <devopen+0x70>
cmp    $0x2f,%cl
jne    1370 <devopen+0x1e0>
test   %rax,%rax
je     1370 <devopen+0x1e0>
movb   $0x0,-0x2(%r12)
lea    -0x1(%r12),%r13
xor    %eax,%eax
mov    %r12,%rbp
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbp),%ecx
test   %cl,%cl
je     1257 <devopen+0xc7>
cmp    $0x2f,%cl
je     1257 <devopen+0xc7>
add    $0x1,%rbp
add    $0xffffffffffffffff,%rax
jmp    1240 <devopen+0xb0>
cmp    $0x2f,%cl
jne    1382 <devopen+0x1f2>
test   %rax,%rax
je     1382 <devopen+0x1f2>
movb   $0x0,-0x1(%rbp)
cmpb   $0x0,0x0(%rbp)
je     139a <devopen+0x20a>
cmpb   $0x0,0x2e0a(%rip)
jne    1307 <devopen+0x177>
movb   $0x1,0x2dfd(%rip)
lea    0xe21(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     12c1 <devopen+0x131>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1080 <strtoul@plt>
cmp    %rbx,(%rsp)
je     12c1 <devopen+0x131>
test   %rax,%rax
je     12c1 <devopen+0x131>
mov    %rax,0x2da7(%rip)
lea    0xdfd(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1307 <devopen+0x177>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1070 <strtol@plt>
imul   $0x3e8,%rax,%rcx
test   %rax,%rax
mov    $0x3e8,%eax
cmovs  %rax,%rcx
cmp    %rbx,(%rsp)
cmove  %rax,%rcx
mov    %rcx,0x2d69(%rip)
mov    0x2d5a(%rip),%rbx
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14d,%esi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %r13,%r8
call   10a0 <socketopen@plt>
add    $0xffffffffffffffff,%rbx
setb   %cl
cmp    $0xffffffff,%eax
jne    1357 <devopen+0x1c7>
test   %cl,%cl
je     1357 <devopen+0x1c7>
mov    0x2d28(%rip),%rdi
call   10b0 <usleep@plt>
test   %rax,%rax
je     1320 <devopen+0x190>
mov    $0xffffffff,%eax
movb   $0x2f,-0x2(%r12)
movb   $0x2f,-0x1(%rbp)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
lea    0xcc0(%rip),%rsi
jmp    13d5 <devopen+0x245>
movb   $0x2f,-0x2(%r12)
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
lea    0xccd(%rip),%rsi
jmp    13b4 <devopen+0x224>
movb   $0x2f,-0x2(%r12)
movb   $0x2f,-0x1(%rbp)
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
lea    0xcda(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"tcp/\00"
@SOCK_STREAM = global i32 0
@.str.1 = [5 x i8] c"udp/\00"
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str.2 = [54 x i8] c"no (known) protocol supplied in special filename `%s'\00"
@.str.3 = [37 x i8] c"special file name `%s' is incomplete\00"
@.str.4 = [41 x i8] c"must supply a remote hostname to `/inet'\00"
@.str.5 = [37 x i8] c"must supply a remote port to `/inet'\00"
@devopen.def_retries = internal global i64 20
@devopen.first_time = internal global i32 1
@devopen.msleep = internal global i64 1000
@.str.6 = [18 x i8] c"GAWK_SOCK_RETRIES\00"
@.str.7 = [16 x i8] c"GAWK_MSEC_SLEEP\00"
define i32 @devopen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %8
%21 = load i8*, i8** %4
%22 = call i32 @str2mode(i8* %21)
store i32 %22, i32* %8
store i32 -1, i32* %5
store i32 6, i32* %9
%23 = load i8*, i8** %3
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %2
%31 = load i32, i32* @SOCK_STREAM
store i32 %31, i32* %11
br label %45
32: ; preds = %2
%33 = load i8*, i8** %6
%34 = call i64 @strncmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* @SOCK_DGRAM
store i32 %37, i32* %11
br label %44
38: ; preds = %32
%39 = load i32, i32* @SOCK_STREAM
store i32 %39, i32* %11
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %3
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %36
br label %45
45: ; preds = %44, %30
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i64 4
store i8* %47, i8** %6
%48 = load i8*, i8** %6
store i8* %48, i8** %14
br label %49
49: ; preds = %61, %45
%50 = load i8*, i8** %6
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 47
br i1 %53, label %54, label %59
54: ; preds = %49
%55 = load i8*, i8** %6
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br label %59
59: ; preds = %54, %49
%60 = phi i1 [ false, %49 ], [ %58, %54 ]
br i1 %60, label %61, label %64
61: ; preds = %59
%62 = load i8*, i8** %6
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %6
br label %49
64: ; preds = %59
%65 = load i8*, i8** %6
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %67, 47
br i1 %68, label %73, label %69
69: ; preds = %64
%70 = load i8*, i8** %6
%71 = load i8*, i8** %14
%72 = icmp eq i8* %70, %71
br i1 %72, label %73, label %78
73: ; preds = %69, %64
%74 = load i32, i32* @stderr
%75 = load i8*, i8** %3
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %75)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %69
%79 = load i8*, i8** %6
store i8 0, i8* %79
%80 = load i8*, i8** %6
store i8* %80, i8** %15
%81 = load i8*, i8** %6
%82 = getelementptr inbounds i8, i8* %81, i32 1
store i8* %82, i8** %6
%83 = load i8*, i8** %6
store i8* %83, i8** %12
br label %84
84: ; preds = %96, %78
%85 = load i8*, i8** %6
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %87, 47
br i1 %88, label %89, label %94
89: ; preds = %84
%90 = load i8*, i8** %6
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp ne i32 %92, 0
br label %94
94: ; preds = %89, %84
%95 = phi i1 [ false, %84 ], [ %93, %89 ]
br i1 %95, label %96, label %99
96: ; preds = %94
%97 = load i8*, i8** %6
%98 = getelementptr inbounds i8, i8* %97, i32 1
store i8* %98, i8** %6
br label %84
99: ; preds = %94
%100 = load i8*, i8** %6
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = icmp ne i32 %102, 47
br i1 %103, label %108, label %104
104: ; preds = %99
%105 = load i8*, i8** %6
%106 = load i8*, i8** %12
%107 = icmp eq i8* %105, %106
br i1 %107, label %108, label %113
108: ; preds = %104, %99
%109 = load i8*, i8** %15
store i8 47, i8* %109
%110 = load i32, i32* @stderr
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %104
%114 = load i8*, i8** %6
store i8 0, i8* %114
%115 = load i8*, i8** %6
store i8* %115, i8** %13
%116 = load i8*, i8** %6
%117 = getelementptr inbounds i8, i8* %116, i32 1
store i8* %117, i8** %6
%118 = load i8*, i8** %6
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = icmp eq i32 %120, 0
br i1 %121, label %122, label %128
122: ; preds = %113
%123 = load i8*, i8** %15
store i8 47, i8* %123
%124 = load i8*, i8** %13
store i8 47, i8* %124
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%127 = call i32 @exit(i32 1)
unreachable
128: ; preds = %113
store i64 0, i64* %16
%129 = load i32, i32* @devopen.first_time
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %164
131: ; preds = %128
store i64 0, i64* %19
store i32 0, i32* @devopen.first_time
%132 = call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
store i8* %132, i8** %17
%133 = icmp ne i8* %132, null
br i1 %133, label %134, label %146
134: ; preds = %131
%135 = load i8*, i8** %17
%136 = call i64 @strtoul(i8* %135, i8** %18, i32 10)
store i64 %136, i64* %19
%137 = load i8*, i8** %18
%138 = load i8*, i8** %17
%139 = icmp ne i8* %137, %138
br i1 %139, label %140, label %145
140: ; preds = %134
%141 = load i64, i64* %19
%142 = icmp ugt i64 %141, 0
br i1 %142, label %143, label %145
143: ; preds = %140
%144 = load i64, i64* %19
store i64 %144, i64* @devopen.def_retries
br label %145
145: ; preds = %143, %140, %134
br label %146
146: ; preds = %145, %131
%147 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
store i8* %147, i8** %20
%148 = icmp ne i8* %147, null
br i1 %148, label %149, label %163
149: ; preds = %146
%150 = load i8*, i8** %20
%151 = call i64 @strtol(i8* %150, i8** %18, i32 10)
store i64 %151, i64* @devopen.msleep
%152 = load i8*, i8** %18
%153 = load i8*, i8** %20
%154 = icmp eq i8* %152, %153
br i1 %154, label %158, label %155
155: ; preds = %149
%156 = load i64, i64* @devopen.msleep
%157 = icmp slt i64 %156, 0
br i1 %157, label %158, label %159
158: ; preds = %155, %149
store i64 1000, i64* @devopen.msleep
br label %162
159: ; preds = %155
%160 = load i64, i64* @devopen.msleep
%161 = mul nsw i64 %160, 1000
store i64 %161, i64* @devopen.msleep
br label %162
162: ; preds = %159, %158
br label %163
163: ; preds = %162, %146
br label %164
164: ; preds = %163, %128
%165 = load i64, i64* @devopen.def_retries
store i64 %165, i64* %16
br label %166
166: ; preds = %185, %164
%167 = load i32, i32* %10
%168 = load i32, i32* %11
%169 = load i8*, i8** %14
%170 = load i8*, i8** %6
%171 = load i8*, i8** %12
%172 = call i32 @socketopen(i32 %167, i32 %168, i8* %169, i8* %170, i8* %171)
store i32 %172, i32* %5
%173 = load i64, i64* %16
%174 = add i64 %173, -1
store i64 %174, i64* %16
br label %175
175: ; preds = %166
%176 = load i32, i32* %5
%177 = icmp eq i32 %176, -1
br i1 %177, label %178, label %185
178: ; preds = %175
%179 = load i64, i64* %16
%180 = icmp ugt i64 %179, 0
br i1 %180, label %181, label %185
181: ; preds = %178
%182 = load i64, i64* @devopen.msleep
%183 = call i64 @usleep(i64 %182)
%184 = icmp eq i64 %183, 0
br label %185
185: ; preds = %181, %178, %175
%186 = phi i1 [ false, %178 ], [ false, %175 ], [ %184, %181 ]
br i1 %186, label %166, label %187
187: ; preds = %185
%188 = load i8*, i8** %15
store i8 47, i8* %188
%189 = load i8*, i8** %13
store i8 47, i8* %189
%190 = load i32, i32* %5
ret i32 %190
}

LLVM IR (-O2):
@.str = [5 x i8] c"tcp/\00"
@SOCK_STREAM = global i32 0
@.str.1 = [5 x i8] c"udp/\00"
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str.2 = [54 x i8] c"no (known) protocol supplied in special filename `%s'\00"
@.str.3 = [37 x i8] c"special file name `%s' is incomplete\00"
@.str.4 = [41 x i8] c"must supply a remote hostname to `/inet'\00"
@.str.5 = [37 x i8] c"must supply a remote port to `/inet'\00"
@devopen.def_retries = internal unnamed_addr global i64 20
@devopen.first_time = internal unnamed_addr global i1 false
@devopen.msleep = internal unnamed_addr global i64 1000
@.str.6 = [18 x i8] c"GAWK_SOCK_RETRIES\00"
@.str.7 = [16 x i8] c"GAWK_MSEC_SLEEP\00"
define i32 @devopen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = tail call i32 @str2mode(i8* %1)
%5 = getelementptr inbounds i8, i8* %0, i64 6
%6 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %8, %2
%16 = phi i32* [ @SOCK_STREAM, %2 ], [ @SOCK_DGRAM, %8 ]
%17 = load i32, i32* %16
%18 = getelementptr inbounds i8, i8* %0, i64 10
br label %19
19: ; preds = %23, %15
%20 = phi i64 [ 10, %15 ], [ %24, %23 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
switch i8 %22, label %23 [
i8 47, label %25
i8 0, label %25
]
23: ; preds = %19
%24 = add nuw nsw i64 %20, 1
br label %19
25: ; preds = %19, %19
%26 = getelementptr inbounds i8, i8* %0, i64 %20
%27 = icmp ne i8 %22, 47
%28 = icmp eq i64 %20, 10
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %25
store i8 0, i8* %26
%35 = getelementptr inbounds i8, i8* %26, i64 1
br label %36
36: ; preds = %40, %34
%37 = phi i64 [ 1, %34 ], [ %41, %40 ]
%38 = getelementptr inbounds i8, i8* %26, i64 %37
%39 = load i8, i8* %38
switch i8 %39, label %40 [
i8 47, label %42
i8 0, label %42
]
40: ; preds = %36
%41 = add nuw nsw i64 %37, 1
br label %36
42: ; preds = %36, %36
%43 = getelementptr inbounds i8, i8* %26, i64 %37
%44 = icmp ne i8 %39, 47
%45 = icmp eq i64 %37, 1
%46 = select i1 %44, i1 true, i1 %45
br i1 %46, label %47, label %51
47: ; preds = %42
store i8 47, i8* %26
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%50 = tail call i32 @exit(i32 1)
unreachable
51: ; preds = %42
store i8 0, i8* %43
%52 = getelementptr inbounds i8, i8* %43, i64 1
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %51
store i8 47, i8* %26
store i8 47, i8* %43
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%58 = tail call i32 @exit(i32 1)
unreachable
59: ; preds = %51
%60 = load i1, i1* @devopen.first_time
br i1 %60, label %84, label %61
61: ; preds = %59
%62 = bitcast i8** %3 to i8*
store i1 true, i1* @devopen.first_time
%63 = tail call i8* @getenv(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%64 = icmp eq i8* %63, null
br i1 %64, label %72, label %65
65: ; preds = %61
%66 = call i64 @strtoul(i8* %63, i8** %3, i32 10)
%67 = load i8*, i8** %3
%68 = icmp ne i8* %67, %63
%69 = icmp ne i64 %66, 0
%70 = select i1 %68, i1 %69, i1 false
br i1 %70, label %71, label %72
71: ; preds = %65
store i64 %66, i64* @devopen.def_retries
br label %72
72: ; preds = %65, %71, %61
%73 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%74 = icmp eq i8* %73, null
br i1 %74, label %83, label %75
75: ; preds = %72
%76 = call i64 @strtol(i8* %73, i8** %3, i32 10)
%77 = load i8*, i8** %3
%78 = icmp eq i8* %77, %73
%79 = icmp slt i64 %76, 0
%80 = select i1 %78, i1 true, i1 %79
%81 = mul nsw i64 %76, 1000
%82 = select i1 %80, i64 1000, i64 %81
store i64 %82, i64* @devopen.msleep
br label %83
83: ; preds = %75, %72
br label %84
84: ; preds = %83, %59
%85 = load i64, i64* @devopen.def_retries
br label %86
86: ; preds = %93, %84
%87 = phi i64 [ %85, %84 ], [ %89, %93 ]
%88 = tail call i32 @socketopen(i32 undef, i32 %17, i8* %18, i8* %52, i8* %35)
%89 = add i64 %87, -1
%90 = icmp eq i32 %88, -1
%91 = icmp ne i64 %89, 0
%92 = select i1 %90, i1 %91, i1 false
br i1 %92, label %93, label %97
93: ; preds = %86
%94 = load i64, i64* @devopen.msleep
%95 = tail call i64 @usleep(i64 %94)
%96 = icmp eq i64 %95, 0
br i1 %96, label %86, label %97
97: ; preds = %86, %93
%98 = phi i32 [ %88, %86 ], [ -1, %93 ]
store i8 47, i8* %26
store i8 47, i8* %43
ret i32 %98
}