long size(data, maxl, rcp)
char *data;
long maxl;
struct res *rcp;
{
  char *lp, *skipsp(), *getline();
  char *datap = data;
  char *index(), *outp(), *outs(), *outl(), *outc();
  int flags, min, max;
  long mink, maxk;
  if ((lp = getline()) == 0 || sscanf(lp, "%x", &flags) != 1)
    fatal("bad size flags");
  if ((lp = getline()) == 0 || sscanf(lp, "%d", &min) != 1)
    fatal("bad size min specification");
  if ((lp = getline()) == 0 || sscanf(lp, "%d", &max) != 1)
    fatal("bad size max specification");
  mink = min;
  mink *= 1024L;
  maxk = max;
  maxk *= 1024L;
  datap = outs(datap, (short)flags, &maxl);
  datap = outl(datap, maxk, &maxl);
  datap = outl(datap, mink, &maxl);
  return (datap - data);
}


x86 assembly (clang, -O0):
<size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <getline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11a0 <size+0x50>
mov    -0x20(%rbp),%rdi
lea    0xe74(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11ae <size+0x5e>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1070 <fatal@plt>
mov    $0x0,%al
call   1050 <getline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11e2 <size+0x92>
mov    -0x20(%rbp),%rdi
lea    0xe44(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11f0 <size+0xa0>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1070 <fatal@plt>
mov    $0x0,%al
call   1050 <getline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1224 <size+0xd4>
mov    -0x20(%rbp),%rdi
lea    0xe02(%rip),%rsi
lea    -0x34(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1232 <size+0xe2>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1070 <fatal@plt>
movslq -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x40(%rbp)
movslq -0x34(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%eax
movswl %ax,%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1060 <outs@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <outl@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <outl@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<size>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    %rsi,0x10(%rsp)
xor    %eax,%eax
call   1050 <getline@plt>
test   %rax,%rax
je     118a <size+0x3a>
lea    0xe8a(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1198 <size+0x48>
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1070 <fatal@plt>
xor    %eax,%eax
call   1050 <getline@plt>
test   %rax,%rax
je     11bf <size+0x6f>
lea    0xe67(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11cd <size+0x7d>
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1070 <fatal@plt>
xor    %eax,%eax
call   1050 <getline@plt>
test   %rax,%rax
je     11f4 <size+0xa4>
lea    0xe32(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1202 <size+0xb2>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1070 <fatal@plt>
movslq 0x8(%rsp),%r15
shl    $0xa,%r15
movslq 0x4(%rsp),%rbx
shl    $0xa,%rbx
movswl 0xc(%rsp),%esi
lea    0x10(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <outs@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <outl@plt>
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <outl@plt>
sub    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.res = type opaque
@.str = [3 x i8] c"%x\00"
@.str.1 = [15 x i8] c"bad size flags\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [27 x i8] c"bad size min specification\00"
@.str.4 = [27 x i8] c"bad size max specification\00"
define i64 @size(i8* %0, i64 %1, %struct.res* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca %struct.res*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store %struct.res* %2, %struct.res** %6
%14 = load i8*, i8** %4
store i8* %14, i8** %8
%15 = call i8* (...) @getline()
store i8* %15, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %21, label %17
17: ; preds = %3
%18 = load i8*, i8** %7
%19 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %17, %3
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = call i8* (...) @getline()
store i8* %24, i8** %7
%25 = icmp eq i8* %24, null
br i1 %25, label %30, label %26
26: ; preds = %23
%27 = load i8*, i8** %7
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %26, %23
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
%33 = call i8* (...) @getline()
store i8* %33, i8** %7
%34 = icmp eq i8* %33, null
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = load i8*, i8** %7
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%38 = icmp ne i32 %37, 1
br i1 %38, label %39, label %41
39: ; preds = %35, %32
%40 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %35
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
store i64 %43, i64* %12
%44 = load i64, i64* %12
%45 = mul nsw i64 %44, 1024
store i64 %45, i64* %12
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
store i64 %47, i64* %13
%48 = load i64, i64* %13
%49 = mul nsw i64 %48, 1024
store i64 %49, i64* %13
%50 = load i8*, i8** %8
%51 = load i32, i32* %9
%52 = trunc i32 %51 to i16
%53 = sext i16 %52 to i32
%54 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %50, i32 %53, i64* %5)
store i8* %54, i8** %8
%55 = load i8*, i8** %8
%56 = load i64, i64* %13
%57 = call i8* (i8*, i64, i64*, ...) bitcast (i8* (...)* @outl to i8* (i8*, i64, i64*, ...)*)(i8* %55, i64 %56, i64* %5)
store i8* %57, i8** %8
%58 = load i8*, i8** %8
%59 = load i64, i64* %12
%60 = call i8* (i8*, i64, i64*, ...) bitcast (i8* (...)* @outl to i8* (i8*, i64, i64*, ...)*)(i8* %58, i64 %59, i64* %5)
store i8* %60, i8** %8
%61 = load i8*, i8** %8
%62 = load i8*, i8** %4
%63 = ptrtoint i8* %61 to i64
%64 = ptrtoint i8* %62 to i64
%65 = sub i64 %63, %64
ret i64 %65
}

LLVM IR (-O2):
%struct.res = type opaque
@.str = [3 x i8] c"%x\00"
@.str.1 = [15 x i8] c"bad size flags\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [27 x i8] c"bad size min specification\00"
@.str.4 = [27 x i8] c"bad size max specification\00"
define i64 @size(i8* %0, i64 %1, %struct.res* nocapture readnone %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i64 %1, i64* %4
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = bitcast i32* %7 to i8*
%11 = tail call i8* (...) @getline()
%12 = icmp eq i8* %11, null
br i1 %12, label %16, label %13
13: ; preds = %3
%14 = call i32 (i8*, i8*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%15 = icmp eq i32 %14, 1
br i1 %15, label %18, label %16
16: ; preds = %13, %3
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = call i8* (...) @getline()
%20 = icmp eq i8* %19, null
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = call i32 (i8*, i8*, ...) @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%23 = icmp eq i32 %22, 1
br i1 %23, label %26, label %24
24: ; preds = %21, %18
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = call i8* (...) @getline()
%28 = icmp eq i8* %27, null
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%31 = icmp eq i32 %30, 1
br i1 %31, label %34, label %32
32: ; preds = %29, %26
%33 = call i32 (i8*, ...) bitcast (i32 (...)* @fatal to i32 (i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = shl nsw i64 %36, 10
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = shl nsw i64 %39, 10
%41 = load i32, i32* %5
%42 = shl i32 %41, 16
%43 = ashr exact i32 %42, 16
%44 = call i8* (i8*, i32, i64*, ...) bitcast (i8* (...)* @outs to i8* (i8*, i32, i64*, ...)*)(i8* %0, i32 %43, i64* %4)
%45 = call i8* (i8*, i64, i64*, ...) bitcast (i8* (...)* @outl to i8* (i8*, i64, i64*, ...)*)(i8* %44, i64 %40, i64* %4)
%46 = call i8* (i8*, i64, i64*, ...) bitcast (i8* (...)* @outl to i8* (i8*, i64, i64*, ...)*)(i8* %45, i64 %37, i64* %4)
%47 = ptrtoint i8* %46 to i64
%48 = ptrtoint i8* %0 to i64
%49 = sub i64 %47, %48
ret i64 %49
}