int cmd_zgetpos(int argc, char *argv[]) {
  unsigned char unit;
  if (argc == 1)
    return error((-2), "Usage: zgetposn [unit]");
  sscanf(argv[1], "%hhu", &unit);
  return error(1, "Unit %d has position %d.", unit, zaber_get_position(unit));
}


x86 assembly (clang, -O0):
<cmd_zgetpos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1164 <cmd_zgetpos+0x34>
mov    $0xfffffffe,%edi
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1050 <error@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <cmd_zgetpos+0x7b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea4(%rip),%rsi
lea    -0x11(%rbp),%rdx
mov    $0x0,%al
call   1030 <sscanf@plt>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
movzbl -0x11(%rbp),%edi
mov    $0x0,%al
call   1040 <zaber_get_position@plt>
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
mov    $0x1,%edi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1050 <error@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_zgetpos>:
cmp    $0x1,%edi
jne    1148 <cmd_zgetpos+0x18>
lea    0xec4(%rip),%rsi
mov    $0xfffffffe,%edi
xor    %eax,%eax
jmp    1050 <error@plt>
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
lea    0xebf(%rip),%rsi
lea    0xf(%rsp),%rdx
xor    %eax,%eax
call   1030 <sscanf@plt>
movzbl 0xf(%rsp),%ebx
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <zaber_get_position@plt>
lea    0xea3(%rip),%rsi
mov    $0x1,%edi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <error@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: zgetposn [unit]\00"
@.str.1 = [5 x i8] c"%hhu\00"
@.str.2 = [25 x i8] c"Unit %d has position %d.\00"
define i32 @cmd_zgetpos(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i32, i8*, ...) bitcast (i32 (...)* @error to i32 (i32, i8*, ...)*)(i32 -2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %3
br label %22
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, ...) @sscanf(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%16 = load i8, i8* %6
%17 = zext i8 %16 to i32
%18 = load i8, i8* %6
%19 = zext i8 %18 to i32
%20 = call i32 (i32, ...) bitcast (i32 (...)* @zaber_get_position to i32 (i32, ...)*)(i32 %19)
%21 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @error to i32 (i32, i8*, i32, i32, ...)*)(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %20)
store i32 %21, i32* %3
br label %22
22: ; preds = %11, %9
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: zgetposn [unit]\00"
@.str.1 = [5 x i8] c"%hhu\00"
@.str.2 = [25 x i8] c"Unit %d has position %d.\00"
define i32 @cmd_zgetpos(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i32, i8*, ...) bitcast (i32 (...)* @error to i32 (i32, i8*, ...)*)(i32 -2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %15
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = call i32 (i8*, i8*, ...) @sscanf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = call i32 (i32, ...) bitcast (i32 (...)* @zaber_get_position to i32 (i32, ...)*)(i32 %12)
%14 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @error to i32 (i32, i8*, i32, i32, ...)*)(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13)
br label %15
15: ; preds = %7, %5
%16 = phi i32 [ %6, %5 ], [ %14, %7 ]
ret i32 %16
}