#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 /*<<< orphan*/ put_unaligned_be32(int, int *);
int resp_read_position(loff_t pos, uint8_t *buf, uint8_t *sam_stat) {
  uint8_t partition = 0;
  memset(buf, 0, 20);
  if ((pos == 0) || (pos == 1))
    buf[0] = 0x80;
  buf[0] |= 0x20;
  buf[0] |= 0x10;
  buf[1] = partition;
  put_unaligned_be32(pos, &buf[4]);
  put_unaligned_be32(pos, &buf[8]);
  ;
  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)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
cmpl   $0x0,-0x4(%rbp)
je     115e <resp_read_position+0x3e>
cmpl   $0x1,-0x4(%rbp)
jne    1168 <resp_read_position+0x48>
mov    -0x10(%rbp),%rax
movl   $0x80,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
or     $0x20,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
or     $0x10,%ecx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   1030 <put_unaligned_be32@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x20,%rsi
call   1030 <put_unaligned_be32@plt>
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   1040 <memset@plt>
mov    $0xb0,%eax
cmp    $0x2,%ebp
jb     1146 <resp_read_position+0x26>
mov    (%rbx),%eax
or     $0x30,%eax
mov    %eax,(%rbx)
movl   $0x0,0x4(%rbx)
lea    0x10(%rbx),%rsi
mov    %ebp,%edi
call   1030 <put_unaligned_be32@plt>
add    $0x20,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <put_unaligned_be32@plt>
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*
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
%8 = load i32*, i32** %5
%9 = call i32 @memset(i32* %8, i32 0, i32 20)
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %12, %3
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 0
store i32 128, i32* %17
br label %18
18: ; preds = %15, %12
%19 = load i32*, i32** %5
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = or i32 %21, 32
store i32 %22, i32* %20
%23 = load i32*, i32** %5
%24 = getelementptr inbounds i32, i32* %23, i64 0
%25 = load i32, i32* %24
%26 = or i32 %25, 16
store i32 %26, i32* %24
%27 = load i32, i32* %7
%28 = load i32*, i32** %5
%29 = getelementptr inbounds i32, i32* %28, i64 1
store i32 %27, i32* %29
%30 = load i32, i32* %4
%31 = load i32*, i32** %5
%32 = getelementptr inbounds i32, i32* %31, i64 4
%33 = call i32 @put_unaligned_be32(i32 %30, i32* %32)
%34 = load i32, i32* %4
%35 = load i32*, i32** %5
%36 = getelementptr inbounds i32, i32* %35, i64 8
%37 = call i32 @put_unaligned_be32(i32 %34, i32* %36)
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 %9, label %6
6: ; preds = %3
%7 = load i32, i32* %1
%8 = or i32 %7, 48
br label %9
9: ; preds = %3, %6
%10 = phi i32 [ %8, %6 ], [ 176, %3 ]
store i32 %10, i32* %1
%11 = getelementptr inbounds i32, i32* %1, i64 1
store i32 0, i32* %11
%12 = getelementptr inbounds i32, i32* %1, i64 4
%13 = tail call i32 @put_unaligned_be32(i32 %0, i32* %12)
%14 = getelementptr inbounds i32, i32* %1, i64 8
%15 = tail call i32 @put_unaligned_be32(i32 %0, i32* %14)
ret i32 20
}