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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, char, char,
                           ...);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *, unsigned int, char *);
void save_bitmap_GS(uint **image, unsigned int number, char *dir, char *name,
                    unsigned int width, unsigned int height) {
  FILE *fd_out;
  char filename[500];
  unsigned long ulBitmapSize = (height * width * 3) + 54;
  char ucaBitmapSize[4];
  ucaBitmapSize[3] = (ulBitmapSize & 0xFF000000) >> 24;
  ucaBitmapSize[2] = (ulBitmapSize & 0x00FF0000) >> 16;
  ucaBitmapSize[1] = (ulBitmapSize & 0x0000FF00) >> 8;
  ucaBitmapSize[0] = (ulBitmapSize & 0x000000FF);
  sprintf(filename, "%s/o%02d_%s.bmp", dir, number, name);
  fd_out = fopen(filename, "wb");
  fprintf(fd_out, "%c%c%c%c%c%c%c%c%c%c", 66, 77, ucaBitmapSize[0],
          ucaBitmapSize[1], ucaBitmapSize[2], ucaBitmapSize[3], 0, 0, 0, 0);
  fprintf(fd_out, "%c%c%c%c%c%c%c%c%c%c", 54, 0, 0, 0, 40, 0, 0, 0,
          (width & 0x00FF), (width & 0xFF00) >> 8);
  fprintf(fd_out, "%c%c%c%c%c%c%c%c%c%c", 0, 0, (height & 0x00FF),
          (height & 0xFF00) >> 8, 0, 0, 1, 0, 24, 0);
  fprintf(fd_out, "%c%c%c%c%c%c%c%c%c%c", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  fprintf(fd_out, "%c%c%c%c%c%c%c%c%c%c", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  fprintf(fd_out, "%c%c%c%c", 0, 0, 0, 0);
  for (unsigned int y = 0; y < height; y++) {
    for (unsigned int x = 0; x < width; x++) {
      fputc(image[x][y], fd_out);
      fputc(image[x][y], fd_out);
      fputc(image[x][y], fd_out);
    }
    for (unsigned int j = 0; j < width % 4; j++) {
      fputc(0, fd_out);
    }
  }
  fclose(fd_out);
}


x86 assembly (clang, -O0):
<save_bitmap_GS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x28(%rbp),%eax
imul   -0x24(%rbp),%eax
imul   $0x3,%eax,%eax
add    $0x36,%eax
mov    %eax,%eax
mov    %rax,-0x238(%rbp)
movabs $0xff000000,%rax
and    -0x238(%rbp),%rax
shr    $0x18,%rax
mov    %al,-0x239(%rbp)
mov    -0x238(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    %al,-0x23a(%rbp)
mov    -0x238(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    %al,-0x23b(%rbp)
mov    -0x238(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x23c(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%r8
lea    0xe03(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x230(%rbp),%rdi
lea    0xe00(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x23c(%rbp),%r8b
mov    -0x23b(%rbp),%r9b
movsbl -0x23a(%rbp),%r10d
ff
movsbl -0x239(%rbp),%eax
lea    0xdd2(%rip),%rsi
mov    $0x42,%edx
mov    $0x4d,%ecx
xor    %r11d,%r11d
movsbl %r8b,%r8d
movsbl %r9b,%r9d
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%r10d
and    $0xff,%r10d
mov    -0x24(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
lea    0xd6d(%rip),%rsi
mov    $0x36,%edx
xor    %r9d,%r9d
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x28,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
mov    %r10d,0x20(%rsp)
mov    %eax,0x28(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%eax
and    $0xff,%eax
mov    %al,%r8b
mov    -0x28(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
lea    0xd0f(%rip),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
movsbl %r8b,%r8d
movsbl %al,%r9d
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x1,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x18,0x20(%rsp)
movl   $0x0,0x28(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xcc2(%rip),%rsi
xor    %r9d,%r9d
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xc75(%rip),%rsi
xor    %r9d,%r9d
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xc34(%rip),%rsi
xor    %r9d,%r9d
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x240(%rbp)
mov    -0x240(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    14fa <save_bitmap_GS+0x3aa>
movl   $0x0,-0x244(%rbp)
mov    -0x244(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    14a4 <save_bitmap_GS+0x354>
mov    -0x8(%rbp),%rax
mov    -0x244(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x240(%rbp),%ecx
mov    (%rax,%rcx,4),%edi
mov    -0x30(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x8(%rbp),%rax
mov    -0x244(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x240(%rbp),%ecx
mov    (%rax,%rcx,4),%edi
mov    -0x30(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x8(%rbp),%rax
mov    -0x244(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x240(%rbp),%ecx
mov    (%rax,%rcx,4),%edi
mov    -0x30(%rbp),%rsi
call   1040 <fputc@plt>
mov    -0x244(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x244(%rbp)
jmp    1421 <save_bitmap_GS+0x2d1>
movl   $0x0,-0x248(%rbp)
mov    -0x248(%rbp),%eax
mov    -0x24(%rbp),%ecx
and    $0x3,%ecx
cmp    %ecx,%eax
jae    14e1 <save_bitmap_GS+0x391>
mov    -0x30(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x248(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x248(%rbp)
jmp    14ae <save_bitmap_GS+0x35e>
jmp    14e6 <save_bitmap_GS+0x396>
mov    -0x240(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x240(%rbp)
jmp    1408 <save_bitmap_GS+0x2b8>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_bitmap_GS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rcx,%rax
mov    %r9d,0x8(%rsp)
mov    %esi,%ecx
mov    %r8d,0x4(%rsp)
mov    %rdi,%r14
mov    %r8d,%esi
imul   %r9d,%esi
lea    (%rsi,%rsi,2),%ebp
add    $0x36,%ebp
mov    %ebp,%r12d
shr    $0x8,%r12d
lea    0xe72(%rip),%rsi
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rax,%r8
call   1070 <sprintf@plt>
lea    0xe6b(%rip),%rsi
mov    %r15,%rdi
call   1060 <fopen@plt>
mov    %rax,%r13
mov    %ebp,%eax
shr    $0x10,%eax
movsbl %al,%r10d
mov    %ebp,%ebx
sar    $0x18,%ebx
movsbl %bpl,%r8d
movsbl %r12b,%r9d
lea    0xe46(%rip),%r15
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x42,%edx
mov    $0x4d,%ecx
xor    %eax,%eax
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   %rbx
push   %r10
call   1050 <fprintf@plt>
add    $0x30,%rsp
mov    0x4(%rsp),%eax
movzbl %al,%ebp
movzbl %ah,%ebx
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x36,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   %rbx
push   %rbp
push   $0x0
push   $0x0
push   $0x0
push   $0x28
call   1050 <fprintf@plt>
add    $0x30,%rsp
mov    0x8(%rsp),%ebx
mov    %ebx,%eax
shr    $0x8,%eax
movsbl %bl,%r8d
movsbl %al,%r9d
mov    %r13,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %eax,%eax
push   $0x0
push   $0x18
push   $0x0
push   $0x1
push   $0x0
push   $0x0
call   1050 <fprintf@plt>
add    $0x30,%rsp
mov    %r13,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
call   1050 <fprintf@plt>
add    $0x30,%rsp
mov    %r13,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
call   1050 <fprintf@plt>
add    $0x30,%rsp
lea    0xd73(%rip),%rsi
mov    %r13,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %ebx,%ebx
je     1374 <save_bitmap_GS+0x224>
mov    %ebx,%ecx
mov    0x4(%rsp),%eax
mov    %eax,%r15d
and    $0x3,%r15d
mov    %ebx,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%r12d
xor    %ebp,%ebp
jmp    12fb <save_bitmap_GS+0x1ab>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    0x8(%rsp),%rbp
je     1374 <save_bitmap_GS+0x224>
cmpl   $0x0,0x4(%rsp)
je     1346 <save_bitmap_GS+0x1f6>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,8),%rax
mov    (%rax,%rbp,4),%edi
mov    %r13,%rsi
call   1040 <fputc@plt>
mov    (%r14,%rbx,8),%rax
mov    (%rax,%rbp,4),%edi
mov    %r13,%rsi
call   1040 <fputc@plt>
mov    (%r14,%rbx,8),%rax
mov    (%rax,%rbp,4),%edi
mov    %r13,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1310 <save_bitmap_GS+0x1c0>
mov    %r15d,%eax
mov    %r15d,%ebx
test   %r15d,%r15d
je     12f0 <save_bitmap_GS+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r13,%rsi
call   1040 <fputc@plt>
add    $0xffffffff,%ebx
jne    1360 <save_bitmap_GS+0x210>
jmp    12f0 <save_bitmap_GS+0x1a0>
mov    %r13,%rdi
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"%s/o%02d_%s.bmp\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [21 x i8] c"%c%c%c%c%c%c%c%c%c%c\00"
@.str.3 = [9 x i8] c"%c%c%c%c\00"
define void @save_bitmap_GS(i32** %0, i32 %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i32**
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca [500 x i8]
%15 = alloca i64
%16 = alloca [4 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32** %0, i32*** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%20 = load i32, i32* %12
%21 = load i32, i32* %11
%22 = mul i32 %20, %21
%23 = mul i32 %22, 3
%24 = add i32 %23, 54
%25 = zext i32 %24 to i64
store i64 %25, i64* %15
%26 = load i64, i64* %15
%27 = and i64 %26, 4278190080
%28 = lshr i64 %27, 24
%29 = trunc i64 %28 to i8
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 3
store i8 %29, i8* %30
%31 = load i64, i64* %15
%32 = and i64 %31, 16711680
%33 = lshr i64 %32, 16
%34 = trunc i64 %33 to i8
%35 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 2
store i8 %34, i8* %35
%36 = load i64, i64* %15
%37 = and i64 %36, 65280
%38 = lshr i64 %37, 8
%39 = trunc i64 %38 to i8
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 1
store i8 %39, i8* %40
%41 = load i64, i64* %15
%42 = and i64 %41, 255
%43 = trunc i64 %42 to i8
%44 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
store i8 %43, i8* %44
%45 = getelementptr inbounds [500 x i8], [500 x i8]* %14, i64 0, i64 0
%46 = load i8*, i8** %9
%47 = load i32, i32* %8
%48 = load i8*, i8** %10
%49 = call i32 @sprintf(i8* %45, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %46, i32 %47, i8* %48)
%50 = getelementptr inbounds [500 x i8], [500 x i8]* %14, i64 0, i64 0
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %51, i32** %13
%52 = load i32*, i32** %13
%53 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
%54 = load i8, i8* %53
%55 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 1
%56 = load i8, i8* %55
%57 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 2
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 3
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 66, i32 77, i8 signext %54, i8 signext %56, i32 %59, i32 %62, i32 0, i32 0, i32 0, i32 0)
%64 = load i32*, i32** %13
%65 = load i32, i32* %11
%66 = and i32 %65, 255
%67 = load i32, i32* %11
%68 = and i32 %67, 65280
%69 = lshr i32 %68, 8
%70 = call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 54, i32 0, i8 signext 0, i8 signext 0, i32 40, i32 0, i32 0, i32 0, i32 %66, i32 %69)
%71 = load i32*, i32** %13
%72 = load i32, i32* %12
%73 = and i32 %72, 255
%74 = trunc i32 %73 to i8
%75 = load i32, i32* %12
%76 = and i32 %75, 65280
%77 = lshr i32 %76, 8
%78 = trunc i32 %77 to i8
%79 = call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i8 signext %74, i8 signext %78, i32 0, i32 0, i32 1, i32 0, i32 24, i32 0)
%80 = load i32*, i32** %13
%81 = call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i8 signext 0, i8 signext 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
%82 = load i32*, i32** %13
%83 = call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i8 signext 0, i8 signext 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
%84 = load i32*, i32** %13
%85 = call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i8 signext 0, i8 signext 0)
store i32 0, i32* %17
br label %86
86: ; preds = %145, %6
%87 = load i32, i32* %17
%88 = load i32, i32* %12
%89 = icmp ult i32 %87, %88
br i1 %89, label %90, label %148
90: ; preds = %86
store i32 0, i32* %18
br label %91
91: ; preds = %129, %90
%92 = load i32, i32* %18
%93 = load i32, i32* %11
%94 = icmp ult i32 %92, %93
br i1 %94, label %95, label %132
95: ; preds = %91
%96 = load i32**, i32*** %7
%97 = load i32, i32* %18
%98 = zext i32 %97 to i64
%99 = getelementptr inbounds i32*, i32** %96, i64 %98
%100 = load i32*, i32** %99
%101 = load i32, i32* %17
%102 = zext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %100, i64 %102
%104 = load i32, i32* %103
%105 = load i32*, i32** %13
%106 = call i32 @fputc(i32 %104, i32* %105)
%107 = load i32**, i32*** %7
%108 = load i32, i32* %18
%109 = zext i32 %108 to i64
%110 = getelementptr inbounds i32*, i32** %107, i64 %109
%111 = load i32*, i32** %110
%112 = load i32, i32* %17
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds i32, i32* %111, i64 %113
%115 = load i32, i32* %114
%116 = load i32*, i32** %13
%117 = call i32 @fputc(i32 %115, i32* %116)
%118 = load i32**, i32*** %7
%119 = load i32, i32* %18
%120 = zext i32 %119 to i64
%121 = getelementptr inbounds i32*, i32** %118, i64 %120
%122 = load i32*, i32** %121
%123 = load i32, i32* %17
%124 = zext i32 %123 to i64
%125 = getelementptr inbounds i32, i32* %122, i64 %124
%126 = load i32, i32* %125
%127 = load i32*, i32** %13
%128 = call i32 @fputc(i32 %126, i32* %127)
br label %129
129: ; preds = %95
%130 = load i32, i32* %18
%131 = add i32 %130, 1
store i32 %131, i32* %18
br label %91
132: ; preds = %91
store i32 0, i32* %19
br label %133
133: ; preds = %141, %132
%134 = load i32, i32* %19
%135 = load i32, i32* %11
%136 = urem i32 %135, 4
%137 = icmp ult i32 %134, %136
br i1 %137, label %138, label %144
138: ; preds = %133
%139 = load i32*, i32** %13
%140 = call i32 @fputc(i32 0, i32* %139)
br label %141
141: ; preds = %138
%142 = load i32, i32* %19
%143 = add i32 %142, 1
store i32 %143, i32* %19
br label %133
144: ; preds = %133
br label %145
145: ; preds = %144
%146 = load i32, i32* %17
%147 = add i32 %146, 1
store i32 %147, i32* %17
br label %86
148: ; preds = %86
%149 = load i32*, i32** %13
%150 = call i32 @fclose(i32* %149)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"%s/o%02d_%s.bmp\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [21 x i8] c"%c%c%c%c%c%c%c%c%c%c\00"
@.str.3 = [9 x i8] c"%c%c%c%c\00"
define void @save_bitmap_GS(i32** nocapture %0, i32 %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca [500 x i8]
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%9 = mul i32 %4, 3
%10 = mul i32 %9, %5
%11 = add i32 %10, 54
%12 = lshr i32 %11, 8
%13 = trunc i32 %12 to i8
%14 = trunc i32 %11 to i8
%15 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1, i8* %3)
%16 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = shl i32 %11, 8
%18 = ashr i32 %17, 24
%19 = ashr i32 %11, 24
%20 = tail call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 66, i32 77, i8 signext %14, i8 signext %13, i32 %18, i32 %19, i32 0, i32 0, i32 0, i32 0)
%21 = and i32 %4, 255
%22 = lshr i32 %4, 8
%23 = and i32 %22, 255
%24 = tail call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 54, i32 0, i8 signext 0, i8 signext 0, i32 40, i32 0, i32 0, i32 0, i32 %21, i32 %23)
%25 = trunc i32 %5 to i8
%26 = lshr i32 %5, 8
%27 = trunc i32 %26 to i8
%28 = tail call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i8 signext %25, i8 signext %27, i32 0, i32 0, i32 1, i32 0, i32 24, i32 0)
%29 = tail call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i8 signext 0, i8 signext 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
%30 = tail call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i8 signext 0, i8 signext 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
%31 = tail call i32 (i32*, i8*, i32, i32, i8, i8, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 0, i8 signext 0, i8 signext 0)
%32 = icmp eq i32 %5, 0
br i1 %32, label %41, label %33
33: ; preds = %6
%34 = icmp eq i32 %4, 0
%35 = and i32 %4, 3
%36 = icmp eq i32 %35, 0
%37 = zext i32 %5 to i64
%38 = zext i32 %4 to i64
br label %39
39: ; preds = %33, %61
%40 = phi i64 [ 0, %33 ], [ %62, %61 ]
br i1 %34, label %43, label %44
41: ; preds = %61, %6
%42 = tail call i32 @fclose(i32* %16)
ret void
43: ; preds = %44, %39
br i1 %36, label %61, label %64
44: ; preds = %39, %44
%45 = phi i64 [ %59, %44 ], [ 0, %39 ]
%46 = getelementptr inbounds i32*, i32** %0, i64 %45
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 %40
%49 = load i32, i32* %48
%50 = tail call i32 @fputc(i32 %49, i32* %16)
%51 = load i32*, i32** %46
%52 = getelementptr inbounds i32, i32* %51, i64 %40
%53 = load i32, i32* %52
%54 = tail call i32 @fputc(i32 %53, i32* %16)
%55 = load i32*, i32** %46
%56 = getelementptr inbounds i32, i32* %55, i64 %40
%57 = load i32, i32* %56
%58 = tail call i32 @fputc(i32 %57, i32* %16)
%59 = add nuw nsw i64 %45, 1
%60 = icmp eq i64 %59, %38
br i1 %60, label %43, label %44
61: ; preds = %64, %43
%62 = add nuw nsw i64 %40, 1
%63 = icmp eq i64 %62, %37
br i1 %63, label %41, label %39
64: ; preds = %43, %64
%65 = phi i32 [ %67, %64 ], [ 0, %43 ]
%66 = tail call i32 @fputc(i32 0, i32* %16)
%67 = add nuw nsw i32 %65, 1
%68 = icmp eq i32 %67, %35
br i1 %68, label %61, label %64
}