#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 uint8_t;
typedef int loff_t;

/* Variables and functions */
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int resp_read_position(loff_t pos, uint8_t *buf, uint8_t *sam_stat) {
  memset(buf, 0, 20);
  if ((pos == 0) || (pos == 1))
    buf[0] = 0x80;
  buf[4] = buf[8] = (pos >> 24);
  buf[5] = buf[9] = (pos >> 16);
  buf[6] = buf[10] = (pos >> 8);
  buf[7] = buf[11] = pos;
  ;
  return 20;
}


x86 assembly (clang, -O0):
<resp_read_position>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
cmpl   $0x0,-0x4(%rbp)
je     1147 <resp_read_position+0x37>
cmpl   $0x1,-0x4(%rbp)
jne    1151 <resp_read_position+0x41>
mov    -0x10(%rbp),%rax
movl   $0x80,(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x18,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x10(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0x10(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    $0x14,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resp_read_position>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
cmp    $0x1,%ebp
ja     1132 <resp_read_position+0x22>
movl   $0x80,(%rbx)
mov    %ebp,%eax
sar    $0x18,%eax
mov    %eax,0x20(%rbx)
mov    %eax,0x10(%rbx)
mov    %ebp,%eax
sar    $0x10,%eax
mov    %eax,0x24(%rbx)
mov    %eax,0x14(%rbx)
mov    %ebp,%eax
sar    $0x8,%eax
mov    %eax,0x28(%rbx)
mov    %eax,0x18(%rbx)
mov    %ebp,0x2c(%rbx)
mov    %ebp,0x1c(%rbx)
mov    $0x14,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @resp_read_position(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %5
%8 = call i32 @memset(i32* %7, i32 0, i32 20)
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %11, %3
%15 = load i32*, i32** %5
%16 = getelementptr inbounds i32, i32* %15, i64 0
store i32 128, i32* %16
br label %17
17: ; preds = %14, %11
%18 = load i32, i32* %4
%19 = ashr i32 %18, 24
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 8
store i32 %19, i32* %21
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 4
store i32 %19, i32* %23
%24 = load i32, i32* %4
%25 = ashr i32 %24, 16
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 9
store i32 %25, i32* %27
%28 = load i32*, i32** %5
%29 = getelementptr inbounds i32, i32* %28, i64 5
store i32 %25, i32* %29
%30 = load i32, i32* %4
%31 = ashr i32 %30, 8
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i64 10
store i32 %31, i32* %33
%34 = load i32*, i32** %5
%35 = getelementptr inbounds i32, i32* %34, i64 6
store i32 %31, i32* %35
%36 = load i32, i32* %4
%37 = load i32*, i32** %5
%38 = getelementptr inbounds i32, i32* %37, i64 11
store i32 %36, i32* %38
%39 = load i32*, i32** %5
%40 = getelementptr inbounds i32, i32* %39, i64 7
store i32 %36, i32* %40
ret i32 20
}

LLVM IR (-O2):
define i32 @resp_read_position(i32 %0, i32* %1, i32* nocapture readnone %2) {
%4 = tail call i32 @memset(i32* %1, i32 0, i32 20)
%5 = icmp ult i32 %0, 2
br i1 %5, label %6, label %7
6: ; preds = %3
store i32 128, i32* %1
br label %7
7: ; preds = %3, %6
%8 = ashr i32 %0, 24
%9 = getelementptr inbounds i32, i32* %1, i64 8
store i32 %8, i32* %9
%10 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %8, i32* %10
%11 = ashr i32 %0, 16
%12 = getelementptr inbounds i32, i32* %1, i64 9
store i32 %11, i32* %12
%13 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %11, i32* %13
%14 = ashr i32 %0, 8
%15 = getelementptr inbounds i32, i32* %1, i64 10
store i32 %14, i32* %15
%16 = getelementptr inbounds i32, i32* %1, i64 6
store i32 %14, i32* %16
%17 = getelementptr inbounds i32, i32* %1, i64 11
store i32 %0, i32* %17
%18 = getelementptr inbounds i32, i32* %1, i64 7
store i32 %0, i32* %18
ret i32 20
}