#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 */
unsigned char logf(unsigned char);
void ucarrlog(unsigned char *in, size_t size) {
  unsigned char minpos = 1, *fpt, forneg;
  {
    forneg = logf(minpos);
    fpt = in + size;
    do {
      if (*in > 0)
        *in = logf(*in);
      else
        *in = forneg;
    } while (++in < fpt);
  }
}


x86 assembly (clang, -O0):
<ucarrlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x1,-0x11(%rbp)
movzbl -0x11(%rbp),%edi
call   1030 <logf@plt>
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jle    1165 <ucarrlog+0x55>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <logf@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    116e <ucarrlog+0x5e>
mov    -0x21(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    1173 <ucarrlog+0x63>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
cmp    -0x20(%rbp),%rax
jb     113c <ucarrlog+0x2c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ucarrlog>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%edi
call   1030 <logf@plt>
mov    %eax,%ebp
add    %rbx,%r14
jmp    113b <ucarrlog+0x2b>
nopl   0x0(%rax,%rax,1)
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    %r14,%rbx
jae    114e <ucarrlog+0x3e>
movzbl (%rbx),%ecx
mov    %ebp,%eax
test   %cl,%cl
je     1130 <ucarrlog+0x20>
movzbl %cl,%edi
call   1030 <logf@plt>
jmp    1130 <ucarrlog+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @ucarrlog(i8* %0, i64 %1) {
%3 = tail call zeroext i8 @logf(i8 zeroext 1)
%4 = getelementptr inbounds i8, i8* %0, i64 %1
br label %5
5: ; preds = %11, %2
%6 = phi i8* [ %0, %2 ], [ %13, %11 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call zeroext i8 @logf(i8 zeroext %7)
br label %11
11: ; preds = %5, %9
%12 = phi i8 [ %10, %9 ], [ %3, %5 ]
store i8 %12, i8* %6
%13 = getelementptr inbounds i8, i8* %6, i64 1
%14 = icmp ult i8* %13, %4
br i1 %14, label %5, label %15
15: ; preds = %11
ret void
}