#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ val;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_DEBUG;
int /*<<< orphan*/ SO_RCVBUF;
int /*<<< orphan*/ SO_SNDBUF;
int bind(int, struct sockaddr *, int);
int errno;
int /*<<< orphan*/ exit(int);
int getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
char *strerror(int);
int main() {
  int sock = 0, ret = 0, val = 0;
  struct sockaddr_in sin5;
  sin5.sin_family = AF_INET;
  sin5.sin_addr.s_addr = inet_addr("10.151.12.112");
  sin5.sin_port = htons(10292);
  sock = socket(AF_INET, SOCK_STREAM, 0);
  if (sock == -1) {
    perror("socket failed");
    exit(-1);
  }
  ret = bind(sock, (struct sockaddr *)&sin5, sizeof(struct sockaddr_in));
  if (ret == -1) {
    perror("bind failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
    exit(-1);
  }
  val = 0;
  ret = setsockopt(sock, SOL_SOCKET, SO_DEBUG, &val, sizeof(val));
  if (ret == -1) {
    perror("set failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
    exit(-1);
  }
  int val_size = 100;
  val = -1;
  ret = getsockopt(sock, SOL_SOCKET, SO_DEBUG, &val, &val_size);
  if (ret == -1) {
    perror("get failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
    exit(-1);
  }
  printf("val = %d\n", val);
  val = 1;
  ret = setsockopt(sock, SOL_SOCKET, SO_DEBUG, &val, sizeof(val));
  if (ret == -1) {
    perror("set2 failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
  }
  val = 128;
  ret = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
  if (ret == -1) {
    perror("set failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
    exit(-1);
  }
  val_size = 100;
  val = -1;
  ret = getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &val, &val_size);
  if (ret == -1) {
    perror("get failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
  }
  printf("SNDBUF val = %d\n", val);
  val = 128;
  ret = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val));
  if (ret == -1) {
    perror("set failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
  }
  val_size = 100;
  val = -1;
  ret = getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &val, &val_size);
  if (ret == -1) {
    perror("get failed");
    printf("errno = %d(%s)\n", errno, strerror(errno));
  }
  printf("REVBUF val = %d\n", val);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    0xe29(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x2834,%edi
call   1040 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1228 <main+0x88>
lea    0xdf5(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1080 <bind@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    128a <main+0xea>
lea    0xdcf(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x28(%rbp),%esi
mov    %rax,%rdx
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
mov    0x2d2c(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1306 <main+0x166>
lea    0xd6f(%rip),%rdi
call   1090 <perror@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x2c(%rbp),%esi
mov    %rax,%rdx
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x64,-0x24(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
mov    0x2ca9(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1060 <getsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1387 <main+0x1e7>
lea    0xcf9(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x30(%rbp),%esi
mov    %rax,%rdx
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%esi
lea    0xcd0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2c3f(%rip),%rax
mov    (%rax),%esi
mov    0x2c1e(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    140a <main+0x26a>
lea    0xc77(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2bc1(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x34(%rbp),%esi
mov    %rax,%rdx
lea    0xc25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x80,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2bcd(%rip),%rax
mov    (%rax),%esi
mov    0x2bb4(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1486 <main+0x2e6>
lea    0xbef(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2b4f(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x38(%rbp),%esi
mov    %rax,%rdx
lea    0xbb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x64,-0x24(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2b4a(%rip),%rax
mov    (%rax),%esi
mov    0x2b31(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1060 <getsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    14fd <main+0x35d>
lea    0xb79(%rip),%rdi
call   1090 <perror@plt>
mov    0x2ada(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2ace(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x3c(%rbp),%esi
mov    %rax,%rdx
lea    0xb32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xb53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x80,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ac9(%rip),%rax
mov    (%rax),%esi
mov    0x2a98(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1580 <main+0x3e0>
lea    0xaeb(%rip),%rdi
call   1090 <perror@plt>
mov    0x2a57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2a4b(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x40(%rbp),%esi
mov    %rax,%rdx
lea    0xaaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x64,-0x24(%rbp)
movl   $0xffffffff,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2a50(%rip),%rax
mov    (%rax),%esi
mov    0x2a1f(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1060 <getsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    15f7 <main+0x457>
lea    0xa7f(%rip),%rdi
call   1090 <perror@plt>
mov    0x29e0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x29d4(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0x44(%rbp),%esi
mov    %rax,%rdx
lea    0xa38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xa6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e2f(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
lea    0xe42(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    $0x2834,%edi
call   1040 <htons@plt>
mov    %eax,0x8(%rsp)
mov    (%rbx),%edi
mov    0x2dda(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
cmp    $0xffffffff,%eax
je     1469 <main+0x2c9>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   1080 <bind@plt>
cmp    $0xffffffff,%eax
je     147f <main+0x2df>
movl   $0x0,(%rsp)
mov    0x2dce(%rip),%r15
mov    (%r15),%esi
mov    0x2dac(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     1460 <main+0x2c0>
movl   $0x64,0x4(%rsp)
movl   $0xffffffff,(%rsp)
mov    (%r15),%esi
mov    0x0(%rbp),%edx
mov    %rsp,%rcx
lea    0x4(%rsp),%r8
mov    %ebx,%edi
call   1060 <getsockopt@plt>
cmp    $0xffffffff,%eax
je     1488 <main+0x2e8>
mov    (%rsp),%esi
lea    0xdea(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x1,(%rsp)
mov    (%r15),%esi
mov    0x0(%rbp),%edx
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     1387 <main+0x1e7>
movl   $0x80,(%rsp)
mov    (%r15),%esi
mov    0x2d23(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     1460 <main+0x2c0>
movl   $0x64,0x4(%rsp)
movl   $0xffffffff,(%rsp)
mov    (%r15),%esi
mov    0x0(%rbp),%edx
mov    %rsp,%rcx
lea    0x4(%rsp),%r8
mov    %ebx,%edi
call   1060 <getsockopt@plt>
cmp    $0xffffffff,%eax
je     13be <main+0x21e>
mov    (%rsp),%esi
lea    0xd52(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x80,(%rsp)
mov    (%r15),%esi
mov    0x2ca0(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     13f5 <main+0x255>
movl   $0x64,0x4(%rsp)
movl   $0xffffffff,(%rsp)
mov    (%r15),%esi
mov    0x0(%rbp),%edx
mov    %rsp,%rcx
lea    0x4(%rsp),%r8
mov    %ebx,%edi
call   1060 <getsockopt@plt>
cmp    $0xffffffff,%eax
je     142c <main+0x28c>
mov    (%rsp),%esi
lea    0xcf8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc0(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c16(%rip),%rax
mov    (%rax),%r14d
mov    %r14d,%edi
call   10b0 <strerror@plt>
lea    0xc7c(%rip),%rdi
mov    %r14d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12a4 <main+0x104>
lea    0xc7e(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bdf(%rip),%rax
mov    (%rax),%r14d
mov    %r14d,%edi
call   10b0 <strerror@plt>
lea    0xc45(%rip),%rdi
mov    %r14d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12fe <main+0x15e>
lea    0xc3c(%rip),%rdi
call   1090 <perror@plt>
mov    0x2ba8(%rip),%rax
mov    (%rax),%r14d
mov    %r14d,%edi
call   10b0 <strerror@plt>
lea    0xc0e(%rip),%rdi
mov    %r14d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    133c <main+0x19c>
lea    0xc10(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b71(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10b0 <strerror@plt>
lea    0xbd9(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1369 <main+0x1c9>
lea    0xbd1(%rip),%rdi
jmp    148f <main+0x2ef>
lea    0xb9e(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
lea    0xb96(%rip),%rdi
jmp    148f <main+0x2ef>
lea    0xbb4(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b15(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   10b0 <strerror@plt>
lea    0xb7d(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [14 x i8] c"10.151.12.112\00"
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@.str.2 = [12 x i8] c"bind failed\00"
@.str.3 = [16 x i8] c"errno = %d(%s)\0A\00"
@errno = global i32 0
@SOL_SOCKET = global i32 0
@SO_DEBUG = global i32 0
@.str.4 = [11 x i8] c"set failed\00"
@.str.5 = [11 x i8] c"get failed\00"
@.str.6 = [10 x i8] c"val = %d\0A\00"
@.str.7 = [12 x i8] c"set2 failed\00"
@SO_SNDBUF = global i32 0
@.str.8 = [17 x i8] c"SNDBUF val = %d\0A\00"
@SO_RCVBUF = global i32 0
@.str.9 = [17 x i8] c"REVBUF val = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i32 %7, i32* %8
%9 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
store i32 %9, i32* %11
%12 = call i32 @htons(i32 10292)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i32 %12, i32* %13
%14 = load i32, i32* @AF_INET
%15 = load i32, i32* @SOCK_STREAM
%16 = call i32 @socket(i32 %14, i32 %15, i32 0)
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %0
%23 = load i32, i32* %2
%24 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%25 = call i32 @bind(i32 %23, %struct.sockaddr* %24, i32 12)
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %35
28: ; preds = %22
%29 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* @errno
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %30, i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %22
store i32 0, i32* %4
%36 = load i32, i32* %2
%37 = load i32, i32* @SOL_SOCKET
%38 = load i32, i32* @SO_DEBUG
%39 = call i32 @setsockopt(i32 %36, i32 %37, i32 %38, i32* %4, i32 4)
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %49
42: ; preds = %35
%43 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%44 = load i32, i32* @errno
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %44, i8* %46)
%48 = call i32 @exit(i32 -1)
unreachable
49: ; preds = %35
store i32 100, i32* %6
store i32 -1, i32* %4
%50 = load i32, i32* %2
%51 = load i32, i32* @SOL_SOCKET
%52 = load i32, i32* @SO_DEBUG
%53 = call i32 @getsockopt(i32 %50, i32 %51, i32 %52, i32* %4, i32* %6)
store i32 %53, i32* %3
%54 = load i32, i32* %3
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %63
56: ; preds = %49
%57 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%58 = load i32, i32* @errno
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %58, i8* %60)
%62 = call i32 @exit(i32 -1)
unreachable
63: ; preds = %49
%64 = load i32, i32* %4
%65 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %64)
store i32 1, i32* %4
%66 = load i32, i32* %2
%67 = load i32, i32* @SOL_SOCKET
%68 = load i32, i32* @SO_DEBUG
%69 = call i32 @setsockopt(i32 %66, i32 %67, i32 %68, i32* %4, i32 4)
store i32 %69, i32* %3
%70 = load i32, i32* %3
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %78
72: ; preds = %63
%73 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%74 = load i32, i32* @errno
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %74, i8* %76)
br label %78
78: ; preds = %72, %63
store i32 128, i32* %4
%79 = load i32, i32* %2
%80 = load i32, i32* @SOL_SOCKET
%81 = load i32, i32* @SO_SNDBUF
%82 = call i32 @setsockopt(i32 %79, i32 %80, i32 %81, i32* %4, i32 4)
store i32 %82, i32* %3
%83 = load i32, i32* %3
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %92
85: ; preds = %78
%86 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%87 = load i32, i32* @errno
%88 = load i32, i32* @errno
%89 = call i8* @strerror(i32 %88)
%90 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %87, i8* %89)
%91 = call i32 @exit(i32 -1)
unreachable
92: ; preds = %78
store i32 100, i32* %6
store i32 -1, i32* %4
%93 = load i32, i32* %2
%94 = load i32, i32* @SOL_SOCKET
%95 = load i32, i32* @SO_SNDBUF
%96 = call i32 @getsockopt(i32 %93, i32 %94, i32 %95, i32* %4, i32* %6)
store i32 %96, i32* %3
%97 = load i32, i32* %3
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %105
99: ; preds = %92
%100 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%101 = load i32, i32* @errno
%102 = load i32, i32* @errno
%103 = call i8* @strerror(i32 %102)
%104 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %101, i8* %103)
br label %105
105: ; preds = %99, %92
%106 = load i32, i32* %4
%107 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %106)
store i32 128, i32* %4
%108 = load i32, i32* %2
%109 = load i32, i32* @SOL_SOCKET
%110 = load i32, i32* @SO_RCVBUF
%111 = call i32 @setsockopt(i32 %108, i32 %109, i32 %110, i32* %4, i32 4)
store i32 %111, i32* %3
%112 = load i32, i32* %3
%113 = icmp eq i32 %112, -1
br i1 %113, label %114, label %120
114: ; preds = %105
%115 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%116 = load i32, i32* @errno
%117 = load i32, i32* @errno
%118 = call i8* @strerror(i32 %117)
%119 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %116, i8* %118)
br label %120
120: ; preds = %114, %105
store i32 100, i32* %6
store i32 -1, i32* %4
%121 = load i32, i32* %2
%122 = load i32, i32* @SOL_SOCKET
%123 = load i32, i32* @SO_RCVBUF
%124 = call i32 @getsockopt(i32 %121, i32 %122, i32 %123, i32* %4, i32* %6)
store i32 %124, i32* %3
%125 = load i32, i32* %3
%126 = icmp eq i32 %125, -1
br i1 %126, label %127, label %133
127: ; preds = %120
%128 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%129 = load i32, i32* @errno
%130 = load i32, i32* @errno
%131 = call i8* @strerror(i32 %130)
%132 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %129, i8* %131)
br label %133
133: ; preds = %127, %120
%134 = load i32, i32* %4
%135 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %134)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [14 x i8] c"10.151.12.112\00"
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@.str.2 = [12 x i8] c"bind failed\00"
@.str.3 = [16 x i8] c"errno = %d(%s)\0A\00"
@errno = global i32 0
@SOL_SOCKET = global i32 0
@SO_DEBUG = global i32 0
@.str.4 = [11 x i8] c"set failed\00"
@.str.5 = [11 x i8] c"get failed\00"
@.str.6 = [10 x i8] c"val = %d\0A\00"
@.str.7 = [12 x i8] c"set2 failed\00"
@SO_SNDBUF = global i32 0
@.str.8 = [17 x i8] c"SNDBUF val = %d\0A\00"
@SO_RCVBUF = global i32 0
@.str.9 = [17 x i8] c"REVBUF val = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast %struct.sockaddr_in* %2 to i8*
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %6, i32* %7
%8 = tail call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i32 %8, i32* %9
%10 = tail call i32 @htons(i32 10292)
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i32 %10, i32* %11
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 -1)
unreachable
19: ; preds = %0
%20 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%21 = call i32 @bind(i32 %14, %struct.sockaddr* %20, i32 12)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %25, i8* %26)
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %19
store i32 0, i32* %1
%30 = load i32, i32* @SOL_SOCKET
%31 = load i32, i32* @SO_DEBUG
%32 = call i32 @setsockopt(i32 %14, i32 %30, i32 %31, i32* %1, i32 4)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%36 = load i32, i32* @errno
%37 = call i8* @strerror(i32 %36)
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %36, i8* %37)
%39 = call i32 @exit(i32 -1)
unreachable
40: ; preds = %29
%41 = bitcast i32* %3 to i8*
store i32 100, i32* %3
store i32 -1, i32* %1
%42 = load i32, i32* @SOL_SOCKET
%43 = load i32, i32* @SO_DEBUG
%44 = call i32 @getsockopt(i32 %14, i32 %42, i32 %43, i32* %1, i32* %3)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %52
46: ; preds = %40
%47 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %48, i8* %49)
%51 = call i32 @exit(i32 -1)
unreachable
52: ; preds = %40
%53 = load i32, i32* %1
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %53)
store i32 1, i32* %1
%55 = load i32, i32* @SOL_SOCKET
%56 = load i32, i32* @SO_DEBUG
%57 = call i32 @setsockopt(i32 %14, i32 %55, i32 %56, i32* %1, i32 4)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %64
59: ; preds = %52
%60 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %61, i8* %62)
br label %64
64: ; preds = %59, %52
store i32 128, i32* %1
%65 = load i32, i32* @SOL_SOCKET
%66 = load i32, i32* @SO_SNDBUF
%67 = call i32 @setsockopt(i32 %14, i32 %65, i32 %66, i32* %1, i32 4)
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %75
69: ; preds = %64
%70 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %71, i8* %72)
%74 = call i32 @exit(i32 -1)
unreachable
75: ; preds = %64
store i32 100, i32* %3
store i32 -1, i32* %1
%76 = load i32, i32* @SOL_SOCKET
%77 = load i32, i32* @SO_SNDBUF
%78 = call i32 @getsockopt(i32 %14, i32 %76, i32 %77, i32* %1, i32* %3)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %85
80: ; preds = %75
%81 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%82 = load i32, i32* @errno
%83 = call i8* @strerror(i32 %82)
%84 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %82, i8* %83)
br label %85
85: ; preds = %80, %75
%86 = load i32, i32* %1
%87 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %86)
store i32 128, i32* %1
%88 = load i32, i32* @SOL_SOCKET
%89 = load i32, i32* @SO_RCVBUF
%90 = call i32 @setsockopt(i32 %14, i32 %88, i32 %89, i32* %1, i32 4)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %97
92: ; preds = %85
%93 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%94 = load i32, i32* @errno
%95 = call i8* @strerror(i32 %94)
%96 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %94, i8* %95)
br label %97
97: ; preds = %92, %85
store i32 100, i32* %3
store i32 -1, i32* %1
%98 = load i32, i32* @SOL_SOCKET
%99 = load i32, i32* @SO_RCVBUF
%100 = call i32 @getsockopt(i32 %14, i32 %98, i32 %99, i32* %1, i32* %3)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %107
102: ; preds = %97
%103 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%104 = load i32, i32* @errno
%105 = call i8* @strerror(i32 %104)
%106 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %104, i8* %105)
br label %107
107: ; preds = %102, %97
%108 = load i32, i32* %1
%109 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %108)
ret i32 0
}