#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 */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ transform_invoke_closure(void *, char *, char *);
void transform_array(void *in, void *out, int num_gen_args, void **args) {
  assert(num_gen_args == 4);
  size_t count = (size_t)args[0];
  size_t sz_in = (size_t)args[1];
  size_t sz_out = (size_t)args[2];
  char *in_ptr = (char *)in;
  char *out_ptr = (char *)out;
  int i;
  for (i = 0; i < count; i++, in_ptr += sz_in, out_ptr += sz_out) {
    transform_invoke_closure(args[3], in_ptr, out_ptr);
  }
}


x86 assembly (clang, -O0):
<transform_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x4,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movslq -0x4c(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11cb <transform_array+0xab>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   1040 <transform_invoke_closure@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1182 <transform_array+0x62>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transform_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
cmp    $0x4,%edx
sete   %dil
call   1030 <assert@plt>
mov    (%r14),%rax
test   %rax,%rax
je     117b <transform_array+0x5b>
mov    0x8(%r14),%r12
mov    0x10(%r14),%r13
cmp    $0x2,%rax
mov    $0x1,%ebp
cmovae %rax,%rbp
nop
mov    0x18(%r14),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <transform_invoke_closure@plt>
add    %r12,%rbx
add    %r13,%r15
add    $0xffffffffffffffff,%rbp
jne    1160 <transform_array+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @transform_array(i8* %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 4
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i8**, i8*** %8
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = ptrtoint i8* %21 to i64
store i64 %22, i64* %9
%23 = load i8**, i8*** %8
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = ptrtoint i8* %25 to i64
store i64 %26, i64* %10
%27 = load i8**, i8*** %8
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = ptrtoint i8* %29 to i64
store i64 %30, i64* %11
%31 = load i8*, i8** %5
store i8* %31, i8** %12
%32 = load i8*, i8** %6
store i8* %32, i8** %13
store i32 0, i32* %14
br label %33
33: ; preds = %45, %4
%34 = load i32, i32* %14
%35 = sext i32 %34 to i64
%36 = load i64, i64* %9
%37 = icmp ult i64 %35, %36
br i1 %37, label %38, label %54
38: ; preds = %33
%39 = load i8**, i8*** %8
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = load i8*, i8** %12
%43 = load i8*, i8** %13
%44 = call i32 @transform_invoke_closure(i8* %41, i8* %42, i8* %43)
br label %45
45: ; preds = %38
%46 = load i32, i32* %14
%47 = add nsw i32 %46, 1
store i32 %47, i32* %14
%48 = load i64, i64* %10
%49 = load i8*, i8** %12
%50 = getelementptr inbounds i8, i8* %49, i64 %48
store i8* %50, i8** %12
%51 = load i64, i64* %11
%52 = load i8*, i8** %13
%53 = getelementptr inbounds i8, i8* %52, i64 %51
store i8* %53, i8** %13
br label %33
54: ; preds = %33
ret void
}

LLVM IR (-O2):
define void @transform_array(i8* %0, i8* %1, i32 %2, i8** nocapture %3) {
%5 = icmp eq i32 %2, 4
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8*, i8** %3, i64 1
%10 = load i8*, i8** %9
%11 = ptrtoint i8* %10 to i64
%12 = getelementptr inbounds i8*, i8** %3, i64 2
%13 = load i8*, i8** %12
%14 = ptrtoint i8* %13 to i64
%15 = icmp eq i8* %8, null
br i1 %15, label %30, label %16
16: ; preds = %4
%17 = ptrtoint i8* %8 to i64
%18 = getelementptr inbounds i8*, i8** %3, i64 3
%19 = call i64 @llvm.umax.i64(i64 %17, i64 1)
br label %20
20: ; preds = %16, %20
%21 = phi i64 [ 0, %16 ], [ %26, %20 ]
%22 = phi i8* [ %1, %16 ], [ %28, %20 ]
%23 = phi i8* [ %0, %16 ], [ %27, %20 ]
%24 = load i8*, i8** %18
%25 = tail call i32 @transform_invoke_closure(i8* %24, i8* %23, i8* %22)
%26 = add nuw i64 %21, 1
%27 = getelementptr inbounds i8, i8* %23, i64 %11
%28 = getelementptr inbounds i8, i8* %22, i64 %14
%29 = icmp eq i64 %26, %19
br i1 %29, label %30, label %20
30: ; preds = %20, %4
ret void
}