#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 scalar_t__ uint32_t;
typedef int /*<<< orphan*/ u_long;
typedef scalar_t__ off_t;
typedef int intmax_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void psum2(char *fn, uint32_t val, off_t len) {
  (void)printf("%lu %jd", (u_long)val, (intmax_t)(len + 511) / 512);
  if (fn != NULL)
    (void)printf(" %s", fn);
  (void)printf("\n");
}


x86 assembly (clang, -O0):
<psum2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rax
add    $0x1ff,%rax
mov    $0x200,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     1169 <psum2+0x59>
mov    -0x8(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psum2>:
push   %rbx
mov    %rdi,%rbx
lea    0x1ff(%rdx),%eax
add    $0x3fe,%edx
test   %eax,%eax
cmovns %eax,%edx
sar    $0x9,%edx
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %rbx,%rbx
je     115c <psum2+0x3c>
lea    0xeb6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%lu %jd\00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @psum2(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %5
%8 = trunc i64 %7 to i32
%9 = load i64, i64* %6
%10 = add nsw i64 %9, 511
%11 = trunc i64 %10 to i32
%12 = sdiv i32 %11, 512
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %12)
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%lu %jd\00"
@.str.1 = [4 x i8] c" %s\00"
define void @psum2(i8* %0, i64 %1, i64 %2) {
%4 = trunc i64 %1 to i32
%5 = trunc i64 %2 to i32
%6 = add i32 %5, 511
%7 = sdiv i32 %6, 512
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %7)
%9 = icmp eq i8* %0, null
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %10, %3
%13 = tail call i32 @putchar(i32 10)
ret void
}