#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_stripe(int width, int height, unsigned char r, unsigned char g,
                     unsigned char b) {
  unsigned char *data = NULL;
  char filename[100] = {0};
  FILE *fp = NULL;
  int i = 0, j = 0;
  if (width <= 0 || height <= 0) {
    printf("Error: Width, Height cannot be 0 or negative number!\n");
    printf("Default Param is used.\n");
    width = 640;
    height = 480;
  }
  data = (unsigned char *)malloc(width * height * 3);
  sprintf(filename, "rgbstripe_%dx%d_rgb24.rgb", width, height);
  if ((fp = fopen(filename, "wb+")) == NULL) {
    printf("Error: Cannot create file!");
    return -1;
  }
  for (j = 0; j < height; j++) {
    for (i = 0; i < width; i++) {
      if (i % 2 != 0) {
        data[(j * width + i) * 3 + 0] = r;
        data[(j * width + i) * 3 + 1] = g;
        data[(j * width + i) * 3 + 2] = b;
      } else {
        data[(j * width + i) * 3 + 0] = 255;
        data[(j * width + i) * 3 + 1] = 255;
        data[(j * width + i) * 3 + 2] = 255;
      }
    }
  }
  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_stripe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %r8b,%al
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %dl,-0xd(%rbp)
mov    %cl,-0xe(%rbp)
mov    %al,-0xf(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
movq   $0x0,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x90(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11e8 <gen_rgb24_stripe+0x68>
cmpl   $0x0,-0xc(%rbp)
jg     1212 <gen_rgb24_stripe+0x92>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x280,-0x8(%rbp)
movl   $0x1e0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   $0x3,%eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe18(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    1276 <gen_rgb24_stripe+0xf6>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140f <gen_rgb24_stripe+0x28f>
movl   $0x0,-0x90(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    13c2 <gen_rgb24_stripe+0x242>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13a9 <gen_rgb24_stripe+0x229>
mov    -0x8c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     132d <gen_rgb24_stripe+0x1ad>
mov    -0xd(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x90(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x8c(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xe(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x90(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x8c(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xf(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x90(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x8c(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1390 <gen_rgb24_stripe+0x210>
mov    -0x18(%rbp),%rax
mov    -0x90(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x8c(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movb   $0xff,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x90(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x8c(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xff,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x90(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x8c(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0xff,(%rax,%rcx,1)
jmp    1395 <gen_rgb24_stripe+0x215>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1299 <gen_rgb24_stripe+0x119>
jmp    13ae <gen_rgb24_stripe+0x22e>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    1280 <gen_rgb24_stripe+0x100>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   $0x3,%eax,%esi
mov    -0x88(%rbp),%rcx
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    -0x88(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    -0x80(%rbp),%rsi
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_rgb24_stripe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %edx,%r13d
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x80(%rsp)
test   %edi,%edi
jle    11d3 <gen_rgb24_stripe+0x53>
mov    %esi,%r15d
mov    %edi,%r12d
test   %esi,%esi
jg     11f7 <gen_rgb24_stripe+0x77>
lea    0xe74(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x280,%r12d
mov    $0x1e0,%r15d
mov    %r15d,%eax
imul   %r12d,%eax
lea    (%rax,%rax,2),%edi
mov    %edi,0xc(%rsp)
call   1070 <malloc@plt>
mov    %rax,0x18(%rsp)
lea    0xdea(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1090 <sprintf@plt>
lea    0xdea(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12ea <gen_rgb24_stripe+0x16a>
mov    %rax,0x10(%rsp)
mov    %r15d,%r8d
mov    %r12d,%edi
mov    0x18(%rsp),%r15
mov    %r15,%r10
add    $0x2,%r10
lea    (%rdi,%rdi,2),%r9
xor    %r11d,%r11d
nop
mov    %r10,%rdx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%esi
and    $0x1,%esi
cmp    $0x1,%rsi
sbb    %esi,%esi
mov    %esi,%ebx
or     %r13b,%bl
mov    %esi,%ecx
or     %bpl,%cl
or     %r14b,%sil
mov    %bl,-0x2(%rdx)
mov    %cl,-0x1(%rdx)
mov    %sil,(%rdx)
add    $0x1,%rax
add    $0x3,%rdx
cmp    %rax,%rdi
jne    1270 <gen_rgb24_stripe+0xf0>
add    $0x1,%r11
add    %r9,%r10
cmp    %r8,%r11
jne    1260 <gen_rgb24_stripe+0xe0>
mov    %r15,%rdi
mov    0xc(%rsp),%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rbx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xd5f(%rip),%rdi
xor    %ebx,%ebx
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12fd <gen_rgb24_stripe+0x17d>
lea    0xd2d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Error: Width, Height cannot be 0 or negative number!\0A\00"
@.str.1 = [24 x i8] c"Default Param is used.\0A\00"
@.str.2 = [26 x i8] c"rgbstripe_%dx%d_rgb24.rgb\00"
@.str.3 = [4 x i8] c"wb+\00"
@.str.4 = [27 x i8] c"Error: Cannot create file!\00"
@.str.5 = [21 x i8] c"Finish generate %s!\0A\00"
define i32 @gen_rgb24_stripe(i32 %0, i32 %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8*
%13 = alloca [100 x i8]
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i8 %2, i8* %9
store i8 %3, i8* %10
store i8 %4, i8* %11
store i8* null, i8** %12
%17 = bitcast [100 x i8]* %13 to i8*
store i32* null, i32** %14
store i32 0, i32* %15
store i32 0, i32* %16
%18 = load i32, i32* %7
%19 = icmp sle i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %5
%21 = load i32, i32* %8
%22 = icmp sle i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20, %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 640, i32* %7
store i32 480, i32* %8
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = mul nsw i32 %27, %28
%30 = mul nsw i32 %29, 3
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %12
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %35)
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32* %38, i32** %14
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %26
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %6
br label %143
42: ; preds = %26
store i32 0, i32* %16
br label %43
43: ; preds = %126, %42
%44 = load i32, i32* %16
%45 = load i32, i32* %8
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %129
47: ; preds = %43
store i32 0, i32* %15
br label %48
48: ; preds = %122, %47
%49 = load i32, i32* %15
%50 = load i32, i32* %7
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %125
52: ; preds = %48
%53 = load i32, i32* %15
%54 = srem i32 %53, 2
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %90
56: ; preds = %52
%57 = load i8, i8* %9
%58 = load i8*, i8** %12
%59 = load i32, i32* %16
%60 = load i32, i32* %7
%61 = mul nsw i32 %59, %60
%62 = load i32, i32* %15
%63 = add nsw i32 %61, %62
%64 = mul nsw i32 %63, 3
%65 = add nsw i32 %64, 0
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %58, i64 %66
store i8 %57, i8* %67
%68 = load i8, i8* %10
%69 = load i8*, i8** %12
%70 = load i32, i32* %16
%71 = load i32, i32* %7
%72 = mul nsw i32 %70, %71
%73 = load i32, i32* %15
%74 = add nsw i32 %72, %73
%75 = mul nsw i32 %74, 3
%76 = add nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %69, i64 %77
store i8 %68, i8* %78
%79 = load i8, i8* %11
%80 = load i8*, i8** %12
%81 = load i32, i32* %16
%82 = load i32, i32* %7
%83 = mul nsw i32 %81, %82
%84 = load i32, i32* %15
%85 = add nsw i32 %83, %84
%86 = mul nsw i32 %85, 3
%87 = add nsw i32 %86, 2
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %80, i64 %88
store i8 %79, i8* %89
br label %121
90: ; preds = %52
%91 = load i8*, i8** %12
%92 = load i32, i32* %16
%93 = load i32, i32* %7
%94 = mul nsw i32 %92, %93
%95 = load i32, i32* %15
%96 = add nsw i32 %94, %95
%97 = mul nsw i32 %96, 3
%98 = add nsw i32 %97, 0
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %91, i64 %99
store i8 -1, i8* %100
%101 = load i8*, i8** %12
%102 = load i32, i32* %16
%103 = load i32, i32* %7
%104 = mul nsw i32 %102, %103
%105 = load i32, i32* %15
%106 = add nsw i32 %104, %105
%107 = mul nsw i32 %106, 3
%108 = add nsw i32 %107, 1
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %101, i64 %109
store i8 -1, i8* %110
%111 = load i8*, i8** %12
%112 = load i32, i32* %16
%113 = load i32, i32* %7
%114 = mul nsw i32 %112, %113
%115 = load i32, i32* %15
%116 = add nsw i32 %114, %115
%117 = mul nsw i32 %116, 3
%118 = add nsw i32 %117, 2
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %111, i64 %119
store i8 -1, i8* %120
br label %121
121: ; preds = %90, %56
br label %122
122: ; preds = %121
%123 = load i32, i32* %15
%124 = add nsw i32 %123, 1
store i32 %124, i32* %15
br label %48
125: ; preds = %48
br label %126
126: ; preds = %125
%127 = load i32, i32* %16
%128 = add nsw i32 %127, 1
store i32 %128, i32* %16
br label %43
129: ; preds = %43
%130 = load i8*, i8** %12
%131 = load i32, i32* %7
%132 = load i32, i32* %8
%133 = mul nsw i32 %131, %132
%134 = mul nsw i32 %133, 3
%135 = load i32*, i32** %14
%136 = call i32 @fwrite(i8* %130, i32 %134, i32 1, i32* %135)
%137 = load i32*, i32** %14
%138 = call i32 @fclose(i32* %137)
%139 = load i8*, i8** %12
%140 = call i32 @free(i8* %139)
%141 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %141)
store i32 0, i32* %6
br label %143
143: ; preds = %129, %40
%144 = load i32, i32* %6
ret i32 %144
}

LLVM IR (-O2):
@.str.2 = [26 x i8] c"rgbstripe_%dx%d_rgb24.rgb\00"
@.str.3 = [4 x i8] c"wb+\00"
@.str.4 = [27 x i8] c"Error: Cannot create file!\00"
@.str.5 = [21 x i8] c"Finish generate %s!\0A\00"
@str = [53 x i8] c"Error: Width, Height cannot be 0 or negative number!\00"
@str.6 = [23 x i8] c"Default Param is used.\00"
define i32 @gen_rgb24_stripe(i32 %0, i32 %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%8 = icmp slt i32 %0, 1
%9 = icmp slt i32 %1, 1
%10 = or i1 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
br label %14
14: ; preds = %5, %11
%15 = phi i32 [ 480, %11 ], [ %1, %5 ]
%16 = phi i32 [ 640, %11 ], [ %0, %5 ]
%17 = mul i32 %15, 3
%18 = mul i32 %17, %16
%19 = tail call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %15)
%22 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %28, label %24
24: ; preds = %14
%25 = zext i32 %16 to i64
%26 = zext i32 %15 to i64
%27 = zext i32 %16 to i64
br label %30
28: ; preds = %14
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %57
30: ; preds = %24, %49
%31 = phi i64 [ 0, %24 ], [ %50, %49 ]
%32 = mul nsw i64 %31, %25
br label %33
33: ; preds = %30, %33
%34 = phi i64 [ 0, %30 ], [ %47, %33 ]
%35 = and i64 %34, 1
%36 = icmp eq i64 %35, 0
%37 = add nuw nsw i64 %34, %32
%38 = mul nsw i64 %37, 3
%39 = getelementptr inbounds i8, i8* %20, i64 %38
%40 = select i1 %36, i8 -1, i8 %2
%41 = select i1 %36, i8 -1, i8 %3
%42 = select i1 %36, i8 -1, i8 %4
store i8 %40, i8* %39
%43 = add nuw nsw i64 %38, 1
%44 = getelementptr inbounds i8, i8* %20, i64 %43
store i8 %41, i8* %44
%45 = add nuw nsw i64 %38, 2
%46 = getelementptr inbounds i8, i8* %20, i64 %45
store i8 %42, i8* %46
%47 = add nuw nsw i64 %34, 1
%48 = icmp eq i64 %47, %27
br i1 %48, label %49, label %33
49: ; preds = %33
%50 = add nuw nsw i64 %31, 1
%51 = icmp eq i64 %50, %26
br i1 %51, label %52, label %30
52: ; preds = %49
%53 = tail call i32 @fwrite(i8* %20, i32 %18, i32 1, i32* %22)
%54 = tail call i32 @fclose(i32* %22)
%55 = tail call i32 @free(i8* %20)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %7)
br label %57
57: ; preds = %52, %28
%58 = phi i32 [ -1, %28 ], [ 0, %52 ]
ret i32 %58
}