#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 */
double log(double);
void gray_log(double **image, double **image2, int line, int row) {
  int i = 0, j = 0;
  for (i = 0; i < line; i++) {
    for (j = 0; j < row; j++) {
      image2[i][j] = log(image[i][j]);
    }
  }
}


x86 assembly (clang, -O0):
<gray_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11aa <gray_log+0x9a>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1197 <gray_log+0x87>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <log@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <gray_log+0x3e>
jmp    119c <gray_log+0x8c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <gray_log+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gray_log>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,0x4(%rsp)
test   %edx,%edx
jle    1185 <gray_log+0x75>
mov    %rsi,%r12
mov    %rdi,%r13
mov    %edx,%r15d
mov    0x4(%rsp),%ebx
xor    %ebp,%ebp
jmp    1149 <gray_log+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %r15,%rbp
je     1185 <gray_log+0x75>
cmpl   $0x0,0x4(%rsp)
jle    1140 <gray_log+0x30>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbp,8),%rax
movsd  (%rax,%r14,8),%xmm0
call   1030 <log@plt>
mov    (%r12,%rbp,8),%rax
movsd  %xmm0,(%rax,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbx
jne    1160 <gray_log+0x50>
jmp    1140 <gray_log+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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