#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*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ getOffset(char *);
int getPadding(char *);
int imgH(char *);
int imgL(char *);
int /*<<< orphan*/ printf(char *, unsigned char, unsigned char, unsigned char);
void readRow(char *filename) {
  FILE *fp;
  fp = fopen(filename, "r");
  unsigned char BitMap[3];
  int h = imgH(filename);
  int l = imgL(filename);
  fseek(fp, getOffset(filename), 0);
  for (int j = 0; j < l; j++) {
    for (int i = 0; i < h; i++) {
      fread(BitMap, sizeof(char), 3, fp);
      printf("%03d %03d %03d\n", BitMap[0], BitMap[1], BitMap[2]);
    }
    fread(BitMap, sizeof(char), getPadding(filename), fp);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<readRow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <imgH@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <imgL@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getOffset@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <fseek@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1280 <readRow+0xf0>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    124d <readRow+0xbd>
lea    -0x13(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1050 <fread@plt>
mov    -0x13(%rbp),%cl
mov    -0x12(%rbp),%al
lea    0xdd2(%rip),%rdi
movzbl %cl,%esi
movzbl %al,%edx
movzbl -0x11(%rbp),%ecx
call   1080 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1200 <readRow+0x70>
lea    -0x13(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <getPadding@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ed <readRow+0x5d>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readRow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbp
lea    0xe58(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <imgH@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1030 <imgL@plt>
mov    %eax,%r12d
mov    %rbp,0x10(%rsp)
mov    %rbp,%rdi
call   1070 <getOffset@plt>
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <fseek@plt>
mov    %r12d,0xc(%rsp)
test   %r12d,%r12d
jle    1264 <readRow+0xd4>
lea    0x9(%rsp),%rbp
lea    0xe0a(%rip),%r13
jmp    1227 <readRow+0x97>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
call   1090 <getPadding@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
je     1264 <readRow+0xd4>
mov    %r15d,%r12d
test   %r15d,%r15d
jle    1200 <readRow+0x70>
nop
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
movzbl 0x9(%rsp),%esi
movzbl 0xa(%rsp),%edx
movzbl 0xb(%rsp),%ecx
mov    %r13,%rdi
call   1080 <printf@plt>
add    $0xffffffff,%r12d
jne    1230 <readRow+0xa0>
jmp    1200 <readRow+0x70>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [16 x i8] c"%03d %03d %03d\0A\00"
define void @readRow(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [3 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i8*, i8** %2
%12 = call i32 @imgH(i8* %11)
store i32 %12, i32* %5
%13 = load i8*, i8** %2
%14 = call i32 @imgL(i8* %13)
store i32 %14, i32* %6
%15 = load i32*, i32** %3
%16 = load i8*, i8** %2
%17 = call i32 @getOffset(i8* %16)
%18 = call i32 @fseek(i32* %15, i32 %17, i32 0)
store i32 0, i32* %7
br label %19
19: ; preds = %48, %1
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %51
23: ; preds = %19
store i32 0, i32* %8
br label %24
24: ; preds = %39, %23
%25 = load i32, i32* %8
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %42
28: ; preds = %24
%29 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%30 = load i32*, i32** %3
%31 = call i32 @fread(i8* %29, i32 1, i32 3, i32* %30)
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%33 = load i8, i8* %32
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%35 = load i8, i8* %34
%36 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
%37 = load i8, i8* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %33, i8 zeroext %35, i8 zeroext %37)
br label %39
39: ; preds = %28
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %24
42: ; preds = %24
%43 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%44 = load i8*, i8** %2
%45 = call i32 @getPadding(i8* %44)
%46 = load i32*, i32** %3
%47 = call i32 @fread(i8* %43, i32 1, i32 %45, i32* %46)
br label %48
48: ; preds = %42
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %19
51: ; preds = %19
%52 = load i32*, i32** %3
%53 = call i32 @fclose(i32* %52)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [16 x i8] c"%03d %03d %03d\0A\00"
define void @readRow(i8* %0) {
%2 = alloca [3 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @imgH(i8* %0)
%6 = tail call i32 @imgL(i8* %0)
%7 = tail call i32 @getOffset(i8* %0)
%8 = tail call i32 @fseek(i32* %3, i32 %7, i32 0)
%9 = icmp sgt i32 %6, 0
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = icmp sgt i32 %5, 0
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
br label %14
14: ; preds = %10, %18
%15 = phi i32 [ 0, %10 ], [ %21, %18 ]
br i1 %11, label %23, label %18
16: ; preds = %18, %1
%17 = tail call i32 @fclose(i32* %3)
ret void
18: ; preds = %23, %14
%19 = tail call i32 @getPadding(i8* %0)
%20 = call i32 @fread(i8* %4, i32 1, i32 %19, i32* %3)
%21 = add nuw nsw i32 %15, 1
%22 = icmp eq i32 %21, %6
br i1 %22, label %16, label %14
23: ; preds = %14, %23
%24 = phi i32 [ %30, %23 ], [ 0, %14 ]
%25 = call i32 @fread(i8* %4, i32 1, i32 3, i32* %3)
%26 = load i8, i8* %4
%27 = load i8, i8* %12
%28 = load i8, i8* %13
%29 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %26, i8 zeroext %27, i8 zeroext %28)
%30 = add nuw nsw i32 %24, 1
%31 = icmp eq i32 %30, %5
br i1 %31, label %18, label %23
}