#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*/ PF_IPX;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ SOCK_SEQPACKET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ maybe_sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ warn(char *);
int main(int argc, char *argv[]) {
  int delay, s;
  for (delay = 0; delay < 5; delay++) {
    s = socket(PF_IPX, SOCK_DGRAM, 0);
    if (s < 0)
      warn("socket(PF_IPX, SOCK_DGRAM, 0)");
    else {
      maybe_sleep(delay);
      close(s);
    }
    s = socket(PF_IPX, SOCK_STREAM, 0);
    if (s < 0)
      warn("socket(PF_IPX, SOCK_STREAM, 0)");
    else {
      maybe_sleep(delay);
      close(s);
    }
    s = socket(PF_IPX, SOCK_SEQPACKET, 0);
    if (s < 0)
      warn("socket(PF_IPX, SOCK_SEQPACKET, 0)");
    else {
      maybe_sleep(delay);
      close(s);
    }
    s = socket(PF_IPX, SOCK_RAW, 0);
    if (s < 0)
      warn("socket(PF_IPX, SOCK_RAW, 0)");
    else {
      maybe_sleep(delay);
      close(s);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    1296 <main+0x156>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    119e <main+0x5e>
lea    0xe6c(%rip),%rdi
call   1030 <warn@plt>
jmp    11ae <main+0x6e>
mov    -0x14(%rbp),%edi
call   1050 <maybe_sleep@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11e5 <main+0xa5>
lea    0xe43(%rip),%rdi
call   1030 <warn@plt>
jmp    11f5 <main+0xb5>
mov    -0x14(%rbp),%edi
call   1050 <maybe_sleep@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    122c <main+0xec>
lea    0xe1b(%rip),%rdi
call   1030 <warn@plt>
jmp    123c <main+0xfc>
mov    -0x14(%rbp),%edi
call   1050 <maybe_sleep@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1273 <main+0x133>
lea    0xdf6(%rip),%rdi
call   1030 <warn@plt>
jmp    1283 <main+0x143>
mov    -0x14(%rbp),%edi
call   1050 <maybe_sleep@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
jmp    1288 <main+0x148>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    0x2e8c(%rip),%r14
mov    0x2e6d(%rip),%r12
mov    0x2e5e(%rip),%r13
mov    0x2e7f(%rip),%r15
jmp    118c <main+0x4c>
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <maybe_sleep@plt>
mov    %ebp,%edi
call   1040 <close@plt>
add    $0x1,%ebx
cmp    $0x5,%ebx
je     1252 <main+0x112>
mov    (%r14),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
test   %eax,%eax
js     11c0 <main+0x80>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <maybe_sleep@plt>
mov    %ebp,%edi
call   1040 <close@plt>
jmp    11cc <main+0x8c>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe39(%rip),%rdi
call   1030 <warn@plt>
mov    (%r14),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   1060 <socket@plt>
test   %eax,%eax
js     11f0 <main+0xb0>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <maybe_sleep@plt>
mov    %ebp,%edi
call   1040 <close@plt>
jmp    11fc <main+0xbc>
lea    0xe27(%rip),%rdi
call   1030 <warn@plt>
mov    (%r14),%edi
mov    0x0(%r13),%esi
xor    %edx,%edx
call   1060 <socket@plt>
test   %eax,%eax
js     1220 <main+0xe0>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <maybe_sleep@plt>
mov    %ebp,%edi
call   1040 <close@plt>
jmp    122c <main+0xec>
lea    0xe16(%rip),%rdi
call   1030 <warn@plt>
mov    (%r14),%edi
mov    (%r15),%esi
xor    %edx,%edx
call   1060 <socket@plt>
test   %eax,%eax
jns    1170 <main+0x30>
lea    0xe17(%rip),%rdi
call   1030 <warn@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PF_IPX = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [30 x i8] c"socket(PF_IPX, SOCK_DGRAM, 0)\00"
@SOCK_STREAM = global i32 0
@.str.1 = [31 x i8] c"socket(PF_IPX, SOCK_STREAM, 0)\00"
@SOCK_SEQPACKET = global i32 0
@.str.2 = [34 x i8] c"socket(PF_IPX, SOCK_SEQPACKET, 0)\00"
@SOCK_RAW = global i32 0
@.str.3 = [28 x i8] c"socket(PF_IPX, SOCK_RAW, 0)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %64, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %67
11: ; preds = %8
%12 = load i32, i32* @PF_IPX
%13 = load i32, i32* @SOCK_DGRAM
%14 = call i32 @socket(i32 %12, i32 %13, i32 0)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @warn(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %24
19: ; preds = %11
%20 = load i32, i32* %6
%21 = call i32 @maybe_sleep(i32 %20)
%22 = load i32, i32* %7
%23 = call i32 @close(i32 %22)
br label %24
24: ; preds = %19, %17
%25 = load i32, i32* @PF_IPX
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @warn(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %37
32: ; preds = %24
%33 = load i32, i32* %6
%34 = call i32 @maybe_sleep(i32 %33)
%35 = load i32, i32* %7
%36 = call i32 @close(i32 %35)
br label %37
37: ; preds = %32, %30
%38 = load i32, i32* @PF_IPX
%39 = load i32, i32* @SOCK_SEQPACKET
%40 = call i32 @socket(i32 %38, i32 %39, i32 0)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 @warn(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %50
45: ; preds = %37
%46 = load i32, i32* %6
%47 = call i32 @maybe_sleep(i32 %46)
%48 = load i32, i32* %7
%49 = call i32 @close(i32 %48)
br label %50
50: ; preds = %45, %43
%51 = load i32, i32* @PF_IPX
%52 = load i32, i32* @SOCK_RAW
%53 = call i32 @socket(i32 %51, i32 %52, i32 0)
store i32 %53, i32* %7
%54 = load i32, i32* %7
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 @warn(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %63
58: ; preds = %50
%59 = load i32, i32* %6
%60 = call i32 @maybe_sleep(i32 %59)
%61 = load i32, i32* %7
%62 = call i32 @close(i32 %61)
br label %63
63: ; preds = %58, %56
br label %64
64: ; preds = %63
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %8
67: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@PF_IPX = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [30 x i8] c"socket(PF_IPX, SOCK_DGRAM, 0)\00"
@SOCK_STREAM = global i32 0
@.str.1 = [31 x i8] c"socket(PF_IPX, SOCK_STREAM, 0)\00"
@SOCK_SEQPACKET = global i32 0
@.str.2 = [34 x i8] c"socket(PF_IPX, SOCK_SEQPACKET, 0)\00"
@SOCK_RAW = global i32 0
@.str.3 = [28 x i8] c"socket(PF_IPX, SOCK_RAW, 0)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %44
%4 = phi i32 [ 0, %2 ], [ %45, %44 ]
%5 = load i32, i32* @PF_IPX
%6 = load i32, i32* @SOCK_DGRAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @warn(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %14
11: ; preds = %3
%12 = tail call i32 @maybe_sleep(i32 %4)
%13 = tail call i32 @close(i32 %7)
br label %14
14: ; preds = %11, %9
%15 = load i32, i32* @PF_IPX
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @warn(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %24
21: ; preds = %14
%22 = tail call i32 @maybe_sleep(i32 %4)
%23 = tail call i32 @close(i32 %17)
br label %24
24: ; preds = %21, %19
%25 = load i32, i32* @PF_IPX
%26 = load i32, i32* @SOCK_SEQPACKET
%27 = tail call i32 @socket(i32 %25, i32 %26, i32 0)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = tail call i32 @warn(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %34
31: ; preds = %24
%32 = tail call i32 @maybe_sleep(i32 %4)
%33 = tail call i32 @close(i32 %27)
br label %34
34: ; preds = %31, %29
%35 = load i32, i32* @PF_IPX
%36 = load i32, i32* @SOCK_RAW
%37 = tail call i32 @socket(i32 %35, i32 %36, i32 0)
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %34
%40 = tail call i32 @warn(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %44
41: ; preds = %34
%42 = tail call i32 @maybe_sleep(i32 %4)
%43 = tail call i32 @close(i32 %37)
br label %44
44: ; preds = %39, %41
%45 = add nuw nsw i32 %4, 1
%46 = icmp eq i32 %45, 5
br i1 %46, label %47, label %3
47: ; preds = %44
ret i32 0
}