#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 dtoi(float);
int /*<<< orphan*/ g2_free(int *);
int /*<<< orphan*/ g2_image(int, float, float, int, int, int *);
scalar_t__ g2_malloc(int);
void g2_image_(float *dev, float *x, float *y, float *x_size, float *y_size,
               float *pens) {
  int i, j, xs, ys;
  int *mypens;
  xs = dtoi(*x_size);
  ys = dtoi(*y_size);
  mypens = (int *)g2_malloc(xs * ys * sizeof(int));
  for (j = 0; j < ys; j++)
    for (i = 0; i < xs; i++)
      mypens[j * xs + i] = dtoi(pens[j * xs + i]);
  g2_image(dtoi(*dev), *x, *y, xs, ys, mypens);
  g2_free(mypens);
}


x86 assembly (clang, -O0):
<g2_image_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
call   1050 <dtoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
call   1050 <dtoi@plt>
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x40(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <g2_malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    1210 <g2_image_+0xd0>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    11fd <g2_image_+0xbd>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
call   1050 <dtoi@plt>
mov    %eax,%edx
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b2 <g2_image_+0x72>
jmp    1202 <g2_image_+0xc2>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    119f <g2_image_+0x5f>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
call   1050 <dtoi@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x48(%rbp),%rcx
call   1040 <g2_image@plt>
mov    -0x48(%rbp),%rdi
call   1060 <g2_free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g2_image_>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%rbx
mov    %r8,%r14
mov    %rdx,0x28(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,0x18(%rsp)
movss  (%rcx),%xmm0
call   1050 <dtoi@plt>
mov    %eax,%r15d
movss  (%r14),%xmm0
call   1050 <dtoi@plt>
mov    %eax,%ebp
mov    %r15d,0x8(%rsp)
imul   %eax,%r15d
shl    $0x2,%r15d
mov    %r15d,%edi
call   1030 <g2_malloc@plt>
mov    %rax,0x10(%rsp)
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
jle    11fb <g2_image_+0xbb>
mov    0x8(%rsp),%eax
movslq %eax,%r15
mov    0xc(%rsp),%ecx
mov    %rcx,0x30(%rsp)
mov    %eax,%r14d
shl    $0x2,%r15
xor    %r12d,%r12d
mov    0x10(%rsp),%rbp
jmp    11d1 <g2_image_+0x91>
xchg   %ax,%ax
add    $0x1,%r12
add    %r15,%rbx
add    %r15,%rbp
cmp    0x30(%rsp),%r12
je     11fb <g2_image_+0xbb>
cmpl   $0x0,0x8(%rsp)
jle    11c0 <g2_image_+0x80>
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
movss  (%rbx,%r13,4),%xmm0
call   1050 <dtoi@plt>
mov    %eax,0x0(%rbp,%r13,4)
add    $0x1,%r13
cmp    %r13,%r14
jne    11e0 <g2_image_+0xa0>
jmp    11c0 <g2_image_+0x80>
mov    0x18(%rsp),%rax
movss  (%rax),%xmm0
call   1050 <dtoi@plt>
mov    0x20(%rsp),%rcx
movss  (%rcx),%xmm0
mov    0x28(%rsp),%rcx
movss  (%rcx),%xmm1
mov    %eax,%edi
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%rbx
mov    %rbx,%rcx
call   1040 <g2_image@plt>
mov    %rbx,%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <g2_free@plt>

LLVM IR (-O0):
define void @g2_image_(float* %0, float* %1, float* %2, float* %3, float* %4, float* %5) {
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
store float* %0, float** %7
store float* %1, float** %8
store float* %2, float** %9
store float* %3, float** %10
store float* %4, float** %11
store float* %5, float** %12
%18 = load float*, float** %10
%19 = load float, float* %18
%20 = call i32 @dtoi(float %19)
store i32 %20, i32* %15
%21 = load float*, float** %11
%22 = load float, float* %21
%23 = call i32 @dtoi(float %22)
store i32 %23, i32* %16
%24 = load i32, i32* %15
%25 = load i32, i32* %16
%26 = mul nsw i32 %24, %25
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = trunc i64 %28 to i32
%30 = call i64 @g2_malloc(i32 %29)
%31 = inttoptr i64 %30 to i32*
store i32* %31, i32** %17
store i32 0, i32* %14
br label %32
32: ; preds = %64, %6
%33 = load i32, i32* %14
%34 = load i32, i32* %16
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %67
36: ; preds = %32
store i32 0, i32* %13
br label %37
37: ; preds = %60, %36
%38 = load i32, i32* %13
%39 = load i32, i32* %15
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %63
41: ; preds = %37
%42 = load float*, float** %12
%43 = load i32, i32* %14
%44 = load i32, i32* %15
%45 = mul nsw i32 %43, %44
%46 = load i32, i32* %13
%47 = add nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds float, float* %42, i64 %48
%50 = load float, float* %49
%51 = call i32 @dtoi(float %50)
%52 = load i32*, i32** %17
%53 = load i32, i32* %14
%54 = load i32, i32* %15
%55 = mul nsw i32 %53, %54
%56 = load i32, i32* %13
%57 = add nsw i32 %55, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %52, i64 %58
store i32 %51, i32* %59
br label %60
60: ; preds = %41
%61 = load i32, i32* %13
%62 = add nsw i32 %61, 1
store i32 %62, i32* %13
br label %37
63: ; preds = %37
br label %64
64: ; preds = %63
%65 = load i32, i32* %14
%66 = add nsw i32 %65, 1
store i32 %66, i32* %14
br label %32
67: ; preds = %32
%68 = load float*, float** %7
%69 = load float, float* %68
%70 = call i32 @dtoi(float %69)
%71 = load float*, float** %8
%72 = load float, float* %71
%73 = load float*, float** %9
%74 = load float, float* %73
%75 = load i32, i32* %15
%76 = load i32, i32* %16
%77 = load i32*, i32** %17
%78 = call i32 @g2_image(i32 %70, float %72, float %74, i32 %75, i32 %76, i32* %77)
%79 = load i32*, i32** %17
%80 = call i32 @g2_free(i32* %79)
ret void
}

LLVM IR (-O2):
define void @g2_image_(float* nocapture %0, float* nocapture %1, float* nocapture %2, float* nocapture %3, float* nocapture %4, float* nocapture %5) {
%7 = load float, float* %3
%8 = tail call i32 @dtoi(float %7)
%9 = load float, float* %4
%10 = tail call i32 @dtoi(float %9)
%11 = shl i32 %8, 2
%12 = mul i32 %11, %10
%13 = tail call i64 @g2_malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
%15 = icmp sgt i32 %10, 0
br i1 %15, label %16, label %37
16: ; preds = %6
%17 = icmp sgt i32 %8, 0
%18 = sext i32 %8 to i64
%19 = zext i32 %10 to i64
%20 = zext i32 %8 to i64
br label %21
21: ; preds = %16, %34
%22 = phi i64 [ 0, %16 ], [ %35, %34 ]
br i1 %17, label %23, label %34
23: ; preds = %21
%24 = mul nsw i64 %22, %18
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %32, %25 ]
%27 = add nsw i64 %26, %24
%28 = getelementptr inbounds float, float* %5, i64 %27
%29 = load float, float* %28
%30 = tail call i32 @dtoi(float %29)
%31 = getelementptr inbounds i32, i32* %14, i64 %27
store i32 %30, i32* %31
%32 = add nuw nsw i64 %26, 1
%33 = icmp eq i64 %32, %20
br i1 %33, label %34, label %25
34: ; preds = %25, %21
%35 = add nuw nsw i64 %22, 1
%36 = icmp eq i64 %35, %19
br i1 %36, label %37, label %21
37: ; preds = %34, %6
%38 = load float, float* %0
%39 = tail call i32 @dtoi(float %38)
%40 = load float, float* %1
%41 = load float, float* %2
%42 = tail call i32 @g2_image(i32 %39, float %40, float %41, i32 %8, i32 %10, i32* %14)
%43 = tail call i32 @g2_free(i32* %14)
ret void
}