int dotcpstat(argc, argv)
int argc;
char *argv[];
{
  register struct tcb *tcb;
  extern char notval[];
  if (argc < 2) {
    tstat();
  } else {
    tcb = (struct tcb *)htol(argv[1]);
    if (tcpval(tcb)) {
      state_tcp(tcb);
    } else {
      printf(notval);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<dotcpstat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1175 <dotcpstat+0x25>
mov    $0x0,%al
call   1070 <tstat@plt>
jmp    11c1 <dotcpstat+0x71>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x0,%al
call   1050 <htol@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1040 <tcpval@plt>
cmp    $0x0,%eax
je     11ae <dotcpstat+0x5e>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <state_tcp@plt>
jmp    11bc <dotcpstat+0x6c>
mov    0x2e2b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11c1 <dotcpstat+0x71>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotcpstat>:
push   %rbx
cmp    $0x1,%edi
jg     115f <dotcpstat+0xf>
xor    %eax,%eax
call   1070 <tstat@plt>
jmp    1195 <dotcpstat+0x45>
mov    0x8(%rsi),%rdi
xor    %eax,%eax
call   1050 <htol@plt>
movslq %eax,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <tcpval@plt>
test   %eax,%eax
je     1187 <dotcpstat+0x37>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <state_tcp@plt>
jmp    1195 <dotcpstat+0x45>
mov    0x2e52(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.tcb = type opaque
@notval = external global [0 x i8]
define i32 @dotcpstat(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.tcb*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @tstat()
br label %26
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) bitcast (i32 (...)* @htol to i32 (i8*, ...)*)(i8* %13)
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to %struct.tcb*
store %struct.tcb* %16, %struct.tcb** %5
%17 = load %struct.tcb*, %struct.tcb** %5
%18 = call i32 (%struct.tcb*, ...) bitcast (i32 (...)* @tcpval to i32 (%struct.tcb*, ...)*)(%struct.tcb* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = load %struct.tcb*, %struct.tcb** %5
%22 = call i32 (%struct.tcb*, ...) bitcast (i32 (...)* @state_tcp to i32 (%struct.tcb*, ...)*)(%struct.tcb* %21)
br label %25
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([0 x i8], [0 x i8]* @notval, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
br label %26
26: ; preds = %25, %8
ret i32 0
}

LLVM IR (-O2):
%struct.tcb = type opaque
@notval = external global [0 x i8]
define i32 @dotcpstat(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @tstat()
br label %18
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) bitcast (i32 (...)* @htol to i32 (i8*, ...)*)(i8* %8)
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to %struct.tcb*
%12 = tail call i32 (%struct.tcb*, ...) bitcast (i32 (...)* @tcpval to i32 (%struct.tcb*, ...)*)(%struct.tcb* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %6
%15 = tail call i32 (%struct.tcb*, ...) bitcast (i32 (...)* @state_tcp to i32 (%struct.tcb*, ...)*)(%struct.tcb* %11)
br label %18
16: ; preds = %6
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([0 x i8], [0 x i8]* @notval, i64 0, i64 0))
br label %18
18: ; preds = %14, %16, %4
ret i32 0
}