#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 /*<<< orphan*/ socklen_t;
typedef scalar_t__ __ptr_t;

/* Variables and functions */
int __socketcall(int, unsigned long *);
int getsockopt(int fd, int level, int optname, __ptr_t optval,
               socklen_t *optlen) {
  unsigned long args[5];
  args[0] = fd;
  args[1] = level;
  args[2] = optname;
  args[3] = (unsigned long)optval;
  args[4] = (unsigned long)optlen;
  return (__socketcall(15, args));
}


x86 assembly (clang, -O0):
<getsockopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x50(%rbp)
movslq -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
movslq -0xc(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x50(%rbp),%rsi
mov    $0xf,%edi
call   1030 <__socketcall@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getsockopt>:
sub    $0x28,%rsp
movslq %edi,%rax
mov    %rax,(%rsp)
movslq %esi,%rax
mov    %rax,0x8(%rsp)
movslq %edx,%rax
mov    %rax,0x10(%rsp)
mov    %rcx,0x18(%rsp)
mov    %r8,0x20(%rsp)
mov    %rsp,%rsi
mov    $0xf,%edi
call   1030 <__socketcall@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @getsockopt(i32 %0, i32 %1, i32 %2, i64 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32*
%11 = alloca [5 x i64]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i64 %3, i64* %9
store i32* %4, i32** %10
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [5 x i64], [5 x i64]* %11, i64 0, i64 0
store i64 %13, i64* %14
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x i64], [5 x i64]* %11, i64 0, i64 1
store i64 %16, i64* %17
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i64], [5 x i64]* %11, i64 0, i64 2
store i64 %19, i64* %20
%21 = load i64, i64* %9
%22 = getelementptr inbounds [5 x i64], [5 x i64]* %11, i64 0, i64 3
store i64 %21, i64* %22
%23 = load i32*, i32** %10
%24 = ptrtoint i32* %23 to i64
%25 = getelementptr inbounds [5 x i64], [5 x i64]* %11, i64 0, i64 4
store i64 %24, i64* %25
%26 = getelementptr inbounds [5 x i64], [5 x i64]* %11, i64 0, i64 0
%27 = call i32 @__socketcall(i32 15, i64* %26)
ret i32 %27
}

LLVM IR (-O2):
define i32 @getsockopt(i32 %0, i32 %1, i32 %2, i64 %3, i32* %4) {
%6 = alloca [5 x i64]
%7 = bitcast [5 x i64]* %6 to i8*
%8 = sext i32 %0 to i64
%9 = getelementptr inbounds [5 x i64], [5 x i64]* %6, i64 0, i64 0
store i64 %8, i64* %9
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds [5 x i64], [5 x i64]* %6, i64 0, i64 1
store i64 %10, i64* %11
%12 = sext i32 %2 to i64
%13 = getelementptr inbounds [5 x i64], [5 x i64]* %6, i64 0, i64 2
store i64 %12, i64* %13
%14 = getelementptr inbounds [5 x i64], [5 x i64]* %6, i64 0, i64 3
store i64 %3, i64* %14
%15 = ptrtoint i32* %4 to i64
%16 = getelementptr inbounds [5 x i64], [5 x i64]* %6, i64 0, i64 4
store i64 %15, i64* %16
%17 = call i32 @__socketcall(i32 15, i64* %9)
ret i32 %17
}