long alrt(data, maxl, rcp)
char *data;
long maxl;
struct res *rcp;
{
  char *lp, *getline();
  int i, s;
  int r1, r2, r3, r4;
  char *datap = data;
  char *outp(), *outs(), *outl(), *outc();
  if ((lp = getline()) == 0 ||
      sscanf(lp, "%d %d %d %d", &r1, &r2, &r3, &r4) != 4)
    fatal("bad rectangle specification");
  if ((lp = getline()) == 0 || sscanf(lp, "%d", &i) != 1)
    fatal("bad item id specification");
  if ((lp = getline()) == 0 || sscanf(lp, "%x", &s) != 1)
    fatal("bad stages specification");
  datap = outs(datap, r1, &maxl);
  datap = outs(datap, r2, &maxl);
  datap = outs(datap, r3, &maxl);
  datap = outs(datap, r4, &maxl);
  datap = outs(datap, i, &maxl);
  datap = outs(datap, s, &maxl);
  return (datap - data);
}


x86 assembly (clang, -O0):
<alrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1040 <getline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     119c <alrt+0x5c>
mov    -0x20(%rbp),%rdi
lea    0xe84(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x38(%rbp),%r9
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x4,%eax
je     11aa <alrt+0x6a>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1060 <fatal@plt>
mov    $0x0,%al
call   1040 <getline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11de <alrt+0x9e>
mov    -0x20(%rbp),%rdi
lea    0xe3f(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     11ec <alrt+0xac>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <fatal@plt>
mov    $0x0,%al
call   1040 <getline@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1220 <alrt+0xe0>
mov    -0x20(%rbp),%rdi
lea    0xe36(%rip),%rsi
lea    -0x28(%rbp),%rdx
mov    $0x0,%al
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     122e <alrt+0xee>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1060 <fatal@plt>
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <outs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <outs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <outs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <outs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <outs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%esi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <outs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alrt>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r14
mov    %rsi,0x20(%rsp)
xor    %eax,%eax
call   1040 <getline@plt>
test   %rax,%rax
je     1185 <alrt+0x45>
lea    0xe9e(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %rax,%rdi
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x4,%eax
je     1193 <alrt+0x53>
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1060 <fatal@plt>
xor    %eax,%eax
call   1040 <getline@plt>
test   %rax,%rax
je     11ba <alrt+0x7a>
lea    0xe63(%rip),%rsi
lea    0x1c(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     11c8 <alrt+0x88>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1060 <fatal@plt>
xor    %eax,%eax
call   1040 <getline@plt>
test   %rax,%rax
je     11ef <alrt+0xaf>
lea    0xe67(%rip),%rsi
lea    0x18(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     11fd <alrt+0xbd>
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1060 <fatal@plt>
mov    0x14(%rsp),%esi
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <outs@plt>
mov    0x10(%rsp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <outs@plt>
mov    0xc(%rsp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <outs@plt>
mov    0x8(%rsp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <outs@plt>
mov    0x1c(%rsp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <outs@plt>
mov    0x18(%rsp),%esi
mov    %rax,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <outs@plt>
sub    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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