#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 */

/* Variables and functions */
short logf(short);
int /*<<< orphan*/ shortminpos(short *, size_t, short *);
void sarrlog(short *in, size_t size) {
  short minpos, *fpt, forneg;
  shortminpos(in, size, &minpos);
  {
    forneg = logf(minpos);
    fpt = in + size;
    do {
      if (*in > 0)
        *in = logf(*in);
      else
        *in = forneg;
    } while (++in < fpt);
  }
}


x86 assembly (clang, -O0):
<sarrlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x12(%rbp),%rdx
call   1040 <shortminpos@plt>
movswl -0x12(%rbp),%edi
call   1030 <logf@plt>
mov    %ax,-0x22(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movswl (%rax),%eax
cmp    $0x0,%eax
jle    118c <sarrlog+0x6c>
mov    -0x8(%rbp),%rax
movswl (%rax),%edi
call   1030 <logf@plt>
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
jmp    1197 <sarrlog+0x77>
mov    -0x22(%rbp),%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
jmp    119c <sarrlog+0x7c>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
cmp    -0x20(%rbp),%rax
jb     1161 <sarrlog+0x41>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sarrlog>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x6(%rsp),%rdx
call   1040 <shortminpos@plt>
movswl 0x6(%rsp),%edi
call   1030 <logf@plt>
mov    %eax,%r15d
lea    (%rbx,%r14,2),%rbp
jmp    115c <sarrlog+0x3c>
nopw   0x0(%rax,%rax,1)
mov    %ax,(%rbx)
add    $0x2,%rbx
cmp    %rbp,%rbx
jae    1171 <sarrlog+0x51>
movzwl (%rbx),%ecx
mov    %r15d,%eax
test   %cx,%cx
jle    1150 <sarrlog+0x30>
movswl %cx,%edi
call   1030 <logf@plt>
jmp    1150 <sarrlog+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sarrlog(i16* %0, i64 %1) {
%3 = alloca i16*
%4 = alloca i64
%5 = alloca i16
%6 = alloca i16*
%7 = alloca i16
store i16* %0, i16** %3
store i64 %1, i64* %4
%8 = load i16*, i16** %3
%9 = load i64, i64* %4
%10 = call i32 @shortminpos(i16* %8, i64 %9, i16* %5)
%11 = load i16, i16* %5
%12 = call signext i16 @logf(i16 signext %11)
store i16 %12, i16* %7
%13 = load i16*, i16** %3
%14 = load i64, i64* %4
%15 = getelementptr inbounds i16, i16* %13, i64 %14
store i16* %15, i16** %6
br label %16
16: ; preds = %30, %2
%17 = load i16*, i16** %3
%18 = load i16, i16* %17
%19 = sext i16 %18 to i32
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load i16*, i16** %3
%23 = load i16, i16* %22
%24 = call signext i16 @logf(i16 signext %23)
%25 = load i16*, i16** %3
store i16 %24, i16* %25
br label %29
26: ; preds = %16
%27 = load i16, i16* %7
%28 = load i16*, i16** %3
store i16 %27, i16* %28
br label %29
29: ; preds = %26, %21
br label %30
30: ; preds = %29
%31 = load i16*, i16** %3
%32 = getelementptr inbounds i16, i16* %31, i32 1
store i16* %32, i16** %3
%33 = load i16*, i16** %6
%34 = icmp ult i16* %32, %33
br i1 %34, label %16, label %35
35: ; preds = %30
ret void
}

LLVM IR (-O2):
define void @sarrlog(i16* %0, i64 %1) {
%3 = alloca i16
%4 = bitcast i16* %3 to i8*
%5 = call i32 @shortminpos(i16* %0, i64 %1, i16* %3)
%6 = load i16, i16* %3
%7 = call signext i16 @logf(i16 signext %6)
%8 = getelementptr inbounds i16, i16* %0, i64 %1
br label %9
9: ; preds = %15, %2
%10 = phi i16* [ %0, %2 ], [ %17, %15 ]
%11 = load i16, i16* %10
%12 = icmp sgt i16 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call signext i16 @logf(i16 signext %11)
br label %15
15: ; preds = %9, %13
%16 = phi i16 [ %14, %13 ], [ %7, %9 ]
store i16 %16, i16* %10
%17 = getelementptr inbounds i16, i16* %10, i64 1
%18 = icmp ult i16* %17, %8
br i1 %18, label %9, label %19
19: ; preds = %15
ret void
}