#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
unsigned char *create_gradient_image(int ar, int ag, int ab, int aa, int br,
                                     int bg, int bb, int ba, int width,
                                     int height) {
  int i;
  double t, delta;
  int pitch = width * 4;
  unsigned char *loc;
  unsigned char *pixels = (unsigned char *)malloc(pitch * height);
  if (pixels == NULL) {
    return NULL;
  }
  loc = pixels;
  for (i = 0, t = 0.0, delta = 1.0 / width; i < width; ++i, t += delta) {
    *loc++ = (unsigned char)(ab + (bb - ab) * t);
    *loc++ = (unsigned char)(ag + (bg - ag) * t);
    *loc++ = (unsigned char)(ar + (br - ar) * t);
    *loc++ = (unsigned char)(aa + (ba - aa) * t);
  }
  loc = pixels + pitch;
  for (i = 1; i < height; ++i) {
    memcpy(loc, pixels, pitch);
    loc += pitch;
  }
  return pixels;
}


x86 assembly (clang, -O0):
<create_gradient_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    0x20(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
imul   0x28(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1179 <create_gradient_image+0x59>
movq   $0x0,-0x8(%rbp)
jmp    12f8 <create_gradient_image+0x1d8>
mov    -0x50(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl 0x20(%rbp),%xmm1
movsd  0xe63(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    129f <create_gradient_image+0x17f>
mov    -0x14(%rbp),%ecx
cvtsi2sd %ecx,%xmm1
mov    0x10(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x48(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%ecx
cvtsi2sd %ecx,%xmm1
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x48(%rbp)
mov    %cl,(%rax)
mov    -0xc(%rbp),%ecx
cvtsi2sd %ecx,%xmm1
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x48(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%ecx
cvtsi2sd %ecx,%xmm1
mov    0x18(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x48(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x48(%rbp)
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11a6 <create_gradient_image+0x86>
mov    -0x50(%rbp),%rax
movslq -0x3c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    0x28(%rbp),%eax
jge    12f0 <create_gradient_image+0x1d0>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x3c(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12b5 <create_gradient_image+0x195>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_gradient_image>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebp
mov    %r8d,%r15d
mov    %ecx,0x14(%rsp)
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,0x10(%rsp)
mov    0x68(%rsp),%r13d
mov    0x60(%rsp),%eax
lea    0x0(,%rax,4),%edi
mov    %edi,0xc(%rsp)
imul   %r13d,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1268 <create_gradient_image+0x148>
mov    %rax,%r12
mov    0x60(%rsp),%edx
test   %edx,%edx
jle    1232 <create_gradient_image+0x112>
cvtsi2sd %edx,%xmm1
mov    0x50(%rsp),%eax
cvtsi2sd %r14d,%xmm8
sub    %r14d,%eax
cvtsi2sd %eax,%xmm9
cvtsi2sd %ebx,%xmm10
sub    %ebx,%ebp
cvtsi2sd %ebp,%xmm3
mov    0x58(%rsp),%eax
mov    0x10(%rsp),%ecx
cvtsi2sd %ecx,%xmm4
sub    %ecx,%r15d
cvtsi2sd %r15d,%xmm5
mov    0x14(%rsp),%ecx
cvtsi2sd %ecx,%xmm6
movsd  0xe46(%rip),%xmm7
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
divsd  %xmm1,%xmm7
mov    %edx,%eax
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
nopl   0x0(%rax)
movapd %xmm9,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm8,%xmm2
cvttsd2si %xmm2,%edx
mov    %dl,(%r12,%rcx,4)
movapd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm10,%xmm2
cvttsd2si %xmm2,%edx
mov    %dl,0x1(%r12,%rcx,4)
movapd %xmm5,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm4,%xmm2
cvttsd2si %xmm2,%edx
mov    %dl,0x2(%r12,%rcx,4)
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm6,%xmm2
cvttsd2si %xmm2,%edx
mov    %dl,0x3(%r12,%rcx,4)
addsd  %xmm7,%xmm1
add    $0x1,%rcx
cmp    %ecx,%eax
jne    11d0 <create_gradient_image+0xb0>
cmp    $0x2,%r13d
jl     126b <create_gradient_image+0x14b>
movslq 0xc(%rsp),%rbp
mov    %r12,%rbx
add    %rbp,%rbx
add    $0xffffffff,%r13d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1030 <memcpy@plt>
add    %rbp,%rbx
add    $0xffffffff,%r13d
jne    1250 <create_gradient_image+0x130>
jmp    126b <create_gradient_image+0x14b>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @create_gradient_image(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9) {
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca double
%24 = alloca double
%25 = alloca i32
%26 = alloca i8*
%27 = alloca i8*
store i32 %0, i32* %12
store i32 %1, i32* %13
store i32 %2, i32* %14
store i32 %3, i32* %15
store i32 %4, i32* %16
store i32 %5, i32* %17
store i32 %6, i32* %18
store i32 %7, i32* %19
store i32 %8, i32* %20
store i32 %9, i32* %21
%28 = load i32, i32* %20
%29 = mul nsw i32 %28, 4
store i32 %29, i32* %25
%30 = load i32, i32* %25
%31 = load i32, i32* %21
%32 = mul nsw i32 %30, %31
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %27
%35 = load i8*, i8** %27
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %38
37: ; preds = %10
store i8* null, i8** %11
br label %121
38: ; preds = %10
%39 = load i8*, i8** %27
store i8* %39, i8** %26
store i32 0, i32* %22
store double 0.000000e+00, double* %23
%40 = load i32, i32* %20
%41 = sitofp i32 %40 to double
%42 = fdiv double 1.000000e+00, %41
store double %42, double* %24
br label %43
43: ; preds = %92, %38
%44 = load i32, i32* %22
%45 = load i32, i32* %20
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %98
47: ; preds = %43
%48 = load i32, i32* %14
%49 = sitofp i32 %48 to double
%50 = load i32, i32* %18
%51 = load i32, i32* %14
%52 = sub nsw i32 %50, %51
%53 = sitofp i32 %52 to double
%54 = load double, double* %23
%55 = call double @llvm.fmuladd.f64(double %53, double %54, double %49)
%56 = fptoui double %55 to i8
%57 = load i8*, i8** %26
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %26
store i8 %56, i8* %57
%59 = load i32, i32* %13
%60 = sitofp i32 %59 to double
%61 = load i32, i32* %17
%62 = load i32, i32* %13
%63 = sub nsw i32 %61, %62
%64 = sitofp i32 %63 to double
%65 = load double, double* %23
%66 = call double @llvm.fmuladd.f64(double %64, double %65, double %60)
%67 = fptoui double %66 to i8
%68 = load i8*, i8** %26
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %26
store i8 %67, i8* %68
%70 = load i32, i32* %12
%71 = sitofp i32 %70 to double
%72 = load i32, i32* %16
%73 = load i32, i32* %12
%74 = sub nsw i32 %72, %73
%75 = sitofp i32 %74 to double
%76 = load double, double* %23
%77 = call double @llvm.fmuladd.f64(double %75, double %76, double %71)
%78 = fptoui double %77 to i8
%79 = load i8*, i8** %26
%80 = getelementptr inbounds i8, i8* %79, i32 1
store i8* %80, i8** %26
store i8 %78, i8* %79
%81 = load i32, i32* %15
%82 = sitofp i32 %81 to double
%83 = load i32, i32* %19
%84 = load i32, i32* %15
%85 = sub nsw i32 %83, %84
%86 = sitofp i32 %85 to double
%87 = load double, double* %23
%88 = call double @llvm.fmuladd.f64(double %86, double %87, double %82)
%89 = fptoui double %88 to i8
%90 = load i8*, i8** %26
%91 = getelementptr inbounds i8, i8* %90, i32 1
store i8* %91, i8** %26
store i8 %89, i8* %90
br label %92
92: ; preds = %47
%93 = load i32, i32* %22
%94 = add nsw i32 %93, 1
store i32 %94, i32* %22
%95 = load double, double* %24
%96 = load double, double* %23
%97 = fadd double %96, %95
store double %97, double* %23
br label %43
98: ; preds = %43
%99 = load i8*, i8** %27
%100 = load i32, i32* %25
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %99, i64 %101
store i8* %102, i8** %26
store i32 1, i32* %22
br label %103
103: ; preds = %116, %98
%104 = load i32, i32* %22
%105 = load i32, i32* %21
%106 = icmp slt i32 %104, %105
br i1 %106, label %107, label %119
107: ; preds = %103
%108 = load i8*, i8** %26
%109 = load i8*, i8** %27
%110 = load i32, i32* %25
%111 = call i32 @memcpy(i8* %108, i8* %109, i32 %110)
%112 = load i32, i32* %25
%113 = load i8*, i8** %26
%114 = sext i32 %112 to i64
%115 = getelementptr inbounds i8, i8* %113, i64 %114
store i8* %115, i8** %26
br label %116
116: ; preds = %107
%117 = load i32, i32* %22
%118 = add nsw i32 %117, 1
store i32 %118, i32* %22
br label %103
119: ; preds = %103
%120 = load i8*, i8** %27
store i8* %120, i8** %11
br label %121
121: ; preds = %119, %37
%122 = load i8*, i8** %11
ret i8* %122
}

LLVM IR (-O2):
define i8* @create_gradient_image(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9) {
%11 = shl nsw i32 %8, 2
%12 = mul nsw i32 %11, %9
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %62, label %16
16: ; preds = %10
%17 = sitofp i32 %8 to double
%18 = fdiv double 1.000000e+00, %17
%19 = icmp sgt i32 %8, 0
br i1 %19, label %20, label %52
20: ; preds = %16
%21 = sitofp i32 %2 to double
%22 = sub nsw i32 %6, %2
%23 = sitofp i32 %22 to double
%24 = sitofp i32 %1 to double
%25 = sub nsw i32 %5, %1
%26 = sitofp i32 %25 to double
%27 = sitofp i32 %0 to double
%28 = sub nsw i32 %4, %0
%29 = sitofp i32 %28 to double
%30 = sitofp i32 %3 to double
%31 = sub nsw i32 %7, %3
%32 = sitofp i32 %31 to double
br label %33
33: ; preds = %20, %33
%34 = phi i8* [ %14, %20 ], [ %48, %33 ]
%35 = phi i32 [ 0, %20 ], [ %49, %33 ]
%36 = phi double [ 0.000000e+00, %20 ], [ %50, %33 ]
%37 = tail call double @llvm.fmuladd.f64(double %23, double %36, double %21)
%38 = fptoui double %37 to i8
%39 = getelementptr inbounds i8, i8* %34, i64 1
store i8 %38, i8* %34
%40 = tail call double @llvm.fmuladd.f64(double %26, double %36, double %24)
%41 = fptoui double %40 to i8
%42 = getelementptr inbounds i8, i8* %34, i64 2
store i8 %41, i8* %39
%43 = tail call double @llvm.fmuladd.f64(double %29, double %36, double %27)
%44 = fptoui double %43 to i8
%45 = getelementptr inbounds i8, i8* %34, i64 3
store i8 %44, i8* %42
%46 = tail call double @llvm.fmuladd.f64(double %32, double %36, double %30)
%47 = fptoui double %46 to i8
%48 = getelementptr inbounds i8, i8* %34, i64 4
store i8 %47, i8* %45
%49 = add nuw nsw i32 %35, 1
%50 = fadd double %18, %36
%51 = icmp eq i32 %49, %8
br i1 %51, label %52, label %33
52: ; preds = %33, %16
%53 = sext i32 %11 to i64
%54 = icmp sgt i32 %9, 1
br i1 %54, label %55, label %62
55: ; preds = %52, %55
%56 = phi i8* [ %58, %55 ], [ %14, %52 ]
%57 = phi i32 [ %60, %55 ], [ 1, %52 ]
%58 = getelementptr inbounds i8, i8* %56, i64 %53
%59 = tail call i32 @memcpy(i8* %58, i8* %14, i32 %11)
%60 = add nuw nsw i32 %57, 1
%61 = icmp eq i32 %60, %9
br i1 %61, label %62, label %55
62: ; preds = %55, %52, %10
%63 = phi i8* [ null, %10 ], [ %14, %52 ], [ %14, %55 ]
ret i8* %63
}