#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 */
struct stat {
  scalar_t__ st_size;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stat(char *, struct stat *);
int main() {
  struct stat s;
  unsigned int seg, add;
  stat("kernel.bin", &s);
  seg = (unsigned int)s.st_size / 512;
  if (((unsigned int)s.st_size % 512) != 0) {
    add = (seg + 1) * 512 - (unsigned int)s.st_size;
    ++seg;
  } else {
    add = 0;
  }
  printf("%i\n", (50 - seg) * 512 + add);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x10(%rbp),%rax
shr    $0x9,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
and    $0x1ff,%eax
cmp    $0x0,%eax
je     117b <main+0x5b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
shl    $0x9,%eax
mov    -0x10(%rbp),%rcx
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <main+0x62>
movl   $0x0,-0x18(%rbp)
mov    $0x32,%esi
sub    -0x14(%rbp),%esi
shl    $0x9,%esi
add    -0x18(%rbp),%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    %rsp,%rsi
call   1040 <stat@plt>
mov    (%rsp),%esi
mov    %esi,%eax
shr    $0x9,%eax
lea    0x1(%rax),%ecx
mov    %ecx,%edx
shl    $0x9,%edx
sub    %esi,%edx
and    $0x1ff,%esi
test   %esi,%esi
cmove  %eax,%ecx
cmovne %edx,%esi
shl    $0x9,%ecx
sub    %ecx,%esi
add    $0x6400,%esi
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [11 x i8] c"kernel.bin\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.stat
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @stat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %struct.stat* %2)
%6 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%7 = load i64, i64* %6
%8 = trunc i64 %7 to i32
%9 = udiv i32 %8, 512
store i32 %9, i32* %3
%10 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = urem i32 %12, 512
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %0
%16 = load i32, i32* %3
%17 = add i32 %16, 1
%18 = mul i32 %17, 512
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%20 = load i64, i64* %19
%21 = trunc i64 %20 to i32
%22 = sub i32 %18, %21
store i32 %22, i32* %4
%23 = load i32, i32* %3
%24 = add i32 %23, 1
store i32 %24, i32* %3
br label %26
25: ; preds = %0
store i32 0, i32* %4
br label %26
26: ; preds = %25, %15
%27 = load i32, i32* %3
%28 = sub i32 50, %27
%29 = mul i32 %28, 512
%30 = load i32, i32* %4
%31 = add i32 %29, %30
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [11 x i8] c"kernel.bin\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = call i32 @stat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%4 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = trunc i64 %5 to i32
%7 = lshr i32 %6, 9
%8 = and i32 %6, 511
%9 = icmp eq i32 %8, 0
%10 = add nuw nsw i32 %7, 1
%11 = shl i32 %10, 9
%12 = sub i32 %11, %6
%13 = select i1 %9, i32 %7, i32 %10
%14 = select i1 %9, i32 0, i32 %12
%15 = mul i32 %13, -512
%16 = add i32 %15, 25600
%17 = add i32 %16, %14
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
ret i32 0
}