#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int gen_rgb24_rgbgradient_bar(int width, int height, int barnum,
                              unsigned char src_r, unsigned char src_g,
                              unsigned char src_b, unsigned char dst_r,
                              unsigned char dst_g, unsigned char dst_b) {
  unsigned char *data = NULL;
  int barwidth;
  float r_inc, g_inc, b_inc;
  unsigned char r_temp, g_temp, b_temp;
  char filename[100] = {0};
  FILE *fp = NULL;
  int t = 0, i = 0, j = 0;
  if (width <= 0 || height <= 0 || barnum <= 0) {
    printf(
        "Error: Width, Height or Bar Number cannot be 0 or negative number!\n");
    printf("Default Param is used.\n");
    width = 640;
    height = 480;
  }
  if (width % barnum != 0)
    printf(
        "Warning: Width cannot be divided by Bar Number without remainder!\n");
  data = (unsigned char *)malloc(width * height * 3);
  barwidth = width / barnum;
  r_inc = ((float)(dst_r - src_r)) / ((float)(barnum - 1));
  g_inc = ((float)(dst_g - src_g)) / ((float)(barnum - 1));
  b_inc = ((float)(dst_b - src_b)) / ((float)(barnum - 1));
  sprintf(filename, "rgbgradientbar_%dx%d_rgb24.rgb", width, height);
  if ((fp = fopen(filename, "wb+")) == NULL) {
    printf("Error: Cannot create file!");
    return -1;
  }
  printf("R, G, B value from picture's left to right:\n");
  for (t = 0; t < (width / barwidth); t++) {
    r_temp = src_r + (char)(t * r_inc);
    g_temp = src_g + (char)(t * g_inc);
    b_temp = src_b + (char)(t * b_inc);
    printf("%3d, %3d, %3d\n", r_temp, g_temp, b_temp);
  }
  for (j = 0; j < height; j++) {
    for (i = 0; i < width; i++) {
      t = i / barwidth;
      r_temp = src_r + (char)(t * r_inc);
      g_temp = src_g + (char)(t * g_inc);
      b_temp = src_b + (char)(t * b_inc);
      data[(j * width + i) * 3 + 0] = r_temp;
      data[(j * width + i) * 3 + 1] = g_temp;
      data[(j * width + i) * 3 + 2] = b_temp;
    }
  }
  fwrite(data, width * height * 3, 1, fp);
  fclose(fp);
  free(data);
  printf("Finish generate %s!\n", filename);
  return 0;
}


x86 assembly (clang, -O0):
<gen_rgb24_rgbgradient_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %r8d,-0xc4(%rbp)
mov    %ecx,%eax
mov    -0xc4(%rbp),%ecx
mov    %eax,-0xc0(%rbp)
mov    %edx,%eax
mov    -0xc0(%rbp),%edx
mov    %eax,-0xbc(%rbp)
mov    %esi,%eax
mov    -0xbc(%rbp),%esi
mov    %eax,-0xb8(%rbp)
mov    %edi,%r8d
mov    -0xb8(%rbp),%edi
mov    %r9b,%al
mov    0x20(%rbp),%r9b
mov    0x18(%rbp),%r9b
mov    0x10(%rbp),%r9b
mov    %r8d,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %dl,-0x11(%rbp)
mov    %cl,-0x12(%rbp)
mov    %al,-0x13(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
movq   $0x0,-0xa8(%rbp)
movl   $0x0,-0xac(%rbp)
movl   $0x0,-0xb0(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1249 <gen_rgb24_rgbgradient_bar+0xc9>
cmpl   $0x0,-0xc(%rbp)
jle    1249 <gen_rgb24_rgbgradient_bar+0xc9>
cmpl   $0x0,-0x10(%rbp)
jg     1273 <gen_rgb24_rgbgradient_bar+0xf3>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x280,-0x8(%rbp)
movl   $0x1e0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
je     1291 <gen_rgb24_rgbgradient_bar+0x111>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   $0x3,%eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x24(%rbp)
movzbl 0x10(%rbp),%eax
movzbl -0x11(%rbp),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movzbl 0x18(%rbp),%eax
movzbl -0x12(%rbp),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movzbl 0x20(%rbp),%eax
movzbl -0x13(%rbp),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xd7a(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xa8(%rbp)
cmp    $0x0,%rax
jne    1368 <gen_rgb24_rgbgradient_bar+0x1e8>
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b5 <gen_rgb24_rgbgradient_bar+0x435>
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xac(%rbp)
mov    -0xac(%rbp),%eax
mov    %eax,-0xc8(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,%ecx
mov    -0xc8(%rbp),%eax
cmp    %ecx,%eax
jge    142e <gen_rgb24_rgbgradient_bar+0x2ae>
movzbl -0x11(%rbp),%eax
cvtsi2ssl -0xac(%rbp),%xmm0
ff
movss  -0x28(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
add    %ecx,%eax
mov    %al,-0x31(%rbp)
movzbl -0x12(%rbp),%eax
cvtsi2ssl -0xac(%rbp),%xmm0
ff
movss  -0x2c(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
add    %ecx,%eax
mov    %al,-0x32(%rbp)
movzbl -0x13(%rbp),%eax
cvtsi2ssl -0xac(%rbp),%xmm0
ff
movss  -0x30(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
movsbl %cl,%ecx
add    %ecx,%eax
mov    %al,-0x33(%rbp)
movzbl -0x31(%rbp),%esi
movzbl -0x32(%rbp),%edx
movzbl -0x33(%rbp),%ecx
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xac(%rbp)
jmp    1380 <gen_rgb24_rgbgradient_bar+0x200>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1565 <gen_rgb24_rgbgradient_bar+0x3e5>
movl   $0x0,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    154c <gen_rgb24_rgbgradient_bar+0x3cc>
mov    -0xb0(%rbp),%eax
mov    -0x24(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,-0xac(%rbp)
movzbl -0x11(%rbp),%eax
cvtsi2ssl -0xac(%rbp),%xmm0
ff
movss  -0x28(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
add    %ecx,%eax
mov    %al,-0x31(%rbp)
movzbl -0x12(%rbp),%eax
cvtsi2ssl -0xac(%rbp),%xmm0
ff
movss  -0x2c(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
add    %ecx,%eax
mov    %al,-0x32(%rbp)
movzbl -0x13(%rbp),%eax
cvtsi2ssl -0xac(%rbp),%xmm0
ff
movss  -0x30(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%ecx
movsbl %cl,%ecx
add    %ecx,%eax
mov    %al,-0x33(%rbp)
mov    -0x31(%rbp),%dl
mov    -0x20(%rbp),%rax
mov    -0xb4(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0xb0(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x32(%rbp),%dl
mov    -0x20(%rbp),%rax
mov    -0xb4(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0xb0(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x33(%rbp),%dl
mov    -0x20(%rbp),%rax
mov    -0xb4(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0xb0(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
jmp    1451 <gen_rgb24_rgbgradient_bar+0x2d1>
jmp    1551 <gen_rgb24_rgbgradient_bar+0x3d1>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1438 <gen_rgb24_rgbgradient_bar+0x2b8>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   $0x3,%eax,%esi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    -0xa8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    -0xa0(%rbp),%rsi
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_rgb24_rgbgradient_bar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9d,%r14d
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %edx,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movl   $0x0,0x90(%rsp)
test   %edi,%edi
jle    11dc <gen_rgb24_rgbgradient_bar+0x5c>
mov    %esi,%r15d
test   %esi,%esi
jle    11dc <gen_rgb24_rgbgradient_bar+0x5c>
mov    %edi,%ebx
test   %ebp,%ebp
jg     11ff <gen_rgb24_rgbgradient_bar+0x7f>
lea    0xeed(%rip),%rdi
call   1040 <puts@plt>
lea    0xf24(%rip),%rdi
call   1040 <puts@plt>
mov    $0x280,%ebx
mov    $0x1e0,%r15d
mov    %ebx,%eax
cltd
mov    %ebp,0x8(%rsp)
idiv   %ebp
mov    %eax,%ebp
test   %edx,%edx
je     121a <gen_rgb24_rgbgradient_bar+0x9a>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
mov    %r15d,%eax
imul   %ebx,%eax
lea    (%rax,%rax,2),%edi
mov    %edi,0x1c(%rsp)
call   1070 <malloc@plt>
mov    %rax,0x20(%rsp)
lea    0xdc8(%rip),%rsi
mov    %r15d,%ecx
lea    0x30(%rsp),%r15
mov    %r15,%rdi
mov    %ebx,%edx
mov    %ecx,0xc(%rsp)
call   1090 <sprintf@plt>
lea    0xdca(%rip),%rsi
mov    %r15,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1450 <gen_rgb24_rgbgradient_bar+0x2d0>
mov    %rax,0x28(%rsp)
movzbl 0xd0(%rsp),%eax
movzbl %r13b,%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm1
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movzbl 0xd8(%rsp),%eax
movzbl %r12b,%ecx
sub    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
movzbl 0xe0(%rsp),%eax
movzbl %r14b,%ecx
sub    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
lea    0xd88(%rip),%rdi
call   1040 <puts@plt>
movss  0x10(%rsp),%xmm4
movss  0x14(%rsp),%xmm3
movss  0x8(%rsp),%xmm2
mov    %ebx,%eax
cltd
idiv   %ebp
mov    %ebx,%r15d
test   %eax,%eax
jle    1382 <gen_rgb24_rgbgradient_bar+0x202>
mov    %eax,%ebx
mov    %r15d,0x18(%rsp)
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
movaps %xmm2,%xmm1
mulss  %xmm0,%xmm1
cvttss2si %xmm1,%eax
add    %r13b,%al
movaps %xmm3,%xmm1
mulss  %xmm0,%xmm1
cvttss2si %xmm1,%ecx
add    %r12b,%cl
mulss  %xmm4,%xmm0
cvttss2si %xmm0,%edi
add    %r14b,%dil
movzbl %al,%esi
movzbl %cl,%edx
movzbl %dil,%ecx
lea    0xcee(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movss  0x10(%rsp),%xmm4
movss  0x14(%rsp),%xmm3
movss  0x8(%rsp),%xmm2
add    $0x1,%r15d
cmp    %r15d,%ebx
jne    1310 <gen_rgb24_rgbgradient_bar+0x190>
cmpl   $0x0,0xc(%rsp)
mov    0x18(%rsp),%r15d
jle    140b <gen_rgb24_rgbgradient_bar+0x28b>
movslq %r15d,%rax
mov    0xc(%rsp),%r8d
mov    %r15d,%edi
mov    0x20(%rsp),%r10
add    $0x2,%r10
lea    (%rax,%rax,2),%r9
xor    %r11d,%r11d
jmp    13ac <gen_rgb24_rgbgradient_bar+0x22c>
nop
add    $0x1,%r11
add    %r9,%r10
cmp    %r8,%r11
je     140b <gen_rgb24_rgbgradient_bar+0x28b>
test   %r15d,%r15d
jle    13a0 <gen_rgb24_rgbgradient_bar+0x220>
mov    %r10,%rbx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %ebp
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps %xmm2,%xmm1
mulss  %xmm0,%xmm1
cvttss2si %xmm1,%eax
movaps %xmm3,%xmm1
mulss  %xmm0,%xmm1
cvttss2si %xmm1,%edx
add    %r13b,%al
mulss  %xmm4,%xmm0
cvttss2si %xmm0,%esi
add    %r12b,%dl
add    %r14b,%sil
mov    %al,-0x2(%rbx)
mov    %dl,-0x1(%rbx)
mov    %sil,(%rbx)
add    $0x1,%rcx
add    $0x3,%rbx
cmp    %rcx,%rdi
jne    13c0 <gen_rgb24_rgbgradient_bar+0x240>
jmp    13a0 <gen_rgb24_rgbgradient_bar+0x220>
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    0x1c(%rsp),%esi
mov    $0x1,%edx
mov    0x28(%rsp),%rbp
mov    %rbp,%rcx
call   10a0 <fwrite@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xc0d(%rip),%rdi
xor    %ebx,%ebx
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1463 <gen_rgb24_rgbgradient_bar+0x2e3>
lea    0xbcc(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"Error: Width, Height or Bar Number cannot be 0 or negative number!\0A\00"
@.str.1 = [24 x i8] c"Default Param is used.\0A\00"
@.str.2 = [67 x i8] c"Warning: Width cannot be divided by Bar Number without remainder!\0A\00"
@.str.3 = [31 x i8] c"rgbgradientbar_%dx%d_rgb24.rgb\00"
@.str.4 = [4 x i8] c"wb+\00"
@.str.5 = [27 x i8] c"Error: Cannot create file!\00"
@.str.6 = [45 x i8] c"R, G, B value from picture's left to right:\0A\00"
@.str.7 = [15 x i8] c"%3d, %3d, %3d\0A\00"
@.str.8 = [21 x i8] c"Finish generate %s!\0A\00"
define i32 @gen_rgb24_rgbgradient_bar(i32 %0, i32 %1, i32 %2, i8 zeroext %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6, i8 zeroext %7, i8 zeroext %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
%19 = alloca i8
%20 = alloca i8*
%21 = alloca i32
%22 = alloca float
%23 = alloca float
%24 = alloca float
%25 = alloca i8
%26 = alloca i8
%27 = alloca i8
%28 = alloca [100 x i8]
%29 = alloca i32*
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
store i32 %0, i32* %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store i8 %3, i8* %14
store i8 %4, i8* %15
store i8 %5, i8* %16
store i8 %6, i8* %17
store i8 %7, i8* %18
store i8 %8, i8* %19
store i8* null, i8** %20
%33 = bitcast [100 x i8]* %28 to i8*
store i32* null, i32** %29
store i32 0, i32* %30
store i32 0, i32* %31
store i32 0, i32* %32
%34 = load i32, i32* %11
%35 = icmp sle i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %9
%37 = load i32, i32* %12
%38 = icmp sle i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i32, i32* %13
%41 = icmp sle i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39, %36, %9
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 640, i32* %11
store i32 480, i32* %12
br label %45
45: ; preds = %42, %39
%46 = load i32, i32* %11
%47 = load i32, i32* %13
%48 = srem i32 %46, %47
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %45
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %45
%53 = load i32, i32* %11
%54 = load i32, i32* %12
%55 = mul nsw i32 %53, %54
%56 = mul nsw i32 %55, 3
%57 = call i64 @malloc(i32 %56)
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %20
%59 = load i32, i32* %11
%60 = load i32, i32* %13
%61 = sdiv i32 %59, %60
store i32 %61, i32* %21
%62 = load i8, i8* %17
%63 = zext i8 %62 to i32
%64 = load i8, i8* %14
%65 = zext i8 %64 to i32
%66 = sub nsw i32 %63, %65
%67 = sitofp i32 %66 to float
%68 = load i32, i32* %13
%69 = sub nsw i32 %68, 1
%70 = sitofp i32 %69 to float
%71 = fdiv float %67, %70
store float %71, float* %22
%72 = load i8, i8* %18
%73 = zext i8 %72 to i32
%74 = load i8, i8* %15
%75 = zext i8 %74 to i32
%76 = sub nsw i32 %73, %75
%77 = sitofp i32 %76 to float
%78 = load i32, i32* %13
%79 = sub nsw i32 %78, 1
%80 = sitofp i32 %79 to float
%81 = fdiv float %77, %80
store float %81, float* %23
%82 = load i8, i8* %19
%83 = zext i8 %82 to i32
%84 = load i8, i8* %16
%85 = zext i8 %84 to i32
%86 = sub nsw i32 %83, %85
%87 = sitofp i32 %86 to float
%88 = load i32, i32* %13
%89 = sub nsw i32 %88, 1
%90 = sitofp i32 %89 to float
%91 = fdiv float %87, %90
store float %91, float* %24
%92 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%93 = load i32, i32* %11
%94 = load i32, i32* %12
%95 = call i32 @sprintf(i8* %92, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %93, i32 %94)
%96 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%97 = call i32* @fopen(i8* %96, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32* %97, i32** %29
%98 = icmp eq i32* %97, null
br i1 %98, label %99, label %101
99: ; preds = %52
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %10
br label %248
101: ; preds = %52
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %30
br label %103
103: ; preds = %147, %101
%104 = load i32, i32* %30
%105 = load i32, i32* %11
%106 = load i32, i32* %21
%107 = sdiv i32 %105, %106
%108 = icmp slt i32 %104, %107
br i1 %108, label %109, label %150
109: ; preds = %103
%110 = load i8, i8* %14
%111 = zext i8 %110 to i32
%112 = load i32, i32* %30
%113 = sitofp i32 %112 to float
%114 = load float, float* %22
%115 = fmul float %113, %114
%116 = fptosi float %115 to i8
%117 = sext i8 %116 to i32
%118 = add nsw i32 %111, %117
%119 = trunc i32 %118 to i8
store i8 %119, i8* %25
%120 = load i8, i8* %15
%121 = zext i8 %120 to i32
%122 = load i32, i32* %30
%123 = sitofp i32 %122 to float
%124 = load float, float* %23
%125 = fmul float %123, %124
%126 = fptosi float %125 to i8
%127 = sext i8 %126 to i32
%128 = add nsw i32 %121, %127
%129 = trunc i32 %128 to i8
store i8 %129, i8* %26
%130 = load i8, i8* %16
%131 = zext i8 %130 to i32
%132 = load i32, i32* %30
%133 = sitofp i32 %132 to float
%134 = load float, float* %24
%135 = fmul float %133, %134
%136 = fptosi float %135 to i8
%137 = sext i8 %136 to i32
%138 = add nsw i32 %131, %137
%139 = trunc i32 %138 to i8
store i8 %139, i8* %27
%140 = load i8, i8* %25
%141 = zext i8 %140 to i32
%142 = load i8, i8* %26
%143 = zext i8 %142 to i32
%144 = load i8, i8* %27
%145 = zext i8 %144 to i32
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %141, i32 %143, i32 %145)
br label %147
147: ; preds = %109
%148 = load i32, i32* %30
%149 = add nsw i32 %148, 1
store i32 %149, i32* %30
br label %103
150: ; preds = %103
store i32 0, i32* %32
br label %151
151: ; preds = %231, %150
%152 = load i32, i32* %32
%153 = load i32, i32* %12
%154 = icmp slt i32 %152, %153
br i1 %154, label %155, label %234
155: ; preds = %151
store i32 0, i32* %31
br label %156
156: ; preds = %227, %155
%157 = load i32, i32* %31
%158 = load i32, i32* %11
%159 = icmp slt i32 %157, %158
br i1 %159, label %160, label %230
160: ; preds = %156
%161 = load i32, i32* %31
%162 = load i32, i32* %21
%163 = sdiv i32 %161, %162
store i32 %163, i32* %30
%164 = load i8, i8* %14
%165 = zext i8 %164 to i32
%166 = load i32, i32* %30
%167 = sitofp i32 %166 to float
%168 = load float, float* %22
%169 = fmul float %167, %168
%170 = fptosi float %169 to i8
%171 = sext i8 %170 to i32
%172 = add nsw i32 %165, %171
%173 = trunc i32 %172 to i8
store i8 %173, i8* %25
%174 = load i8, i8* %15
%175 = zext i8 %174 to i32
%176 = load i32, i32* %30
%177 = sitofp i32 %176 to float
%178 = load float, float* %23
%179 = fmul float %177, %178
%180 = fptosi float %179 to i8
%181 = sext i8 %180 to i32
%182 = add nsw i32 %175, %181
%183 = trunc i32 %182 to i8
store i8 %183, i8* %26
%184 = load i8, i8* %16
%185 = zext i8 %184 to i32
%186 = load i32, i32* %30
%187 = sitofp i32 %186 to float
%188 = load float, float* %24
%189 = fmul float %187, %188
%190 = fptosi float %189 to i8
%191 = sext i8 %190 to i32
%192 = add nsw i32 %185, %191
%193 = trunc i32 %192 to i8
store i8 %193, i8* %27
%194 = load i8, i8* %25
%195 = load i8*, i8** %20
%196 = load i32, i32* %32
%197 = load i32, i32* %11
%198 = mul nsw i32 %196, %197
%199 = load i32, i32* %31
%200 = add nsw i32 %198, %199
%201 = mul nsw i32 %200, 3
%202 = add nsw i32 %201, 0
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i8, i8* %195, i64 %203
store i8 %194, i8* %204
%205 = load i8, i8* %26
%206 = load i8*, i8** %20
%207 = load i32, i32* %32
%208 = load i32, i32* %11
%209 = mul nsw i32 %207, %208
%210 = load i32, i32* %31
%211 = add nsw i32 %209, %210
%212 = mul nsw i32 %211, 3
%213 = add nsw i32 %212, 1
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds i8, i8* %206, i64 %214
store i8 %205, i8* %215
%216 = load i8, i8* %27
%217 = load i8*, i8** %20
%218 = load i32, i32* %32
%219 = load i32, i32* %11
%220 = mul nsw i32 %218, %219
%221 = load i32, i32* %31
%222 = add nsw i32 %220, %221
%223 = mul nsw i32 %222, 3
%224 = add nsw i32 %223, 2
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds i8, i8* %217, i64 %225
store i8 %216, i8* %226
br label %227
227: ; preds = %160
%228 = load i32, i32* %31
%229 = add nsw i32 %228, 1
store i32 %229, i32* %31
br label %156
230: ; preds = %156
br label %231
231: ; preds = %230
%232 = load i32, i32* %32
%233 = add nsw i32 %232, 1
store i32 %233, i32* %32
br label %151
234: ; preds = %151
%235 = load i8*, i8** %20
%236 = load i32, i32* %11
%237 = load i32, i32* %12
%238 = mul nsw i32 %236, %237
%239 = mul nsw i32 %238, 3
%240 = load i32*, i32** %29
%241 = call i32 @fwrite(i8* %235, i32 %239, i32 1, i32* %240)
%242 = load i32*, i32** %29
%243 = call i32 @fclose(i32* %242)
%244 = load i8*, i8** %20
%245 = call i32 @free(i8* %244)
%246 = getelementptr inbounds [100 x i8], [100 x i8]* %28, i64 0, i64 0
%247 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %246)
store i32 0, i32* %10
br label %248
248: ; preds = %234, %99
%249 = load i32, i32* %10
ret i32 %249
}

LLVM IR (-O2):
@.str.3 = [31 x i8] c"rgbgradientbar_%dx%d_rgb24.rgb\00"
@.str.4 = [4 x i8] c"wb+\00"
@.str.5 = [27 x i8] c"Error: Cannot create file!\00"
@.str.7 = [15 x i8] c"%3d, %3d, %3d\0A\00"
@.str.8 = [21 x i8] c"Finish generate %s!\0A\00"
@str = [44 x i8] c"R, G, B value from picture's left to right:\00"
@str.9 = [66 x i8] c"Warning: Width cannot be divided by Bar Number without remainder!\00"
@str.10 = [67 x i8] c"Error: Width, Height or Bar Number cannot be 0 or negative number!\00"
@str.11 = [23 x i8] c"Default Param is used.\00"
define i32 @gen_rgb24_rgbgradient_bar(i32 %0, i32 %1, i32 %2, i8 zeroext %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6, i8 zeroext %7, i8 zeroext %8) {
%10 = alloca [100 x i8]
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%12 = icmp slt i32 %0, 1
%13 = icmp slt i32 %1, 1
%14 = or i1 %12, %13
%15 = icmp slt i32 %2, 1
%16 = or i1 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.10, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
br label %20
20: ; preds = %9, %17
%21 = phi i32 [ 480, %17 ], [ %1, %9 ]
%22 = phi i32 [ 640, %17 ], [ %0, %9 ]
%23 = srem i32 %22, %2
%24 = sdiv i32 %22, %2
%25 = icmp eq i32 %23, 0
br i1 %25, label %28, label %26
26: ; preds = %20
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.9, i64 0, i64 0))
br label %28
28: ; preds = %26, %20
%29 = mul i32 %21, 3
%30 = mul i32 %29, %22
%31 = tail call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i8*
%33 = zext i8 %6 to i32
%34 = zext i8 %3 to i32
%35 = sub nsw i32 %33, %34
%36 = sitofp i32 %35 to float
%37 = add nsw i32 %2, -1
%38 = sitofp i32 %37 to float
%39 = fdiv float %36, %38
%40 = zext i8 %7 to i32
%41 = zext i8 %4 to i32
%42 = sub nsw i32 %40, %41
%43 = sitofp i32 %42 to float
%44 = fdiv float %43, %38
%45 = zext i8 %8 to i32
%46 = zext i8 %5 to i32
%47 = sub nsw i32 %45, %46
%48 = sitofp i32 %47 to float
%49 = fdiv float %48, %38
%50 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %21)
%51 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %55
53: ; preds = %28
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %119
55: ; preds = %28
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%57 = sdiv i32 %22, %24
%58 = icmp sgt i32 %57, 0
br i1 %58, label %66, label %61
59: ; preds = %66
%60 = icmp sgt i32 %21, 0
br i1 %60, label %61, label %114
61: ; preds = %55, %59
%62 = icmp sgt i32 %22, 0
%63 = sext i32 %22 to i64
%64 = zext i32 %21 to i64
%65 = zext i32 %22 to i64
br label %84
66: ; preds = %55, %66
%67 = phi i32 [ %82, %66 ], [ 0, %55 ]
%68 = sitofp i32 %67 to float
%69 = fmul float %39, %68
%70 = fptosi float %69 to i8
%71 = add i8 %70, %3
%72 = fmul float %44, %68
%73 = fptosi float %72 to i8
%74 = add i8 %73, %4
%75 = fmul float %49, %68
%76 = fptosi float %75 to i8
%77 = add i8 %76, %5
%78 = zext i8 %71 to i32
%79 = zext i8 %74 to i32
%80 = zext i8 %77 to i32
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %78, i32 %79, i32 %80)
%82 = add nuw nsw i32 %67, 1
%83 = icmp eq i32 %82, %57
br i1 %83, label %59, label %66
84: ; preds = %61, %111
%85 = phi i64 [ 0, %61 ], [ %112, %111 ]
br i1 %62, label %86, label %111
86: ; preds = %84
%87 = mul nsw i64 %85, %63
br label %88
88: ; preds = %86, %88
%89 = phi i64 [ 0, %86 ], [ %109, %88 ]
%90 = trunc i64 %89 to i32
%91 = sdiv i32 %90, %24
%92 = sitofp i32 %91 to float
%93 = fmul float %39, %92
%94 = fptosi float %93 to i8
%95 = add i8 %94, %3
%96 = fmul float %44, %92
%97 = fptosi float %96 to i8
%98 = add i8 %97, %4
%99 = fmul float %49, %92
%100 = fptosi float %99 to i8
%101 = add i8 %100, %5
%102 = add nsw i64 %89, %87
%103 = mul nsw i64 %102, 3
%104 = getelementptr inbounds i8, i8* %32, i64 %103
store i8 %95, i8* %104
%105 = add nsw i64 %103, 1
%106 = getelementptr inbounds i8, i8* %32, i64 %105
store i8 %98, i8* %106
%107 = add nsw i64 %103, 2
%108 = getelementptr inbounds i8, i8* %32, i64 %107
store i8 %101, i8* %108
%109 = add nuw nsw i64 %89, 1
%110 = icmp eq i64 %109, %65
br i1 %110, label %111, label %88
111: ; preds = %88, %84
%112 = add nuw nsw i64 %85, 1
%113 = icmp eq i64 %112, %64
br i1 %113, label %114, label %84
114: ; preds = %111, %59
%115 = tail call i32 @fwrite(i8* %32, i32 %30, i32 1, i32* %51)
%116 = tail call i32 @fclose(i32* %51)
%117 = tail call i32 @free(i8* %32)
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %11)
br label %119
119: ; preds = %114, %53
%120 = phi i32 [ -1, %53 ], [ 0, %114 ]
ret i32 %120
}