#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 */
int imgL(char *);
int nBit(char *);
int rowL(char *);
int getPadding(char *filename) {
  int rowSize = rowL(filename);
  int bit = nBit(filename);
  int l = imgL(filename);
  int nByte = l * bit / 8;
  if (nByte % 4 == 0)
    return 0;
  else {
    int nPadding = rowSize % (nByte);
    return nPadding;
  }
}


x86 assembly (clang, -O0):
<getPadding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <rowL@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <nBit@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <imgL@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1192 <getPadding+0x62>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <getPadding+0x72>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPadding>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <rowL@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1050 <nBit@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <imgL@plt>
imul   %ebp,%eax
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
sar    $0x3,%ecx
test   $0x3,%cl
je     116e <getPadding+0x3e>
mov    %r14d,%eax
cltd
idiv   %ecx
mov    %edx,%eax
jmp    1170 <getPadding+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getPadding(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @rowL(i8* %9)
store i32 %10, i32* %4
%11 = load i8*, i8** %3
%12 = call i32 @nBit(i8* %11)
store i32 %12, i32* %5
%13 = load i8*, i8** %3
%14 = call i32 @imgL(i8* %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = mul nsw i32 %15, %16
%18 = sdiv i32 %17, 8
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = srem i32 %19, 4
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %1
store i32 0, i32* %2
br label %28
23: ; preds = %1
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = srem i32 %24, %25
store i32 %26, i32* %8
%27 = load i32, i32* %8
store i32 %27, i32* %2
br label %28
28: ; preds = %23, %22
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @getPadding(i8* %0) {
%2 = tail call i32 @rowL(i8* %0)
%3 = tail call i32 @nBit(i8* %0)
%4 = tail call i32 @imgL(i8* %0)
%5 = mul nsw i32 %4, %3
%6 = sdiv i32 %5, 8
%7 = and i32 %6, 3
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = srem i32 %2, %6
br label %11
11: ; preds = %1, %9
%12 = phi i32 [ %10, %9 ], [ 0, %1 ]
ret i32 %12
}