#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 IPPROTO_ICMP;
int IPPROTO_IP;
int IPPROTO_TCP;
int IPPROTO_UDP;
int PF_INET;
int PF_LOCAL;
int SOCK_DGRAM;
int SOCK_STREAM;
int /*<<< orphan*/ close(int);
int socket(int, int, int);
int main() {
  int s;
  s = socket(PF_LOCAL, SOCK_STREAM, 0);
  close(s);
  socket(0, SOCK_STREAM, 0);
  socket(PF_INET, 75, IPPROTO_IP);
  s = socket(PF_LOCAL, SOCK_DGRAM, 0);
  close(s);
  s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
  close(s);
  s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  close(s);
  socket(PF_INET, SOCK_STREAM, IPPROTO_UDP);
  socket(PF_INET, SOCK_DGRAM, IPPROTO_TCP);
  s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  close(s);
  socket(PF_INET, SOCK_STREAM, IPPROTO_ICMP);
  socket(-1, SOCK_STREAM, IPPROTO_IP);
  socket(PF_INET, -1, IPPROTO_IP);
  socket(PF_INET, 0, IPPROTO_IP);
  socket(PF_INET, SOCK_STREAM, -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    %edx,%edi
call   1040 <socket@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
mov    $0x4b,%esi
call   1040 <socket@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    0x2e23(%rip),%rax
mov    (%rax),%esi
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
mov    0x2db7(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
mov    0x2db5(%rip),%rax
mov    (%rax),%esi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
mov    0x2dac(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
mov    0x2d75(%rip),%rax
mov    (%rax),%esi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
mov    0x2d51(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    0x2d33(%rip),%rax
mov    (%rax),%esi
mov    0x2d52(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
call   1040 <socket@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
mov    0x2d36(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1040 <socket@plt>
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
mov    0x2d1a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <socket@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
mov    0x2cd9(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edx
call   1040 <socket@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2e80(%rip),%r12
mov    (%r12),%edi
mov    0x2e85(%rip),%r14
mov    (%r14),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,%edi
call   1030 <close@plt>
mov    (%r14),%esi
xor    %edi,%edi
xor    %edx,%edx
call   1040 <socket@plt>
mov    0x2e59(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2e7e(%rip),%r15
mov    (%r15),%edx
mov    $0x4b,%esi
call   1040 <socket@plt>
mov    (%r12),%edi
mov    0x2e56(%rip),%r12
mov    (%r12),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,%edi
call   1030 <close@plt>
mov    0x0(%r13),%edi
mov    (%r12),%esi
mov    (%r15),%edx
call   1040 <socket@plt>
mov    %eax,%edi
call   1030 <close@plt>
mov    0x0(%r13),%edi
mov    (%r12),%esi
mov    0x2de6(%rip),%rbx
mov    (%rbx),%edx
call   1040 <socket@plt>
mov    %eax,%edi
call   1030 <close@plt>
mov    0x0(%r13),%edi
mov    (%r14),%esi
mov    (%rbx),%edx
call   1040 <socket@plt>
mov    0x0(%r13),%edi
mov    (%r12),%esi
mov    0x2dfb(%rip),%rbx
mov    (%rbx),%edx
call   1040 <socket@plt>
mov    0x0(%r13),%edi
mov    (%r14),%esi
mov    (%rbx),%edx
call   1040 <socket@plt>
mov    %eax,%edi
call   1030 <close@plt>
mov    0x0(%r13),%edi
mov    (%r14),%esi
mov    0x2dc1(%rip),%rax
mov    (%rax),%edx
call   1040 <socket@plt>
mov    (%r14),%esi
mov    (%r15),%edx
mov    $0xffffffff,%edi
call   1040 <socket@plt>
mov    0x0(%r13),%edi
mov    (%r15),%edx
mov    $0xffffffff,%esi
call   1040 <socket@plt>
mov    0x0(%r13),%edi
mov    (%r15),%edx
xor    %esi,%esi
call   1040 <socket@plt>
mov    0x0(%r13),%edi
mov    (%r14),%esi
mov    $0xffffffff,%edx
call   1040 <socket@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PF_LOCAL = global i32 0
@SOCK_STREAM = global i32 0
@PF_INET = global i32 0
@IPPROTO_IP = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@IPPROTO_TCP = global i32 0
@IPPROTO_ICMP = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @PF_LOCAL
%4 = load i32, i32* @SOCK_STREAM
%5 = call i32 @socket(i32 %3, i32 %4, i32 0)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @close(i32 %6)
%8 = load i32, i32* @SOCK_STREAM
%9 = call i32 @socket(i32 0, i32 %8, i32 0)
%10 = load i32, i32* @PF_INET
%11 = load i32, i32* @IPPROTO_IP
%12 = call i32 @socket(i32 %10, i32 75, i32 %11)
%13 = load i32, i32* @PF_LOCAL
%14 = load i32, i32* @SOCK_DGRAM
%15 = call i32 @socket(i32 %13, i32 %14, i32 0)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = call i32 @close(i32 %16)
%18 = load i32, i32* @PF_INET
%19 = load i32, i32* @SOCK_DGRAM
%20 = load i32, i32* @IPPROTO_IP
%21 = call i32 @socket(i32 %18, i32 %19, i32 %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* @PF_INET
%25 = load i32, i32* @SOCK_DGRAM
%26 = load i32, i32* @IPPROTO_UDP
%27 = call i32 @socket(i32 %24, i32 %25, i32 %26)
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = call i32 @close(i32 %28)
%30 = load i32, i32* @PF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = load i32, i32* @IPPROTO_UDP
%33 = call i32 @socket(i32 %30, i32 %31, i32 %32)
%34 = load i32, i32* @PF_INET
%35 = load i32, i32* @SOCK_DGRAM
%36 = load i32, i32* @IPPROTO_TCP
%37 = call i32 @socket(i32 %34, i32 %35, i32 %36)
%38 = load i32, i32* @PF_INET
%39 = load i32, i32* @SOCK_STREAM
%40 = load i32, i32* @IPPROTO_TCP
%41 = call i32 @socket(i32 %38, i32 %39, i32 %40)
store i32 %41, i32* %2
%42 = load i32, i32* %2
%43 = call i32 @close(i32 %42)
%44 = load i32, i32* @PF_INET
%45 = load i32, i32* @SOCK_STREAM
%46 = load i32, i32* @IPPROTO_ICMP
%47 = call i32 @socket(i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* @SOCK_STREAM
%49 = load i32, i32* @IPPROTO_IP
%50 = call i32 @socket(i32 -1, i32 %48, i32 %49)
%51 = load i32, i32* @PF_INET
%52 = load i32, i32* @IPPROTO_IP
%53 = call i32 @socket(i32 %51, i32 -1, i32 %52)
%54 = load i32, i32* @PF_INET
%55 = load i32, i32* @IPPROTO_IP
%56 = call i32 @socket(i32 %54, i32 0, i32 %55)
%57 = load i32, i32* @PF_INET
%58 = load i32, i32* @SOCK_STREAM
%59 = call i32 @socket(i32 %57, i32 %58, i32 -1)
ret i32 0
}

LLVM IR (-O2):
@PF_LOCAL = global i32 0
@SOCK_STREAM = global i32 0
@PF_INET = global i32 0
@IPPROTO_IP = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@IPPROTO_TCP = global i32 0
@IPPROTO_ICMP = global i32 0
define i32 @main() {
%1 = load i32, i32* @PF_LOCAL
%2 = load i32, i32* @SOCK_STREAM
%3 = tail call i32 @socket(i32 %1, i32 %2, i32 0)
%4 = tail call i32 @close(i32 %3)
%5 = load i32, i32* @SOCK_STREAM
%6 = tail call i32 @socket(i32 0, i32 %5, i32 0)
%7 = load i32, i32* @PF_INET
%8 = load i32, i32* @IPPROTO_IP
%9 = tail call i32 @socket(i32 %7, i32 75, i32 %8)
%10 = load i32, i32* @PF_LOCAL
%11 = load i32, i32* @SOCK_DGRAM
%12 = tail call i32 @socket(i32 %10, i32 %11, i32 0)
%13 = tail call i32 @close(i32 %12)
%14 = load i32, i32* @PF_INET
%15 = load i32, i32* @SOCK_DGRAM
%16 = load i32, i32* @IPPROTO_IP
%17 = tail call i32 @socket(i32 %14, i32 %15, i32 %16)
%18 = tail call i32 @close(i32 %17)
%19 = load i32, i32* @PF_INET
%20 = load i32, i32* @SOCK_DGRAM
%21 = load i32, i32* @IPPROTO_UDP
%22 = tail call i32 @socket(i32 %19, i32 %20, i32 %21)
%23 = tail call i32 @close(i32 %22)
%24 = load i32, i32* @PF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = load i32, i32* @IPPROTO_UDP
%27 = tail call i32 @socket(i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* @PF_INET
%29 = load i32, i32* @SOCK_DGRAM
%30 = load i32, i32* @IPPROTO_TCP
%31 = tail call i32 @socket(i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* @PF_INET
%33 = load i32, i32* @SOCK_STREAM
%34 = load i32, i32* @IPPROTO_TCP
%35 = tail call i32 @socket(i32 %32, i32 %33, i32 %34)
%36 = tail call i32 @close(i32 %35)
%37 = load i32, i32* @PF_INET
%38 = load i32, i32* @SOCK_STREAM
%39 = load i32, i32* @IPPROTO_ICMP
%40 = tail call i32 @socket(i32 %37, i32 %38, i32 %39)
%41 = load i32, i32* @SOCK_STREAM
%42 = load i32, i32* @IPPROTO_IP
%43 = tail call i32 @socket(i32 -1, i32 %41, i32 %42)
%44 = load i32, i32* @PF_INET
%45 = load i32, i32* @IPPROTO_IP
%46 = tail call i32 @socket(i32 %44, i32 -1, i32 %45)
%47 = load i32, i32* @PF_INET
%48 = load i32, i32* @IPPROTO_IP
%49 = tail call i32 @socket(i32 %47, i32 0, i32 %48)
%50 = load i32, i32* @PF_INET
%51 = load i32, i32* @SOCK_STREAM
%52 = tail call i32 @socket(i32 %50, i32 %51, i32 -1)
ret i32 0
}