#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 */
typedef int socklen_t;
typedef int /*<<< orphan*/ optval;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_OOBINLINE;
int /*<<< orphan*/ SO_TYPE;
int /*<<< orphan*/ getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int execute_getsockopt() {
  int sfd = socket(AF_INET, SOCK_STREAM, 0);
  int optval;
  socklen_t optlen = sizeof(optval);
  getsockopt(sfd, SOL_SOCKET, SO_TYPE, &optval, &optlen);
  getsockopt(sfd, SOL_SOCKET, SO_OOBINLINE, &optval, &optlen);
  return 0;
}


x86 assembly (clang, -O0):
<execute_getsockopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,-0x4(%rbp)
movl   $0x4,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
lea    -0xc(%rbp),%r8
call   1030 <getsockopt@plt>
mov    -0x4(%rbp),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
mov    0x2e40(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
lea    -0xc(%rbp),%r8
call   1030 <getsockopt@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_getsockopt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,%ebx
movl   $0x4,(%rsp)
mov    0x2e97(%rip),%r12
mov    (%r12),%esi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%r14
mov    %rsp,%r15
mov    %ebx,%edi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <getsockopt@plt>
mov    (%r12),%esi
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <getsockopt@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_TYPE = global i32 0
@SO_OOBINLINE = global i32 0
define i32 @execute_getsockopt() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %1
store i32 4, i32* %3
%7 = load i32, i32* %1
%8 = load i32, i32* @SOL_SOCKET
%9 = load i32, i32* @SO_TYPE
%10 = call i32 @getsockopt(i32 %7, i32 %8, i32 %9, i32* %2, i32* %3)
%11 = load i32, i32* %1
%12 = load i32, i32* @SOL_SOCKET
%13 = load i32, i32* @SO_OOBINLINE
%14 = call i32 @getsockopt(i32 %11, i32 %12, i32 %13, i32* %2, i32* %3)
ret i32 0
}

LLVM IR (-O2):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_TYPE = global i32 0
@SO_OOBINLINE = global i32 0
define i32 @execute_getsockopt() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_STREAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
store i32 4, i32* %2
%8 = load i32, i32* @SOL_SOCKET
%9 = load i32, i32* @SO_TYPE
%10 = call i32 @getsockopt(i32 %5, i32 %8, i32 %9, i32* %1, i32* %2)
%11 = load i32, i32* @SOL_SOCKET
%12 = load i32, i32* @SO_OOBINLINE
%13 = call i32 @getsockopt(i32 %5, i32 %11, i32 %12, i32* %1, i32* %2)
ret i32 0
}