#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 */
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
void adjust_file(FILE *f) {
  unsigned char empty = 0x00;
  long x = ftell(f);
  long i;
  long end = ((((x) % 4) == 0) ? (x) : (((x) / 4) * 4 + 4));
  for (i = 0; i < (end - x); i++) {
    fwrite(&empty, 1, sizeof(unsigned char), f);
  }
}


x86 assembly (clang, -O0):
<adjust_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1162 <adjust_file+0x42>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    117c <adjust_file+0x5c>
mov    -0x18(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
shl    $0x2,%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    -0x18(%rbp),%rcx
cmp    %rcx,%rax
jge    11c6 <adjust_file+0xa6>
mov    -0x8(%rbp),%rcx
lea    -0x9(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fwrite@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118c <adjust_file+0x6c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_file>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <ftell@plt>
test   $0x3,%al
je     1145 <adjust_file+0x25>
lea    0x3(%rax),%rbx
test   %rax,%rax
cmovns %rax,%rbx
and    $0xfffffffffffffffc,%rbx
add    $0x4,%rbx
jmp    1148 <adjust_file+0x28>
mov    %rax,%rbx
sub    %rax,%rbx
test   %rbx,%rbx
jle    1160 <adjust_file+0x40>
xor    %edi,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
add    $0xffffffffffffffff,%rbx
jne    1150 <adjust_file+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @adjust_file(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32* %0, i32** %2
store i8 0, i8* %3
%7 = load i32*, i32** %2
%8 = call i64 @ftell(i32* %7)
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = srem i64 %9, 4
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = load i64, i64* %4
br label %19
14: ; preds = %1
%15 = load i64, i64* %4
%16 = sdiv i64 %15, 4
%17 = mul nsw i64 %16, 4
%18 = add nsw i64 %17, 4
br label %19
19: ; preds = %14, %12
%20 = phi i64 [ %13, %12 ], [ %18, %14 ]
store i64 %20, i64* %6
store i64 0, i64* %5
br label %21
21: ; preds = %30, %19
%22 = load i64, i64* %5
%23 = load i64, i64* %6
%24 = load i64, i64* %4
%25 = sub nsw i64 %23, %24
%26 = icmp slt i64 %22, %25
br i1 %26, label %27, label %33
27: ; preds = %21
%28 = load i32*, i32** %2
%29 = call i32 @fwrite(i8* %3, i32 1, i32 1, i32* %28)
br label %30
30: ; preds = %27
%31 = load i64, i64* %5
%32 = add nsw i64 %31, 1
store i64 %32, i64* %5
br label %21
33: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @adjust_file(i32* nocapture %0) {
%2 = tail call i64 @ftell(i32* %0)
%3 = and i64 %2, 3
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = sdiv i64 %2, 4
%7 = shl nsw i64 %6, 2
%8 = add nsw i64 %7, 4
br label %9
9: ; preds = %1, %5
%10 = phi i64 [ %8, %5 ], [ %2, %1 ]
%11 = sub i64 %10, %2
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9, %13
%14 = phi i64 [ %16, %13 ], [ 0, %9 ]
%15 = tail call i32 @fputc(i32 0, i32* %0)
%16 = add nuw nsw i64 %14, 1
%17 = icmp eq i64 %16, %11
br i1 %17, label %18, label %13
18: ; preds = %13, %9
ret void
}